style(android): respect system theme and clamp overlays
This commit is contained in:
@@ -7,7 +7,6 @@ import android.view.WindowManager
|
|||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@@ -18,6 +17,7 @@ import androidx.lifecycle.Lifecycle
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import com.steipete.clawdis.node.ui.RootScreen
|
import com.steipete.clawdis.node.ui.RootScreen
|
||||||
|
import com.steipete.clawdis.node.ui.ClawdisTheme
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
@@ -44,7 +44,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
MaterialTheme {
|
ClawdisTheme {
|
||||||
Surface(modifier = Modifier) {
|
Surface(modifier = Modifier) {
|
||||||
RootScreen(viewModel = viewModel)
|
RootScreen(viewModel = viewModel)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.steipete.clawdis.node.ui
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.darkColorScheme
|
||||||
|
import androidx.compose.material3.dynamicDarkColorScheme
|
||||||
|
import androidx.compose.material3.dynamicLightColorScheme
|
||||||
|
import androidx.compose.material3.lightColorScheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ClawdisTheme(content: @Composable () -> Unit) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val isDark = isSystemInDarkTheme()
|
||||||
|
val colorScheme =
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
if (isDark) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||||
|
} else {
|
||||||
|
if (isDark) darkColorScheme() else lightColorScheme()
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialTheme(colorScheme = colorScheme, content = content)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun overlayContainerColor(): Color {
|
||||||
|
val scheme = MaterialTheme.colorScheme
|
||||||
|
val isDark = isSystemInDarkTheme()
|
||||||
|
val base = if (isDark) scheme.surfaceContainerLow else scheme.surfaceContainerHigh
|
||||||
|
// Light mode: background stays dark (canvas), so clamp overlays away from pure-white glare.
|
||||||
|
return if (isDark) base else base.copy(alpha = 0.88f)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun overlayIconColor(): Color {
|
||||||
|
return MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
}
|
||||||
|
|
||||||
@@ -131,8 +131,8 @@ private fun OverlayIconButton(
|
|||||||
modifier = Modifier.size(44.dp),
|
modifier = Modifier.size(44.dp),
|
||||||
colors =
|
colors =
|
||||||
IconButtonDefaults.filledTonalIconButtonColors(
|
IconButtonDefaults.filledTonalIconButtonColors(
|
||||||
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
|
containerColor = overlayContainerColor(),
|
||||||
contentColor = MaterialTheme.colorScheme.onSurface,
|
contentColor = overlayIconColor(),
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
icon()
|
icon()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ fun StatusPill(
|
|||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
shape = RoundedCornerShape(14.dp),
|
shape = RoundedCornerShape(14.dp),
|
||||||
color = MaterialTheme.colorScheme.surfaceContainerHigh,
|
color = overlayContainerColor(),
|
||||||
tonalElevation = 3.dp,
|
tonalElevation = 3.dp,
|
||||||
shadowElevation = 0.dp,
|
shadowElevation = 0.dp,
|
||||||
) {
|
) {
|
||||||
@@ -59,7 +59,7 @@ fun StatusPill(
|
|||||||
|
|
||||||
VerticalDivider(
|
VerticalDivider(
|
||||||
modifier = Modifier.height(14.dp).alpha(0.35f),
|
modifier = Modifier.height(14.dp).alpha(0.35f),
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
|
|
||||||
Icon(
|
Icon(
|
||||||
@@ -67,7 +67,7 @@ fun StatusPill(
|
|||||||
contentDescription = if (voiceEnabled) "Voice enabled" else "Voice disabled",
|
contentDescription = if (voiceEnabled) "Voice enabled" else "Voice disabled",
|
||||||
tint =
|
tint =
|
||||||
if (voiceEnabled) {
|
if (voiceEnabled) {
|
||||||
MaterialTheme.colorScheme.onSurface
|
overlayIconColor()
|
||||||
} else {
|
} else {
|
||||||
MaterialTheme.colorScheme.onSurfaceVariant
|
MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user