Skip to content

Commit

Permalink
feat: 添加夜间模式
Browse files Browse the repository at this point in the history
  • Loading branch information
jixiaoyong committed Mar 30, 2024
1 parent ea28778 commit add995e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 36 deletions.
7 changes: 6 additions & 1 deletion src/main/kotlin/io/github/jixiaoyong/pages/MainPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ fun App() {
scope.launch(Dispatchers.Default) {
detector = OsThemeDetector.getDetector()
detector?.registerListener(listener)
detector?.isDark?.let {
isDarkTheme = it

}
}

onDispose {
Expand Down Expand Up @@ -83,6 +87,7 @@ fun App() {
} else {
Color.Transparent
}

Row(
modifier =
Modifier
Expand All @@ -101,7 +106,7 @@ fun App() {
tint = MaterialTheme.colors.primary,
modifier = Modifier.padding(end = 5.dp).size(18.dp)
)
Text(route.second)
Text(route.second, color = MaterialTheme.colors.onBackground)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fun PageSettingInfo() {
) {
Column(modifier = Modifier.weight(1f, true)) {
Text(
"是否自动匹配签名",
"自动匹配签名",
style = TextStyle(fontWeight = FontWeight.ExtraBold, fontSize = 16.sp)
)
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ fun SignInfoItem(
keyboardOptions =
if (isPwd) KeyboardOptions.Default.copy(keyboardType = KeyboardType.Password) else KeyboardOptions.Default,
shape = RoundedCornerShape(size = 15.dp),
textStyle = LocalTextStyle.current.copy(fontWeight = FontWeight.Normal, color = Color.Black)
textStyle = LocalTextStyle.current.copy(
fontWeight = FontWeight.Normal,
color = MaterialTheme.colors.onBackground
)
)
if (null != onClick) ButtonWidget(
onClick = onClick,
Expand Down
51 changes: 18 additions & 33 deletions src/main/kotlin/io/github/jixiaoyong/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,28 @@ private val lightColors = Colors(
onBackground = Color.Black,
surface = Color(0xffF2F2F7),
onSurface = Color(0xFFBABEBE),
primaryVariant = Color(0xff0056A3), // 主色调的变体
secondary = Color(0xFFBABEBE), // 次要颜色
secondaryVariant = Color(0xFFE7E7E7), // 次要颜色的变体
error = Color(0xffD32F2F), // 错误颜色
onSecondary = Color(0xff808080), // 在次要颜色上的颜色
onError = Color.White, // 在错误颜色上的颜色
primaryVariant = Color(0xff0056A3),
secondary = Color(0xFFBABEBE),
secondaryVariant = Color(0xFFE7E7E7),
error = Color(0xffD32F2F),
onSecondary = Color(0xff808080),
onError = Color.White,
isLight = true
)

//private val lightColors = Colors(
// primary = Color(0xFF03a9f4),
// secondary = Color(0xFF3ddc84),
// background = Color(0xFFFFFFF),
// onBackground = Color(0xFF0088D0),
// surface = Color(0xFFD6E8E7),
// primaryVariant = Color(0xFF008DD5),
// onPrimary = Color(0xFF212121),
// secondaryVariant = Color(0xFF00782B),
// onSecondary = Color(0xFF484848),
// error = Color(0xFF3DDC84),
// onError = Color(0xFF212121),
// onSurface = Color(0xFF212121),
// isLight = true
//)

private val darkColors = Colors(
primary = Color(0xFF00BFA5),
secondary = Color(0xFF2979FF),
background = Color(0xFF121212),
onBackground = Color(0xFF005F4B),
surface = Color(0xFF383838),
primaryVariant = Color(0xFF00A189),
onPrimary = Color(0xFFE0E0E0),
secondaryVariant = Color(0xFFE9FFFF),
onSecondary = Color(0xFFE0E0E0),
error = Color(0xFF2979FF),
onError = Color(0xFFFFFFFF),
onSurface = Color(0xFFFFFFFF),
primary = Color(0xff007AFF),
onPrimary = Color(0xffDFE1E5),
background = Color(0xff1E1F22),
onBackground = Color(0xffDFDFDF),
surface = Color(0xff3F403F),
onSurface = Color(0xFFBABEBE),
primaryVariant = Color(0xff0056A3),
secondary = Color(0xff4B4B4B),
secondaryVariant = Color(0xff343434),
error = Color(0xffD32F2F),
onSecondary = Color(0xff808080),
onError = Color.White,
isLight = false
)

0 comments on commit add995e

Please sign in to comment.