feat: 引入 YaYaTheme 并应用到所有 Activity
新增 Theme.kt 提供 Android 12+ 动态颜色支持, 为全部 5 个 Activity 的 setContent 包裹 YaYaTheme。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2b0491d7d7
commit
f34e34e5ae
@ -4,18 +4,21 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import plus.rua.project.ui.AboutScreen
|
import plus.rua.project.ui.AboutScreen
|
||||||
|
import plus.rua.project.ui.theme.YaYaTheme
|
||||||
|
|
||||||
class AboutActivity : BaseActivity() {
|
class AboutActivity : BaseActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
AboutScreen(
|
YaYaTheme {
|
||||||
|
AboutScreen(
|
||||||
onBack = { finishWithSlideBack() },
|
onBack = { finishWithSlideBack() },
|
||||||
onNavigateToLicenses = {
|
onNavigateToLicenses = {
|
||||||
startActivityWithSlide(Intent(this, LicensesActivity::class.java))
|
startActivityWithSlide(Intent(this, LicensesActivity::class.java))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,15 +3,18 @@ package plus.rua.project
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import plus.rua.project.ui.DateCheckerScreen
|
import plus.rua.project.ui.DateCheckerScreen
|
||||||
|
import plus.rua.project.ui.theme.YaYaTheme
|
||||||
|
|
||||||
class DateCheckerActivity : BaseActivity() {
|
class DateCheckerActivity : BaseActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
DateCheckerScreen(
|
YaYaTheme {
|
||||||
|
DateCheckerScreen(
|
||||||
onBack = { finishWithSlideBack() }
|
onBack = { finishWithSlideBack() }
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,15 +3,18 @@ package plus.rua.project
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import plus.rua.project.ui.LicensesScreen
|
import plus.rua.project.ui.LicensesScreen
|
||||||
|
import plus.rua.project.ui.theme.YaYaTheme
|
||||||
|
|
||||||
class LicensesActivity : BaseActivity() {
|
class LicensesActivity : BaseActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
LicensesScreen(
|
YaYaTheme {
|
||||||
|
LicensesScreen(
|
||||||
onBack = { finishWithSlideBack() }
|
onBack = { finishWithSlideBack() }
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,15 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import plus.rua.project.ui.CalendarMonthView
|
import plus.rua.project.ui.CalendarMonthView
|
||||||
|
import plus.rua.project.ui.theme.YaYaTheme
|
||||||
|
|
||||||
class MainActivity : BaseActivity() {
|
class MainActivity : BaseActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
CalendarMonthView(
|
YaYaTheme {
|
||||||
|
CalendarMonthView(
|
||||||
onNavigateToAbout = {
|
onNavigateToAbout = {
|
||||||
startActivityWithSlide(Intent(this, AboutActivity::class.java))
|
startActivityWithSlide(Intent(this, AboutActivity::class.java))
|
||||||
},
|
},
|
||||||
@ -18,6 +20,7 @@ class MainActivity : BaseActivity() {
|
|||||||
startActivityWithSlide(Intent(this, ToolsActivity::class.java))
|
startActivityWithSlide(Intent(this, ToolsActivity::class.java))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,18 +4,21 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import plus.rua.project.ui.ToolsScreen
|
import plus.rua.project.ui.ToolsScreen
|
||||||
|
import plus.rua.project.ui.theme.YaYaTheme
|
||||||
|
|
||||||
class ToolsActivity : BaseActivity() {
|
class ToolsActivity : BaseActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
ToolsScreen(
|
YaYaTheme {
|
||||||
|
ToolsScreen(
|
||||||
onBack = { finishWithSlideBack() },
|
onBack = { finishWithSlideBack() },
|
||||||
onNavigateToDateChecker = {
|
onNavigateToDateChecker = {
|
||||||
startActivityWithSlide(Intent(this, DateCheckerActivity::class.java))
|
startActivityWithSlide(Intent(this, DateCheckerActivity::class.java))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
core/src/main/kotlin/plus/rua/project/ui/theme/Theme.kt
Normal file
32
core/src/main/kotlin/plus/rua/project/ui/theme/Theme.kt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package plus.rua.project.ui.theme
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.dynamicDarkColorScheme
|
||||||
|
import androidx.compose.material3.dynamicLightColorScheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
||||||
|
/**
|
||||||
|
* YaYa 应用主题,Android 12+ 使用系统动态颜色,低版本回退到 Material 3 默认方案。
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun YaYaTheme(
|
||||||
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
content: @Composable () -> Unit,
|
||||||
|
) {
|
||||||
|
val colorScheme = when {
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||||
|
val context = LocalContext.current
|
||||||
|
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> MaterialTheme.colorScheme
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialTheme(
|
||||||
|
colorScheme = colorScheme,
|
||||||
|
content = content,
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user