-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
里面有动态配色和主题样式两个设置的实现 后续还有待优化 SharedPreferences 的读写方式
- Loading branch information
1 parent
e729125
commit 32e2292
Showing
21 changed files
with
522 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/src/main/kotlin/cn/super12138/todo/constants/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cn.super12138.todo.constants | ||
|
||
object Constants { | ||
const val SP_NAME = "cn.super12138.todo_preferences" | ||
|
||
const val PREF_DYNAMIC_COLOR = "dynamic_color" | ||
const val PREF_DYNAMIC_COLOR_DEFAULT = true | ||
|
||
const val PREF_PALETTE_STYLE = "palette_style" | ||
const val PREF_PALETTE_STYLE_DEFAULT = 1 // TonalSpot | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/kotlin/cn/super12138/todo/constants/GlobalValues.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package cn.super12138.todo.constants | ||
|
||
import cn.super12138.todo.utils.SPDelegates | ||
|
||
object GlobalValues { | ||
var dynamicColor: Boolean by SPDelegates( | ||
Constants.PREF_DYNAMIC_COLOR, | ||
Constants.PREF_DYNAMIC_COLOR_DEFAULT | ||
) | ||
var paletteStyle: Int by SPDelegates( | ||
Constants.PREF_PALETTE_STYLE, | ||
Constants.PREF_PALETTE_STYLE_DEFAULT | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ enum class TodoScreen { | |
Main, | ||
TodoEditor, | ||
SettingsMain, | ||
SettingsAppearance, | ||
SettingsAbout, | ||
SettingsAboutLicence | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
app/src/main/kotlin/cn/super12138/todo/ui/pages/settings/SettingsAppearance.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cn.super12138.todo.ui.pages.settings | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.ColorLens | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.input.nestedscroll.nestedScroll | ||
import androidx.compose.ui.res.stringResource | ||
import cn.super12138.todo.R | ||
import cn.super12138.todo.constants.Constants | ||
import cn.super12138.todo.ui.components.LargeTopAppBarScaffold | ||
import cn.super12138.todo.ui.pages.settings.components.SwitchSettingsItem | ||
import cn.super12138.todo.ui.pages.settings.components.palette.PalettePicker | ||
import cn.super12138.todo.ui.theme.appPaletteStyle | ||
import cn.super12138.todo.ui.theme.isDynamicColorEnable | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun SettingsAppearance( | ||
onNavigateUp: () -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior() | ||
LargeTopAppBarScaffold( | ||
title = stringResource(R.string.pref_appearance), | ||
onBack = onNavigateUp, | ||
scrollBehavior = scrollBehavior, | ||
modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection), | ||
) { innerPadding -> | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(innerPadding) | ||
.verticalScroll(rememberScrollState()) | ||
) { | ||
SwitchSettingsItem( | ||
key = Constants.PREF_DYNAMIC_COLOR, | ||
default = Constants.PREF_DYNAMIC_COLOR_DEFAULT, | ||
leadingIcon = Icons.Outlined.ColorLens, | ||
title = stringResource(R.string.pref_appearance_dynamic_color), | ||
description = stringResource(R.string.pref_appearance_dynamic_color_desc), | ||
onCheckedChange = { isDynamicColorEnable = it }, | ||
) | ||
|
||
PalettePicker(onPaletteChange = { appPaletteStyle = it }) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.