Skip to content

Commit

Permalink
try fix dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Voine committed May 12, 2023
1 parent e7f8f2e commit b691cb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.chatwaifu.mobile.ui.theme.ChatWaifu_MobileTheme
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.chatwaifu.mobile.ui.theme.globalDarkTheme

class SettingFragment : Fragment() {

Expand All @@ -34,6 +35,7 @@ class SettingFragment : Fragment() {
var currentDarkMode by rememberSaveable {
mutableStateOf(initData.darkModeSwitch)
}
globalDarkTheme = currentDarkMode
ChatWaifu_MobileTheme(darkTheme = currentDarkMode) {
SettingContentScaffold(
settingUIState = SettingUIState(initData),
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/com/chatwaifu/mobile/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

var globalDarkTheme: Boolean = false

@Composable
fun ChatWaifu_MobileTheme(
darkTheme: Boolean = false,
content: @Composable () -> Unit,
) {
val colors = if (darkTheme) {
var showTheme = darkTheme
if (darkTheme != globalDarkTheme) {
showTheme = globalDarkTheme
}
val colors = if (showTheme) {
ChatWaifuDarkTheme
} else {
ChatWaifuLightTheme
Expand Down

0 comments on commit b691cb0

Please sign in to comment.