dark mode-v11
This commit is contained in:
parent
36233da198
commit
bbcfc6440d
2 changed files with 9 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
package com.example.login_v3.home.setting
|
package com.example.login_v3.home.setting
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.LocalActivity
|
||||||
import androidx.compose.animation.AnimatedVisibilityScope
|
import androidx.compose.animation.AnimatedVisibilityScope
|
||||||
import androidx.compose.animation.SharedTransitionScope
|
import androidx.compose.animation.SharedTransitionScope
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
|
|
@ -27,9 +29,11 @@ import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
|
|
@ -121,8 +125,9 @@ fun SharedTransitionScope.setting_detail_Screen(
|
||||||
|
|
||||||
composable("setting_Profile") { setting_profile_page() }
|
composable("setting_Profile") { setting_profile_page() }
|
||||||
composable("setting_Theme") {
|
composable("setting_Theme") {
|
||||||
val themeViewModel: Theme_ViewModel = viewModel()
|
val activity = LocalActivity.current as ComponentActivity
|
||||||
setting_theme_page(viewModel = themeViewModel)
|
val vm: Theme_ViewModel = hiltViewModel(viewModelStoreOwner = activity)
|
||||||
|
setting_theme_page(viewModel = vm)
|
||||||
}
|
}
|
||||||
composable("setting_Devices") { setting_devices_page() }
|
composable("setting_Devices") { setting_devices_page() }
|
||||||
composable("setting_Subscription") { setting_subscription_page() }
|
composable("setting_Subscription") { setting_subscription_page() }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.example.login_v3.home.setting.setting_detail_page.viewmodel
|
package com.example.login_v3.home.setting.setting_detail_page.viewmodel
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
|
@ -14,6 +15,7 @@ class Theme_ViewModel : ViewModel() {
|
||||||
val currentTheme: StateFlow<AppTheme> = _currentTheme.asStateFlow()
|
val currentTheme: StateFlow<AppTheme> = _currentTheme.asStateFlow()
|
||||||
|
|
||||||
fun updateTheme(newTheme: AppTheme) {
|
fun updateTheme(newTheme: AppTheme) {
|
||||||
|
Log.d("ThemeDebug", "ViewModel 更新主題為: $newTheme")
|
||||||
_currentTheme.value = newTheme
|
_currentTheme.value = newTheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue