commit 2d8e96b913537a12a358358d56a1ec42299c4b63
parent efece2bac591db25de551354185edcd748f75c15
Author: Gabriel Luong <gabriel.luong@gmail.com>
Date: Thu, 4 Dec 2025 18:13:28 +0000
Bug 1993368 - Part 23: Migrate SnackbarHostPreview to use M3 color tokens r=android-reviewers,007
- Fixes the Snackbar colors by correcting the inverseSurface light theme color:
https://www.figma.com/design/MjufE1X5fvkxZ0YneX4kRd/Android-Library--2025-?node-id=64745-6703&m=dev
Differential Revision: https://phabricator.services.mozilla.com/D273051
Diffstat:
2 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/mobile/android/android-components/components/compose/base/src/main/java/mozilla/components/compose/base/theme/AcornColors.kt b/mobile/android/android-components/components/compose/base/src/main/java/mozilla/components/compose/base/theme/AcornColors.kt
@@ -1024,7 +1024,7 @@ fun acornLightColorScheme(): ColorScheme = lightColorPalette.toM3ColorScheme(
secondaryContainer = Color(0xFFE6E0F5),
tertiaryContainer = PhotonColors.Pink05,
surface = PhotonColors.LightGrey10,
- inverseSurface = PhotonColors.DarkGrey05,
+ inverseSurface = PhotonColors.DarkGrey60,
errorContainer = PhotonColors.Red05,
outline = PhotonColors.LightGrey90,
outlineVariant = PhotonColors.LightGrey30,
diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/snackbar/Snackbar.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/snackbar/Snackbar.kt
@@ -7,7 +7,6 @@ package org.mozilla.fenix.compose.snackbar
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
-import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
@@ -17,6 +16,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
+import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -217,51 +217,50 @@ class Snackbar private constructor(
@FlexibleWindowLightDarkPreview
@Composable
-@Suppress("LongMethod")
private fun SnackbarHostPreview() {
val snackbarHostState = remember { SnackbarHostState() }
var snackbarClicks by remember { mutableIntStateOf(0) }
val scope = rememberCoroutineScope()
FirefoxTheme {
- Box(
- modifier = Modifier
- .fillMaxSize()
- .background(color = FirefoxTheme.colors.layer1)
- .padding(all = 16.dp),
- ) {
- Column {
- FilledButton(
- text = "Show snackbar",
- modifier = Modifier.fillMaxWidth(),
- ) {
- scope.launch {
- snackbarHostState.displaySnackbar(
- visuals = SnackbarVisuals(
- message = "Snackbar",
- subMessage = "SubMessage",
- actionLabel = "click me",
- ),
- onActionPerformed = { snackbarClicks++ },
- )
+ Surface {
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(all = 16.dp),
+ ) {
+ Column {
+ FilledButton(
+ text = "Show snackbar",
+ modifier = Modifier.fillMaxWidth(),
+ ) {
+ scope.launch {
+ snackbarHostState.displaySnackbar(
+ visuals = SnackbarVisuals(
+ message = "Snackbar",
+ subMessage = "SubMessage",
+ actionLabel = "click me",
+ ),
+ onActionPerformed = { snackbarClicks++ },
+ )
+ }
}
- }
- Spacer(modifier = Modifier.height(16.dp))
+ Spacer(modifier = Modifier.height(16.dp))
- Text(
- text = "Snackbar action clicks: $snackbarClicks",
- color = FirefoxTheme.colors.textPrimary,
- )
+ Text(
+ text = "Snackbar action clicks: $snackbarClicks",
+ )
- Spacer(modifier = Modifier.height(16.dp))
- }
+ Spacer(modifier = Modifier.height(16.dp))
+ }
- SnackbarHost(
- hostState = snackbarHostState,
- modifier = Modifier.align(Alignment.BottomCenter),
- ) {
- Snackbar(snackbarData = it)
+ SnackbarHost(
+ hostState = snackbarHostState,
+ modifier = Modifier.align(Alignment.BottomCenter),
+ ) {
+ Snackbar(snackbarData = it)
+ }
}
}
}