From 10a3a4ac1e751d0884b1aa7838fa5b8a91e4c4c6 Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Sat, 15 Jul 2023 22:39:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=A4=9C=E9=97=B4?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E2=80=9C=E9=9D=99=E8=B0=A7=E8=93=9D=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/huanchengfly/tieba/post/App.kt | 18 +++++++-- .../post/ui/common/theme/compose/Theme.kt | 1 + .../forum/threadlist/ForumThreadListPage.kt | 9 ++--- .../settings/custom/CustomSettingsPage.kt | 12 ++++-- .../tieba/post/utils/ThemeUtil.kt | 3 ++ .../main/res/drawable/bg_popup_dark_blue.xml | 6 +++ app/src/main/res/values/arrays.xml | 8 +++- app/src/main/res/values/colors.xml | 39 ++++++++++++++++--- app/src/main/res/values/styles.xml | 29 ++++++++++++++ 9 files changed, 105 insertions(+), 20 deletions(-) create mode 100644 app/src/main/res/drawable/bg_popup_dark_blue.xml diff --git a/app/src/main/java/com/huanchengfly/tieba/post/App.kt b/app/src/main/java/com/huanchengfly/tieba/post/App.kt index 3a0cb5e2..f1252b28 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/App.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/App.kt @@ -456,7 +456,13 @@ class App : Application(), IApp, SketchFactory { return getColorByAttr(context, R.attr.colorTextSecondary, theme) } return if (ThemeUtil.isNightMode(theme)) { - context.getColorCompat(R.color.theme_color_on_chip_night) + context.getColorCompat( + resources.getIdentifier( + "theme_color_on_chip_$theme", + "color", + packageName + ) + ) } else context.getColorCompat(R.color.theme_color_on_chip_light) } R.attr.colorUnselected -> { @@ -589,8 +595,14 @@ class App : Application(), IApp, SketchFactory { } } R.attr.colorOnToolbarBar -> { - return if (ThemeUtil.isNightMode(theme) || ThemeUtil.getThemeTranslucent() == ThemeUtil.THEME_TRANSLUCENT_LIGHT) { - context.getColorCompat(R.color.theme_color_on_toolbar_bar_dark) + return if (ThemeUtil.isTranslucentTheme(theme) || ThemeUtil.isNightMode(theme)) { + context.getColorCompat( + resources.getIdentifier( + "theme_color_on_toolbar_bar_$theme", + "color", + packageName + ) + ) } else { context.getColorCompat(R.color.theme_color_on_toolbar_bar_light) } diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/common/theme/compose/Theme.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/common/theme/compose/Theme.kt index 35a29175..4e13c23e 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/common/theme/compose/Theme.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/common/theme/compose/Theme.kt @@ -95,6 +95,7 @@ fun getColorPalette( onSecondary = Color(0xFFFFFFFF), background = extendedColors.background, onBackground = extendedColors.text, + surface = extendedColors.card ) } else { lightColors( diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/forum/threadlist/ForumThreadListPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/forum/threadlist/ForumThreadListPage.kt index f95bcc7e..9e31ee99 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/forum/threadlist/ForumThreadListPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/forum/threadlist/ForumThreadListPage.kt @@ -38,7 +38,6 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.huanchengfly.tieba.post.R -import com.huanchengfly.tieba.post.activities.ThreadActivity import com.huanchengfly.tieba.post.api.abstractText import com.huanchengfly.tieba.post.api.models.protos.ThreadInfo import com.huanchengfly.tieba.post.api.models.protos.frsPage.Classify @@ -48,6 +47,8 @@ import com.huanchengfly.tieba.post.arch.collectPartialAsState import com.huanchengfly.tieba.post.arch.onEvent import com.huanchengfly.tieba.post.arch.pageViewModel import com.huanchengfly.tieba.post.ui.common.windowsizeclass.WindowWidthSizeClass +import com.huanchengfly.tieba.post.ui.page.LocalNavigator +import com.huanchengfly.tieba.post.ui.page.destinations.ThreadPageDestination import com.huanchengfly.tieba.post.ui.page.forum.getSortType import com.huanchengfly.tieba.post.ui.widgets.Chip import com.huanchengfly.tieba.post.ui.widgets.compose.FeedCard @@ -242,6 +243,7 @@ fun ForumThreadListPage( viewModel: ForumThreadListViewModel = if (isGood) pageViewModel() else pageViewModel() ) { val context = LocalContext.current + val navigator = LocalNavigator.current val snackbarHostState = LocalSnackbarHostState.current LazyLoad(loaded = viewModel.initialized) { viewModel.send(getFirstLoadIntent(context, forumName, isGood)) @@ -333,10 +335,7 @@ fun ForumThreadListPage( goodClassifyId = goodClassifyId, goodClassifyHoldersProvider = { goodClassifies }, onItemClicked = { - ThreadActivity.launch( - context, - it.threadId.toString() - ) + navigator.navigate(ThreadPageDestination(it.threadId)) }, onAgree = { viewModel.send( diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt index d21d7316..cee29a5e 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringArrayResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.google.accompanist.drawablepainter.rememberDrawablePainter @@ -82,6 +83,8 @@ fun CustomSettingsPage( ) } prefsItem { + val darkThemeValues = stringArrayResource(id = R.array.dark_theme_values) + val darkThemeNames = stringArrayResource(id = R.array.dark_theme_names) ListPref( key = "dark_theme", title = stringResource(id = R.string.settings_night_mode), @@ -95,10 +98,11 @@ fun CustomSettingsPage( ) } }, - entries = mapOf( - ThemeUtil.THEME_GREY_DARK to "深邃灰", - ThemeUtil.THEME_AMOLED_DARK to "A屏黑" - ), + entries = darkThemeValues.associateWith { value -> + darkThemeNames[darkThemeValues.indexOf( + value + )] + }, useSelectedAsSummary = true, ) } diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt index 52c5be1e..3e66b95f 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt @@ -67,6 +67,7 @@ object ThemeUtil { const val THEME_PURPLE = "purple" const val THEME_PINK = "pink" const val THEME_RED = "red" + const val THEME_BLUE_DARK = "blue_dark" const val THEME_GREY_DARK = "grey_dark" const val THEME_AMOLED_DARK = "amoled_dark" @@ -395,6 +396,7 @@ object ThemeUtil { THEME_PURPLE -> R.style.TiebaLite_Purple THEME_PINK -> R.style.TiebaLite_Pink THEME_RED -> R.style.TiebaLite_Red + THEME_BLUE_DARK -> R.style.TiebaLite_Dark_Blue THEME_GREY_DARK -> R.style.TiebaLite_Dark_Grey THEME_AMOLED_DARK -> R.style.TiebaLite_Dark_Amoled THEME_CUSTOM -> R.style.TiebaLite_Custom @@ -415,6 +417,7 @@ object ThemeUtil { THEME_PURPLE, THEME_PINK, THEME_RED, + THEME_BLUE_DARK, THEME_GREY_DARK, THEME_AMOLED_DARK -> theme.lowercase(Locale.getDefault()) diff --git a/app/src/main/res/drawable/bg_popup_dark_blue.xml b/app/src/main/res/drawable/bg_popup_dark_blue.xml new file mode 100644 index 00000000..a4ae19fe --- /dev/null +++ b/app/src/main/res/drawable/bg_popup_dark_blue.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index bc9de403..70584a50 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -36,6 +36,7 @@ pink red purple + blue_dark grey_dark amoled_dark @@ -46,16 +47,19 @@ 少女粉 新年红 星空紫 + 静谧蓝 深邃灰 - A屏黑 + 纯黑 + 静谧蓝 深邃灰 - A屏黑 + 纯黑 + blue_dark grey_dark amoled_dark diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c9f0a104..bbba9f8a 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -78,6 +78,7 @@ @color/black #FF512DA8 @color/tieba + @color/tieba @color/tieba @color/tieba @@ -88,6 +89,7 @@ @color/black #FF512DA8 @color/tieba + @color/tieba @color/tieba @color/tieba @@ -95,19 +97,24 @@ #FF5588D7 #FFF8F8F8 + #242F3D #323232 #1E1E1E #FF808080 - #FF808080 + #68737E + #FF808080 + #FF808080 #FFF8F8F8 #FF10171F - #FF212121 + #17212B + #FF202020 #FF1E1E1E @color/white #FF15202B + #17212B #202020 #000000 #00FFFFFF @@ -124,17 +131,20 @@ #8AFFFFFF #B3000000 #CCE6E7EE - #CCE6E7EE - #CCE6E7EE + #CCEEEEEE + #CCEEEEEE + #CCEEEEEE @color/theme_color_accent_white #FFFFFFFF #FF000000 @color/white + @color/white @color/white @color/white #F8F8F8 + #242F3D #2C2C2C #1E1E1E #10FFFFFF @@ -142,8 +152,17 @@ #BFBFBF #5C5C5C + #626C79 + #5C5C5C + #5C5C5C + @color/theme_color_accent_grey_dark + + + @color/theme_color_on_toolbar_bar_light + #FFF8F8F8 + #141F2A #242424 #282828 @@ -152,18 +171,21 @@ #FFFFFFFF #FF131D28 - #202020 + #17212B + #FF202020 #FF000000 #FFFFFFFF #FF131D28 - #FF212121 + #FF17212B + #FF202020 #FF000000 #FFFFFFFF #FF212121 @color/white #FF15202B + #1B2733 #FF303030 #FF171717 @@ -171,6 +193,7 @@ #43FFFFFF #4D000000 #FF415C68 + #5A6670 #FF808080 #FF808080 @@ -178,6 +201,7 @@ #15FFFFFF #2A000000 #FF1A2A39 + #242F3D #FF1E1E1E #FF1E1E1E @@ -185,6 +209,7 @@ #10FFFFFF #20000000 #FF131D27 + #202B37 #FF2A2A2A #FF101010 @@ -192,6 +217,7 @@ #FFFFFFFF #FF1C1C1C #FF1C2938 + #202B37 #FF252525 #FF1C1C1C @@ -199,6 +225,7 @@ #10FFFFFF #15000000 #FF10171D + #242F3D #FF1E1E1E #FF1E1E1E diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8452b72e..5d4e5b43 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -238,6 +238,14 @@ @color/default_color_toolbar_item_active + + + + @@ -615,6 +627,23 @@ #FF10171D + +