🛠️ Fix issues with dark theme switching

* Fixed issue with dark theme switching incorrectly on API 35
This commit is contained in:
Acclorite 2024-11-12 09:05:05 +02:00
parent 812584b5bb
commit c40b068e11
3 changed files with 9 additions and 18 deletions

View file

@ -35,7 +35,7 @@
<activity <activity
android:name=".Activity" android:name=".Activity"
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|locale|density" android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|locale|density|uiMode"
android:exported="true" android:exported="true"
android:theme="@style/Theme.Start.Splash"> android:theme="@style/Theme.Start.Splash">
<intent-filter> <intent-filter>

View file

@ -329,8 +329,8 @@ class HistoryViewModel @Inject constructor(
return return
} }
val history = historyWithoutBooks.map { val history = historyWithoutBooks.mapNotNull {
val book = books.find { book -> book.id == it.bookId }!! val book = books.find { book -> book.id == it.bookId } ?: return@mapNotNull null
it.copy( it.copy(
book = book book = book
) )
@ -340,8 +340,8 @@ class HistoryViewModel @Inject constructor(
history history
.filter { .filter {
val book = books.find { book -> book.id == it.bookId }!! val book = books.find { book -> book.id == it.bookId }
book.title.lowercase().trim().contains(query.lowercase().trim()) book?.title?.lowercase()?.trim()?.contains(query.lowercase().trim()) == true
}.groupBy { item -> }.groupBy { item ->
val calendar = Calendar.getInstance().apply { val calendar = Calendar.getInstance().apply {
timeInMillis = item.time timeInMillis = item.time

View file

@ -21,7 +21,6 @@ import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -55,18 +54,10 @@ fun LibraryBookItem(
onLongClick: () -> Unit, onLongClick: () -> Unit,
onButtonClick: () -> Unit onButtonClick: () -> Unit
) { ) {
val primaryColor = MaterialTheme.colorScheme.primary val backgroundColor = if (book.second) MaterialTheme.colorScheme.primary
val onPrimaryColor = MaterialTheme.colorScheme.onPrimary
val onSurfaceColor = MaterialTheme.colorScheme.onSurface
val backgroundColor = remember(book.second) {
if (book.second) primaryColor
else Color.Transparent else Color.Transparent
} val fontColor = if (book.second) MaterialTheme.colorScheme.onPrimary
val fontColor = remember(book.second) { else MaterialTheme.colorScheme.onSurface
if (book.second) onPrimaryColor
else onSurfaceColor
}
val progress = rememberSaveable(book.first.progress) { val progress = rememberSaveable(book.first.progress) {
"${book.first.progress.calculateProgress(1)}%" "${book.first.progress.calculateProgress(1)}%"