dark mode-v5
This commit is contained in:
parent
de39e1dc6d
commit
33412637dc
2 changed files with 12 additions and 4 deletions
|
|
@ -4,21 +4,29 @@ import android.os.Bundle
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.activity.viewModels
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import com.example.login_v3.auth.HealthCheckScreen
|
import com.example.login_v3.auth.HealthCheckScreen
|
||||||
|
import com.example.login_v3.home.setting.setting_detail_page.viewmodel.Theme_ViewModel
|
||||||
import com.example.login_v3.ui.theme.AppTheme
|
import com.example.login_v3.ui.theme.AppTheme
|
||||||
import com.example.login_v3.ui.theme.Login_V3Theme
|
import com.example.login_v3.ui.theme.Login_V3Theme
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
|
//color mode viewmodel
|
||||||
|
private val themeViewModel by viewModels<Theme_ViewModel>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
installSplashScreen()
|
installSplashScreen()
|
||||||
setContent {
|
setContent {
|
||||||
Login_V3Theme(appTheme = AppTheme.DARK) {
|
val currentAppTheme = themeViewModel.currentTheme.value
|
||||||
|
|
||||||
|
Login_V3Theme(appTheme = currentAppTheme) {
|
||||||
Technologia()
|
Technologia()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,9 @@ fun setting_theme_page(
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = when(theme) {
|
text = when(theme) {
|
||||||
AppTheme.SYSTEM -> "跟隨系統設定"
|
AppTheme.SYSTEM -> "follow"
|
||||||
AppTheme.LIGHT -> "淺色模式"
|
AppTheme.LIGHT -> "dark"
|
||||||
AppTheme.DARK -> "深色模式"
|
AppTheme.DARK -> "light"
|
||||||
},
|
},
|
||||||
modifier = Modifier.padding(start = 8.dp)
|
modifier = Modifier.padding(start = 8.dp)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue