feat: dynamic color toggle

This commit is contained in:
Ushie 2022-08-16 02:23:53 +03:00
parent 7a34c03981
commit ebd0f74a3a
No known key found for this signature in database
GPG key ID: 0EF73F1CA38B2D5F
5 changed files with 11 additions and 4 deletions

View file

@ -47,6 +47,7 @@ class MainActivity : ComponentActivity() {
setContent {
ManagerTheme(
isDarkTheme = preferences.theme == Theme.DARK || preferences.theme == Theme.SYSTEM && isSystemInDarkTheme(),
isDynamicColor = preferences.dynamicColor
) {
val navigator = rememberBackstackNavigator<AppDestination>(AppDestination.Home)
@ -65,7 +66,6 @@ class MainActivity : ComponentActivity() {
onClickAbout = { navigator.push(AppDestination.About) },
onClickSettings = { navigator.push(AppDestination.Settings) }
)
is AppDestination.Plugins -> PluginsScreen()
is AppDestination.Install -> InstallerScreen(
onClickBack = navigator::pop,
)

View file

@ -7,6 +7,7 @@ import com.aliucord.manager.ui.theme.Theme
class PreferencesManager(preferences: SharedPreferences) : BasePreferenceManager(preferences) {
var theme by enumPreference("theme", Theme.SYSTEM)
var dynamicColor by booleanPreference("dynamic_color", true)
var replaceBg by booleanPreference("replace_bg", true)
var devMode by booleanPreference("dev_mode", false)
var debuggable by booleanPreference("debuggable", false)

View file

@ -17,9 +17,6 @@ sealed interface AppDestination : Destination {
@Parcelize
object Home : AppDestination
@Parcelize
object Plugins : AppDestination
@Parcelize
object Install : AppDestination

View file

@ -72,6 +72,12 @@ fun SettingsScreen(
}
)
SwitchSetting(
checked = preferences.dynamicColor,
title = { Text(stringResource(R.string.dynamic_color)) },
onCheckedChange = { preferences.dynamicColor = it }
)
Divider()
OutlinedTextField(
@ -158,6 +164,7 @@ fun SwitchSetting(
title: @Composable () -> Unit,
description: @Composable (() -> Unit)? = null,
onCheckedChange: (Boolean) -> Unit,
enabled: Boolean = true
) {
ListItem(
modifier = Modifier.clickable { onCheckedChange(!checked) },
@ -166,6 +173,7 @@ fun SwitchSetting(
supportingText = description,
trailingContent = {
Switch(
enabled = enabled,
checked = checked,
onCheckedChange = onCheckedChange
)

View file

@ -48,4 +48,5 @@
<string name="launch">Launch</string>
<string name="uninstall">Uninstall</string>
<string name="version">Version</string>
<string name="dynamic_color">Dynamic color</string>
</resources>