mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-14 18:26:11 -04:00
fix(widget): Sync window background with Compose theme in config activity
The widget configuration activity used enableEdgeToEdge() but never synced the Android window background with the Compose Material theme. When the system dark/light mode disagreed with the app's theme setting, text became invisible (dark on dark). Also extend the bottom bar Surface under the navigation bar to eliminate the white gap.
This commit is contained in:
@@ -7,8 +7,13 @@ import android.os.Bundle
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.viewModels
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.graphics.luminance
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.core.view.WindowCompat
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import eu.darken.capod.common.compose.waitForState
|
||||
@@ -53,6 +58,15 @@ class WidgetConfigurationActivity : Activity2() {
|
||||
setContent {
|
||||
val themeState by generalSettings.themeState.collectAsState(initial = generalSettings.currentThemeState)
|
||||
CapodTheme(state = themeState) {
|
||||
val backgroundColor = MaterialTheme.colorScheme.background
|
||||
val useDarkIcons = backgroundColor.luminance() > 0.5f
|
||||
SideEffect {
|
||||
window.decorView.setBackgroundColor(backgroundColor.toArgb())
|
||||
val insetsController = WindowCompat.getInsetsController(window, window.decorView)
|
||||
insetsController.isAppearanceLightStatusBars = useDarkIcons
|
||||
insetsController.isAppearanceLightNavigationBars = useDarkIcons
|
||||
}
|
||||
|
||||
val state by waitForState(vm.state)
|
||||
state?.let { currentState ->
|
||||
WidgetConfigurationScreen(
|
||||
|
||||
@@ -31,6 +31,8 @@ import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.WindowInsetsSides
|
||||
import androidx.compose.foundation.layout.only
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -113,7 +115,7 @@ fun WidgetConfigurationScreen(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.windowInsetsPadding(WindowInsets.systemBars),
|
||||
.windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal)),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -326,7 +328,7 @@ fun WidgetConfigurationScreen(
|
||||
|
||||
// Bottom bar
|
||||
Surface(tonalElevation = 3.dp) {
|
||||
Column {
|
||||
Column(modifier = Modifier.windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Bottom))) {
|
||||
if (!state.isPro) {
|
||||
Text(
|
||||
text = stringResource(R.string.common_feature_requires_pro_msg),
|
||||
|
||||
Reference in New Issue
Block a user