Fix PaletteScreen crashing on app suspends
This commit is contained in:
parent
d841399f51
commit
742126e4eb
2 changed files with 10 additions and 8 deletions
|
|
@ -316,7 +316,7 @@ class MangaScreen(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCoverLoaded = screenModel::setPaletteColor,
|
onCoverLoaded = screenModel::setPaletteColor,
|
||||||
onPaletteScreenClick = { navigator.push(PaletteScreen(successState.seedColor)) }
|
onPaletteScreenClick = { navigator.push(PaletteScreen(successState.seedColor?.toArgb())) }
|
||||||
// KMK <--
|
// KMK <--
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.ui.manga
|
package eu.kanade.tachiyomi.ui.manga
|
||||||
|
|
||||||
|
import androidx.annotation.ColorInt
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
|
@ -29,29 +30,30 @@ import uy.kohesive.injekt.api.get
|
||||||
* A screen that displays a colors palette of current theme.
|
* A screen that displays a colors palette of current theme.
|
||||||
*/
|
*/
|
||||||
class PaletteScreen(
|
class PaletteScreen(
|
||||||
private val seedColor: Color?,
|
@ColorInt private val seedColor: Int?,
|
||||||
) : Screen() {
|
) : Screen() {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun Content() {
|
override fun Content() {
|
||||||
|
val seedColor = seedColor?.let { Color(it) } ?: MaterialTheme.colorScheme.primary
|
||||||
val uiPreferences = remember { Injekt.get<UiPreferences>() }
|
val uiPreferences = remember { Injekt.get<UiPreferences>() }
|
||||||
|
|
||||||
if (uiPreferences.themeCoverBased().get()) {
|
if (uiPreferences.themeCoverBased().get()) {
|
||||||
DynamicMaterialTheme(
|
DynamicMaterialTheme(
|
||||||
seedColor = seedColor ?: MaterialTheme.colorScheme.primary,
|
seedColor = seedColor,
|
||||||
useDarkTheme = isSystemInDarkTheme(),
|
useDarkTheme = isSystemInDarkTheme(),
|
||||||
withAmoled = uiPreferences.themeDarkAmoled().get(),
|
withAmoled = uiPreferences.themeDarkAmoled().get(),
|
||||||
style = uiPreferences.themeCoverBasedStyle().get(),
|
style = uiPreferences.themeCoverBasedStyle().get(),
|
||||||
animate = true,
|
animate = true,
|
||||||
content = { MaterialThemeContent() },
|
content = { MaterialThemeContent(seedColor) },
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
MaterialThemeContent()
|
MaterialThemeContent(seedColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MaterialThemeContent() {
|
fun MaterialThemeContent(seedColor: Color) {
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
|
|
@ -68,9 +70,9 @@ class PaletteScreen(
|
||||||
) {
|
) {
|
||||||
ButtonsColor(
|
ButtonsColor(
|
||||||
"accent & onPrimary",
|
"accent & onPrimary",
|
||||||
seedColor ?: MaterialTheme.colorScheme.primary,
|
seedColor,
|
||||||
"accent & contentColor",
|
"accent & contentColor",
|
||||||
seedColor ?: MaterialTheme.colorScheme.primary,
|
seedColor,
|
||||||
MaterialTheme.colorScheme.onPrimary,
|
MaterialTheme.colorScheme.onPrimary,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue