dark mode-v7
This commit is contained in:
parent
acd8f188e2
commit
42872e9ad3
3 changed files with 7 additions and 6 deletions
|
|
@ -24,9 +24,7 @@ class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
installSplashScreen()
|
installSplashScreen()
|
||||||
setContent {
|
setContent {
|
||||||
val currentAppTheme = themeViewModel.currentTheme.value
|
Login_V3Theme(appTheme = themeViewModel.currentTheme) {
|
||||||
|
|
||||||
Login_V3Theme(appTheme = currentAppTheme) {
|
|
||||||
Technologia()
|
Technologia()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@ import com.example.login_v3.ui.theme.AppTheme
|
||||||
fun setting_theme_page(
|
fun setting_theme_page(
|
||||||
viewModel: Theme_ViewModel
|
viewModel: Theme_ViewModel
|
||||||
){
|
){
|
||||||
val selectedTheme = viewModel.currentTheme.value
|
// 直接讀取,不需要 .value
|
||||||
|
val selectedTheme = viewModel.currentTheme
|
||||||
|
|
||||||
Column(modifier = Modifier.padding(16.dp)) {
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
Text(
|
Text(
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
package com.example.login_v3.home.setting.setting_detail_page.viewmodel
|
package com.example.login_v3.home.setting.setting_detail_page.viewmodel
|
||||||
|
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import com.example.login_v3.ui.theme.AppTheme
|
import com.example.login_v3.ui.theme.AppTheme
|
||||||
|
|
||||||
class Theme_ViewModel : ViewModel() {
|
class Theme_ViewModel : ViewModel() {
|
||||||
var currentTheme = mutableStateOf(AppTheme.SYSTEM)
|
var currentTheme by mutableStateOf(AppTheme.DARK)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun updateTheme(newTheme: AppTheme) {
|
fun updateTheme(newTheme: AppTheme) {
|
||||||
currentTheme.value = newTheme
|
currentTheme = newTheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue