feat: 支持系统深色主题切换
新增 values/values-night 主题资源 Theme.YaYa,AndroidManifest 切换为该主题; Compose 端根据 isSystemInDarkTheme 切换 light/dark ColorScheme。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e6898df400
commit
fae6e3eb72
@ -7,7 +7,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@android:style/Theme.Material.Light.NoActionBar">
|
||||
android:theme="@style/Theme.YaYa">
|
||||
<activity
|
||||
android:exported="true"
|
||||
android:name=".MainActivity">
|
||||
|
||||
4
androidApp/src/main/res/values-night/themes.xml
Normal file
4
androidApp/src/main/res/values-night/themes.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.YaYa" parent="@android:style/Theme.Material.NoActionBar" />
|
||||
</resources>
|
||||
4
androidApp/src/main/res/values/themes.xml
Normal file
4
androidApp/src/main/res/values/themes.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.YaYa" parent="@android:style/Theme.Material.Light.NoActionBar" />
|
||||
</resources>
|
||||
@ -1,18 +1,22 @@
|
||||
package plus.rua.project
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import plus.rua.project.ui.CalendarMonthView
|
||||
|
||||
/**
|
||||
* 应用入口 Composable,包裹 CalendarMonthView 并提供 MaterialTheme。
|
||||
* 应用入口 Composable,根据系统主题切换明暗 ColorScheme 并包裹 CalendarMonthView。
|
||||
*/
|
||||
@Composable
|
||||
@Preview(name = "Calendar App")
|
||||
fun App() {
|
||||
MaterialTheme {
|
||||
val colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
|
||||
MaterialTheme(colorScheme = colorScheme) {
|
||||
CalendarMonthView(modifier = Modifier)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user