dark mode-v12
This commit is contained in:
parent
bbcfc6440d
commit
98b78c598a
1 changed files with 34 additions and 28 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package com.example.login_v3.home.setting.setting_detail_page.detail_UI
|
package com.example.login_v3.home.setting.setting_detail_page.detail_UI
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
|
@ -26,39 +27,44 @@ fun setting_theme_page(
|
||||||
// 直接讀取,不需要 .value
|
// 直接讀取,不需要 .value
|
||||||
val selectedTheme by viewModel.currentTheme.collectAsState()
|
val selectedTheme by viewModel.currentTheme.collectAsState()
|
||||||
|
|
||||||
Column(modifier = Modifier.padding(16.dp)) {
|
Box(
|
||||||
Text(
|
modifier = Modifier
|
||||||
text = "主題設定",
|
.padding(10.dp)
|
||||||
style = MaterialTheme.typography.headlineMedium,
|
) {
|
||||||
color = MaterialTheme.colorScheme.primary
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
)
|
Text(
|
||||||
|
text = "主題設定",
|
||||||
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
|
color = MaterialTheme.colorScheme.primary
|
||||||
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
||||||
// 遍歷所有 Enum 選項
|
// 遍歷所有 Enum 選項
|
||||||
AppTheme.entries.forEach { theme ->
|
AppTheme.entries.forEach { theme ->
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.selectable(
|
.selectable(
|
||||||
|
selected = (theme == selectedTheme),
|
||||||
|
onClick = { viewModel.updateTheme(theme) }
|
||||||
|
)
|
||||||
|
.padding(8.dp)
|
||||||
|
) {
|
||||||
|
RadioButton(
|
||||||
selected = (theme == selectedTheme),
|
selected = (theme == selectedTheme),
|
||||||
onClick = { viewModel.updateTheme(theme) }
|
onClick = { viewModel.updateTheme(theme) }
|
||||||
)
|
)
|
||||||
.padding(8.dp)
|
Text(
|
||||||
) {
|
text = when(theme) {
|
||||||
RadioButton(
|
AppTheme.SYSTEM -> "follow"
|
||||||
selected = (theme == selectedTheme),
|
AppTheme.LIGHT -> "light"
|
||||||
onClick = { viewModel.updateTheme(theme) }
|
AppTheme.DARK -> "dark"
|
||||||
)
|
},
|
||||||
Text(
|
modifier = Modifier.padding(start = 8.dp)
|
||||||
text = when(theme) {
|
)
|
||||||
AppTheme.SYSTEM -> "follow"
|
}
|
||||||
AppTheme.LIGHT -> "light"
|
|
||||||
AppTheme.DARK -> "dark"
|
|
||||||
},
|
|
||||||
modifier = Modifier.padding(start = 8.dp)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue