动态主题切换

This commit is contained in:
2024-10-26 19:05:52 +08:00
parent 01fb092e83
commit 2012668361
45 changed files with 244 additions and 281 deletions

View File

@@ -5,6 +5,9 @@ import android.content.Intent
import android.icu.util.Calendar
import android.icu.util.TimeZone
import android.util.Log
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.aiosman.riderpro.data.AccountProfile
import com.aiosman.riderpro.data.AccountService
import com.aiosman.riderpro.data.AccountServiceImpl
@@ -35,6 +38,7 @@ object AppState {
var UserId: Int? = null
var profile :AccountProfileEntity? = null
var darkMode = false
var appTheme by mutableStateOf<AppThemeData>(LightThemeColors())
suspend fun initWithAccount(scope: CoroutineScope, context: Context) {
val accountService: AccountService = AccountServiceImpl()
// 获取用户认证信息
@@ -116,6 +120,16 @@ object AppState {
}
}
fun switchTheme() {
darkMode = !darkMode
appTheme = if (darkMode) {
DarkThemeColors()
} else {
LightThemeColors()
}
AppStore.saveDarkMode(darkMode)
}
fun ReloadAppState(context: Context) {
// 重置动态列表页面
TimelineMomentViewModel.ResetModel()