update color scheme

This commit is contained in:
2026-09-15 14:52:55 +03:00
parent dbbfc6984c
commit e5ed4d6eb5
4 changed files with 9 additions and 21 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ plugins {
alias(libs.plugins.convention.serialization) alias(libs.plugins.convention.serialization)
} }
val appVersion = "1.0.2" val appVersion = "1.0.3"
android { android {
buildFeatures { buildConfig = true } buildFeatures { buildConfig = true }
@@ -1,11 +1,8 @@
package ru.shadowsparky.gigawear.presentation package ru.shadowsparky.gigawear.presentation
import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.runtime.CompositionLocalProvider
import com.arkivanov.decompose.retainedComponent import com.arkivanov.decompose.retainedComponent
import org.koin.android.ext.android.inject import org.koin.android.ext.android.inject
import ru.shadowsparky.gigawear.presentation.auth.AuthScreen import ru.shadowsparky.gigawear.presentation.auth.AuthScreen
@@ -13,8 +10,6 @@ import ru.shadowsparky.gigawear.presentation.chat.ChatScreen
import ru.shadowsparky.gigawear.presentation.nav.Child import ru.shadowsparky.gigawear.presentation.nav.Child
import ru.shadowsparky.gigawear.presentation.routing.RoutingScreen import ru.shadowsparky.gigawear.presentation.routing.RoutingScreen
import ru.shadowsparky.ui.nav.Nav import ru.shadowsparky.ui.nav.Nav
import ru.shadowsparky.ui.theme.LocalColorSchemeProvider
import ru.shadowsparky.ui.theme.darkScheme
class MainActivity : ComponentActivity() { class MainActivity : ComponentActivity() {
private val rootFactory by inject<RootComponentFactory>() private val rootFactory by inject<RootComponentFactory>()
@@ -23,18 +18,11 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val root = retainedComponent { rootFactory.create(it) } val root = retainedComponent { rootFactory.create(it) }
setContent { setContent {
val scheme = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { Nav(root) { child, _ ->
dynamicDarkColorScheme(this) when (child) {
} else { is Child.MainChild -> ChatScreen(child.component)
darkScheme is Child.AuthChild -> AuthScreen(child.component)
} is Child.RoutingChild -> RoutingScreen(child.component)
CompositionLocalProvider(LocalColorSchemeProvider provides scheme) {
Nav(root) { child, _ ->
when (child) {
is Child.MainChild -> ChatScreen(child.component)
is Child.AuthChild -> AuthScreen(child.component)
is Child.RoutingChild -> RoutingScreen(child.component)
}
} }
} }
} }
@@ -17,7 +17,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties import androidx.compose.ui.window.DialogProperties
import ru.shadowsparky.ui.theme.getColorScheme import ru.shadowsparky.ui.theme.getColorScheme
import ru.shadowsparky.ui.util.isWear
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class) @OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
@Composable @Composable
@@ -45,7 +44,7 @@ fun AlertContent(
} }
} }
MaterialExpressiveTheme(getColorScheme()) { MaterialExpressiveTheme(getColorScheme()) {
if (isTv() || isWear()) { if (isTv()) {
BasicAlertDialog( BasicAlertDialog(
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
modifier = modifier, modifier = modifier,
@@ -6,6 +6,7 @@ import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.compositionLocalOf import androidx.compose.runtime.compositionLocalOf
import ru.shadowsparky.ui.util.isWear
val lightScheme = lightColorScheme( val lightScheme = lightColorScheme(
primary = primaryLight, primary = primaryLight,
@@ -88,7 +89,7 @@ val LocalColorSchemeProvider = compositionLocalOf<ColorScheme?> { null }
@Composable @Composable
fun getColorScheme(): ColorScheme { fun getColorScheme(): ColorScheme {
return LocalColorSchemeProvider.current ?: when { return LocalColorSchemeProvider.current ?: when {
isSystemInDarkTheme() -> darkDynamicScheme() ?: darkScheme isSystemInDarkTheme() || isWear() -> darkDynamicScheme() ?: darkScheme
else -> lightDynamicScheme() ?: lightScheme else -> lightDynamicScheme() ?: lightScheme
} }
} }