refactor(overview): Thread isPro/onUpgrade into pod cards (groundwork)

Groundwork for a future pro indicator on the overview card's ANC mode selector. Adds isPro + onUpgrade parameters to OverviewScreen, PodDeviceCard, DualPodsCard, SinglePodsCard (currently unused inside the cards, defaults keep existing previews working). Wraps AncModeSelector in a Box as a scaffold for an overlay. Bumps surfaceContainerLowDark to match surfaceContainerDark in all three theme palettes (Amber/Blue/Green) across standard/medium/high contrast. No user-facing change yet.
This commit is contained in:
darken
2026-04-11 15:01:47 +02:00
committed by Matthias Urhahn
parent 4174072dbf
commit 09c0692205
7 changed files with 58 additions and 40 deletions
@@ -72,7 +72,7 @@ object CapodColorsAmber {
val surfaceDimDark = Color(0xFF181210)
val surfaceBrightDark = Color(0xFF3F3835)
val surfaceContainerLowestDark = Color(0xFF120D0B)
val surfaceContainerLowDark = Color(0xFF201A18)
val surfaceContainerLowDark = Color(0xFF251E1C)
val surfaceContainerDark = Color(0xFF251E1C)
val surfaceContainerHighDark = Color(0xFF2F2826)
val surfaceContainerHighestDark = Color(0xFF3B3331)
@@ -146,7 +146,7 @@ object CapodColorsAmber {
val surfaceDimDarkMediumContrast = Color(0xFF181210)
val surfaceBrightDarkMediumContrast = Color(0xFF3F3835)
val surfaceContainerLowestDarkMediumContrast = Color(0xFF120D0B)
val surfaceContainerLowDarkMediumContrast = Color(0xFF201A18)
val surfaceContainerLowDarkMediumContrast = Color(0xFF251E1C)
val surfaceContainerDarkMediumContrast = Color(0xFF251E1C)
val surfaceContainerHighDarkMediumContrast = Color(0xFF2F2826)
val surfaceContainerHighestDarkMediumContrast = Color(0xFF3B3331)
@@ -220,7 +220,7 @@ object CapodColorsAmber {
val surfaceDimDarkHighContrast = Color(0xFF181210)
val surfaceBrightDarkHighContrast = Color(0xFF3F3835)
val surfaceContainerLowestDarkHighContrast = Color(0xFF120D0B)
val surfaceContainerLowDarkHighContrast = Color(0xFF201A18)
val surfaceContainerLowDarkHighContrast = Color(0xFF251E1C)
val surfaceContainerDarkHighContrast = Color(0xFF251E1C)
val surfaceContainerHighDarkHighContrast = Color(0xFF2F2826)
val surfaceContainerHighestDarkHighContrast = Color(0xFF3B3331)
@@ -72,7 +72,7 @@ object CapodColorsBlue {
val surfaceDimDark = Color(0xFF131316)
val surfaceBrightDark = Color(0xFF39393C)
val surfaceContainerLowestDark = Color(0xFF0D0E11)
val surfaceContainerLowDark = Color(0xFF1B1B1F)
val surfaceContainerLowDark = Color(0xFF1F1F23)
val surfaceContainerDark = Color(0xFF1F1F23)
val surfaceContainerHighDark = Color(0xFF292A2D)
val surfaceContainerHighestDark = Color(0xFF343438)
@@ -146,7 +146,7 @@ object CapodColorsBlue {
val surfaceDimDarkMediumContrast = Color(0xFF131316)
val surfaceBrightDarkMediumContrast = Color(0xFF39393C)
val surfaceContainerLowestDarkMediumContrast = Color(0xFF0D0E11)
val surfaceContainerLowDarkMediumContrast = Color(0xFF1B1B1F)
val surfaceContainerLowDarkMediumContrast = Color(0xFF1F1F23)
val surfaceContainerDarkMediumContrast = Color(0xFF1F1F23)
val surfaceContainerHighDarkMediumContrast = Color(0xFF292A2D)
val surfaceContainerHighestDarkMediumContrast = Color(0xFF343438)
@@ -220,7 +220,7 @@ object CapodColorsBlue {
val surfaceDimDarkHighContrast = Color(0xFF131316)
val surfaceBrightDarkHighContrast = Color(0xFF39393C)
val surfaceContainerLowestDarkHighContrast = Color(0xFF0D0E11)
val surfaceContainerLowDarkHighContrast = Color(0xFF1B1B1F)
val surfaceContainerLowDarkHighContrast = Color(0xFF1F1F23)
val surfaceContainerDarkHighContrast = Color(0xFF1F1F23)
val surfaceContainerHighDarkHighContrast = Color(0xFF292A2D)
val surfaceContainerHighestDarkHighContrast = Color(0xFF343438)
@@ -72,7 +72,7 @@ object CapodColorsGreen {
val surfaceDimDark = Color(0xFF111411)
val surfaceBrightDark = Color(0xFF373A37)
val surfaceContainerLowestDark = Color(0xFF0C0F0C)
val surfaceContainerLowDark = Color(0xFF191C19)
val surfaceContainerLowDark = Color(0xFF1D201D)
val surfaceContainerDark = Color(0xFF1D201D)
val surfaceContainerHighDark = Color(0xFF282B28)
val surfaceContainerHighestDark = Color(0xFF333532)
@@ -146,7 +146,7 @@ object CapodColorsGreen {
val surfaceDimDarkMediumContrast = Color(0xFF111411)
val surfaceBrightDarkMediumContrast = Color(0xFF373A37)
val surfaceContainerLowestDarkMediumContrast = Color(0xFF0C0F0C)
val surfaceContainerLowDarkMediumContrast = Color(0xFF191C19)
val surfaceContainerLowDarkMediumContrast = Color(0xFF1D201D)
val surfaceContainerDarkMediumContrast = Color(0xFF1D201D)
val surfaceContainerHighDarkMediumContrast = Color(0xFF282B28)
val surfaceContainerHighestDarkMediumContrast = Color(0xFF333532)
@@ -220,7 +220,7 @@ object CapodColorsGreen {
val surfaceDimDarkHighContrast = Color(0xFF111411)
val surfaceBrightDarkHighContrast = Color(0xFF373A37)
val surfaceContainerLowestDarkHighContrast = Color(0xFF0C0F0C)
val surfaceContainerLowDarkHighContrast = Color(0xFF191C19)
val surfaceContainerLowDarkHighContrast = Color(0xFF1D201D)
val surfaceContainerDarkHighContrast = Color(0xFF1D201D)
val surfaceContainerHighDarkHighContrast = Color(0xFF282B28)
val surfaceContainerHighestDarkHighContrast = Color(0xFF333532)
@@ -230,9 +230,11 @@ fun OverviewScreen(
) { device ->
PodDeviceCard(
device = device,
isPro = state.upgradeInfo.isPro,
showDebug = state.isDebugMode,
now = state.now,
onAncModeChange = { mode -> onAncModeChange(device, mode) },
onUpgrade = onUpgrade,
onDeviceSettings = { onDeviceSettings(device) },
)
}
@@ -272,9 +274,11 @@ fun OverviewScreen(
) { device ->
PodDeviceCard(
device = device,
isPro = state.upgradeInfo.isPro,
showDebug = state.isDebugMode,
now = state.now,
onAncModeChange = { mode -> onAncModeChange(device, mode) },
onUpgrade = onUpgrade,
onDeviceSettings = { onDeviceSettings(device) },
)
}
@@ -288,20 +292,24 @@ fun OverviewScreen(
@Composable
private fun PodDeviceCard(
device: PodDevice,
isPro: Boolean,
showDebug: Boolean,
now: Instant,
onAncModeChange: (AapSetting.AncMode.Value) -> Unit,
onUpgrade: () -> Unit,
onDeviceSettings: (() -> Unit)? = null,
) {
when {
device.hasDualPods -> DualPodsCard(
device = device, showDebug = showDebug, now = now,
device = device, isPro = isPro, showDebug = showDebug, now = now,
onAncModeChange = onAncModeChange,
onUpgrade = onUpgrade,
onDeviceSettings = onDeviceSettings,
)
device.model != PodModel.UNKNOWN -> SinglePodsCard(
device = device, showDebug = showDebug, now = now,
device = device, isPro = isPro, showDebug = showDebug, now = now,
onAncModeChange = onAncModeChange,
onUpgrade = onUpgrade,
onDeviceSettings = onDeviceSettings,
)
else -> UnknownPodDeviceCard(device = device, showDebug = showDebug)
@@ -59,9 +59,11 @@ import java.time.Instant
@Composable
fun DualPodsCard(
device: PodDevice,
isPro: Boolean = true,
showDebug: Boolean,
now: Instant,
onAncModeChange: ((AapSetting.AncMode.Value) -> Unit)? = null,
onUpgrade: (() -> Unit)? = null,
onDeviceSettings: (() -> Unit)? = null,
) {
val context = LocalContext.current
@@ -403,6 +405,7 @@ private fun DualPodsCardFullPreview() = PreviewWrapper {
device = MockPodDataProvider.dualPodMonitoredWithAap(),
showDebug = false,
now = Instant.now(),
isPro = false,
onDeviceSettings = {},
)
}
@@ -7,6 +7,7 @@ import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@@ -15,6 +16,7 @@ import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
@@ -30,6 +32,7 @@ import androidx.compose.material.icons.twotone.KeyboardVoice
import androidx.compose.material.icons.twotone.LinkOff
import androidx.compose.material.icons.twotone.Lock
import androidx.compose.material.icons.twotone.SettingsInputAntenna
import androidx.compose.material.icons.twotone.Stars
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SegmentedButton
@@ -318,42 +321,44 @@ fun DebugSection(
@Composable
fun AncModeSelector(
modifier: Modifier = Modifier,
currentMode: AapSetting.AncMode.Value,
supportedModes: List<AapSetting.AncMode.Value>,
onModeSelected: (AapSetting.AncMode.Value) -> Unit,
pendingMode: AapSetting.AncMode.Value? = null,
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
val displayMode = pendingMode ?: currentMode
SingleChoiceSegmentedButtonRow(modifier = modifier.fillMaxWidth()) {
supportedModes.forEachIndexed { index, mode ->
SegmentedButton(
selected = mode == displayMode,
onClick = { onModeSelected(mode) },
enabled = enabled,
shape = SegmentedButtonDefaults.itemShape(index, supportedModes.size),
colors = if (pendingMode != null && mode == displayMode) {
SegmentedButtonDefaults.colors(
activeContainerColor = MaterialTheme.colorScheme.secondaryContainer,
activeContentColor = MaterialTheme.colorScheme.onSecondaryContainer,
)
} else {
SegmentedButtonDefaults.colors()
},
label = {
Text(
text = when (mode) {
AapSetting.AncMode.Value.OFF -> stringResource(R.string.anc_mode_off)
AapSetting.AncMode.Value.ON -> stringResource(R.string.anc_mode_on)
AapSetting.AncMode.Value.TRANSPARENCY -> stringResource(R.string.anc_mode_transparency)
AapSetting.AncMode.Value.ADAPTIVE -> stringResource(R.string.anc_mode_adaptive)
},
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
},
)
Box(modifier = modifier.fillMaxWidth()) {
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
supportedModes.forEachIndexed { index, mode ->
SegmentedButton(
selected = mode == displayMode,
onClick = { onModeSelected(mode) },
enabled = enabled,
shape = SegmentedButtonDefaults.itemShape(index, supportedModes.size),
colors = if (pendingMode != null && mode == displayMode) {
SegmentedButtonDefaults.colors(
activeContainerColor = MaterialTheme.colorScheme.secondaryContainer,
activeContentColor = MaterialTheme.colorScheme.onSecondaryContainer,
)
} else {
SegmentedButtonDefaults.colors()
},
label = {
Text(
text = when (mode) {
AapSetting.AncMode.Value.OFF -> stringResource(R.string.anc_mode_off)
AapSetting.AncMode.Value.ON -> stringResource(R.string.anc_mode_on)
AapSetting.AncMode.Value.TRANSPARENCY -> stringResource(R.string.anc_mode_transparency)
AapSetting.AncMode.Value.ADAPTIVE -> stringResource(R.string.anc_mode_adaptive)
},
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
},
)
}
}
}
}
@@ -55,9 +55,11 @@ import java.time.Instant
@Composable
fun SinglePodsCard(
device: PodDevice,
isPro: Boolean = true,
showDebug: Boolean,
now: Instant,
onAncModeChange: ((AapSetting.AncMode.Value) -> Unit)? = null,
onUpgrade: (() -> Unit)? = null,
onDeviceSettings: (() -> Unit)? = null,
) {
val context = LocalContext.current