From 119bb492e6f88c5a90fec1a3ca353eaa28f5f299 Mon Sep 17 00:00:00 2001 From: Meghan Date: Wed, 6 May 2026 16:30:37 -0400 Subject: [PATCH 1/6] Test styles skill --- Jetsnack/app/build.gradle.kts | 1 + .../example/jetsnack/ui/components/Button.kt | 39 ++++--------- .../example/jetsnack/ui/home/FilterScreen.kt | 3 +- .../jetsnack/ui/theme/ComponentStyles.kt | 58 +++++++++++++++++++ .../com/example/jetsnack/ui/theme/Theme.kt | 22 +++++-- Jetsnack/gradle/libs.versions.toml | 2 +- 6 files changed, 90 insertions(+), 35 deletions(-) create mode 100644 Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/ComponentStyles.kt diff --git a/Jetsnack/app/build.gradle.kts b/Jetsnack/app/build.gradle.kts index 0fca21037b..2d1d6a086d 100644 --- a/Jetsnack/app/build.gradle.kts +++ b/Jetsnack/app/build.gradle.kts @@ -86,6 +86,7 @@ android { kotlin { compilerOptions { jvmTarget = JvmTarget.fromTarget("17") + freeCompilerArgs.add("-opt-in=androidx.compose.foundation.style.ExperimentalFoundationStyleApi") } } compileOptions { diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt index 794bd3f1d7..16cb5cdac3 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt @@ -17,9 +17,10 @@ package com.example.jetsnack.ui.components import android.content.res.Configuration.UI_MODE_NIGHT_YES -import androidx.compose.foundation.BorderStroke + import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.clickable import androidx.compose.foundation.indication import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement @@ -28,7 +29,9 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.style.MutableStyleState +import androidx.compose.foundation.style.Style +import androidx.compose.foundation.style.styleable import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ProvideTextStyle @@ -38,11 +41,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Brush -import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.RectangleShape -import androidx.compose.ui.graphics.Shape import androidx.compose.ui.semantics.Role import androidx.compose.ui.tooling.preview.Preview import com.example.jetsnack.ui.theme.JetsnackTheme @@ -51,36 +50,24 @@ import com.example.jetsnack.ui.theme.JetsnackTheme fun JetsnackButton( onClick: () -> Unit, modifier: Modifier = Modifier, + style: Style = Style, enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, - shape: Shape = ButtonShape, - border: BorderStroke? = null, - backgroundGradient: List = JetsnackTheme.colors.interactivePrimary, - disabledBackgroundGradient: List = JetsnackTheme.colors.interactiveSecondary, - contentColor: Color = JetsnackTheme.colors.textInteractive, - disabledContentColor: Color = JetsnackTheme.colors.textHelp, contentPadding: PaddingValues = ButtonDefaults.ContentPadding, content: @Composable RowScope.() -> Unit, ) { - JetsnackSurface( - shape = shape, - color = Color.Transparent, - contentColor = if (enabled) contentColor else disabledContentColor, - border = border, + val styleState = remember(interactionSource) { MutableStyleState(interactionSource) } + styleState.isEnabled = enabled + Row( modifier = modifier - .clip(shape) - .background( - Brush.horizontalGradient( - colors = if (enabled) backgroundGradient else disabledBackgroundGradient, - ), - ) .clickable( onClick = onClick, enabled = enabled, role = Role.Button, interactionSource = interactionSource, indication = null, - ), + ) + .styleable(styleState, JetsnackTheme.styles.buttonStyle, style), ) { ProvideTextStyle( value = MaterialTheme.typography.labelLarge, @@ -101,8 +88,6 @@ fun JetsnackButton( } } -private val ButtonShape = RoundedCornerShape(percent = 50) - @Preview("default", "round") @Preview("dark theme", "round", uiMode = UI_MODE_NIGHT_YES) @Preview("large font", "round", fontScale = 2f) @@ -122,7 +107,7 @@ private fun ButtonPreview() { private fun RectangleButtonPreview() { JetsnackTheme { JetsnackButton( - onClick = {}, shape = RectangleShape, + onClick = {}, ) { Text(text = "Demo") } diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt index f2c0dcabc4..f185ccc713 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt @@ -269,9 +269,10 @@ fun MaxCalories(sliderPosition: Float, onValueChanged: (Float) -> Unit) { @Composable fun FilterTitle(text: String) { +) { Text( text = text, - style = MaterialTheme.typography.titleLarge, + style = MaterialTheme.typography.titleLarg style = MaterialTheme.typography.titleLarge, color = JetsnackTheme.colors.brand, modifier = Modifier.padding(bottom = 8.dp), ) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/ComponentStyles.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/ComponentStyles.kt new file mode 100644 index 0000000000..4300f875d9 --- /dev/null +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/ComponentStyles.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.jetsnack.ui.theme + +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.style.Style +import androidx.compose.foundation.style.background +import androidx.compose.foundation.style.clip +import androidx.compose.foundation.style.contentColor +import androidx.compose.foundation.style.contentPadding +import androidx.compose.foundation.style.disabled +import androidx.compose.foundation.style.minHeight +import androidx.compose.foundation.style.minWidth +import androidx.compose.foundation.style.pressed +import androidx.compose.foundation.style.shape +import androidx.compose.foundation.style.textStyle +import androidx.compose.runtime.Immutable +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.unit.dp +import com.example.jetsnack.ui.theme.JetsnackTheme.colors +import com.example.jetsnack.ui.theme.JetsnackTheme.typography + +@Immutable +data class AppStyles( + val buttonStyle: Style = buttonStyle, +) + +private val buttonStyle = Style { + minWidth(58.dp) + minHeight(40.dp) + contentPadding(8.dp, 24.dp) + background(Brush.horizontalGradient(colors.interactivePrimary)) + shape(RoundedCornerShape(50)) + clip() + textStyle(typography.labelLarge) + contentColor(colors.textInteractive) + disabled { + background(Brush.horizontalGradient(colors.interactiveSecondary)) + contentColor(colors.textHelp) + } + pressed { + background(Brush.horizontalGradient(colors.interactivePrimary)) + } +} diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt index 87f851d5ba..23c7099656 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt @@ -24,6 +24,7 @@ import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color +import androidx.compose.runtime.compositionLocalOf private val LightColorPalette = JetsnackColors( brand = Shadow5, @@ -80,14 +81,17 @@ private val DarkColorPalette = JetsnackColors( @Composable fun JetsnackTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { val colors = if (darkTheme) DarkColorPalette else LightColorPalette + val styles = AppStyles() ProvideJetsnackColors(colors) { - MaterialTheme( - colorScheme = debugColors(darkTheme), - typography = Typography, - shapes = Shapes, - content = content, - ) + CompositionLocalProvider(LocalAppStyles provides styles) { + MaterialTheme( + colorScheme = debugColors(darkTheme), + typography = Typography, + shapes = Shapes, + content = content, + ) + } } } @@ -95,6 +99,10 @@ object JetsnackTheme { val colors: JetsnackColors @Composable get() = LocalJetsnackColors.current + + val styles: AppStyles + @Composable + get() = LocalAppStyles.current } /** @@ -141,6 +149,8 @@ private val LocalJetsnackColors = staticCompositionLocalOf { error("No JetsnackColorPalette provided") } +private val LocalAppStyles = compositionLocalOf { AppStyles() } + /** * A Material [Colors] implementation which sets all colors to [debugColor] to discourage usage of * [MaterialTheme.colorScheme] in preference to [JetsnackTheme.colors]. diff --git a/Jetsnack/gradle/libs.versions.toml b/Jetsnack/gradle/libs.versions.toml index 4eee128ede..4e8175a8d6 100644 --- a/Jetsnack/gradle/libs.versions.toml +++ b/Jetsnack/gradle/libs.versions.toml @@ -4,7 +4,7 @@ android-material3 = "1.14.0-alpha09" androidGradlePlugin = "9.0.1" androidx-activity-compose = "1.13.0" androidx-appcompat = "1.7.1" -androidx-compose-bom = "2026.03.00" +androidx-compose-bom = "2026.04.01" androidx-core-splashscreen = "1.2.0" androidx-corektx = "1.17.0" androidx-glance = "1.2.0-rc01" From 9af96fa2aae5fe65d397a1c73cd18eb97bfa4947 Mon Sep 17 00:00:00 2001 From: Meghan Date: Wed, 6 May 2026 17:07:47 -0400 Subject: [PATCH 2/6] Revert "Test styles skill" This reverts commit 119bb492e6f88c5a90fec1a3ca353eaa28f5f299. --- Jetsnack/app/build.gradle.kts | 1 - .../example/jetsnack/ui/components/Button.kt | 39 +++++++++---- .../example/jetsnack/ui/home/FilterScreen.kt | 3 +- .../jetsnack/ui/theme/ComponentStyles.kt | 58 ------------------- .../com/example/jetsnack/ui/theme/Theme.kt | 22 ++----- Jetsnack/gradle/libs.versions.toml | 2 +- 6 files changed, 35 insertions(+), 90 deletions(-) delete mode 100644 Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/ComponentStyles.kt diff --git a/Jetsnack/app/build.gradle.kts b/Jetsnack/app/build.gradle.kts index 2d1d6a086d..0fca21037b 100644 --- a/Jetsnack/app/build.gradle.kts +++ b/Jetsnack/app/build.gradle.kts @@ -86,7 +86,6 @@ android { kotlin { compilerOptions { jvmTarget = JvmTarget.fromTarget("17") - freeCompilerArgs.add("-opt-in=androidx.compose.foundation.style.ExperimentalFoundationStyleApi") } } compileOptions { diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt index 16cb5cdac3..794bd3f1d7 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt @@ -17,10 +17,9 @@ package com.example.jetsnack.ui.components import android.content.res.Configuration.UI_MODE_NIGHT_YES - +import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.clickable import androidx.compose.foundation.indication import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement @@ -29,9 +28,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.style.MutableStyleState -import androidx.compose.foundation.style.Style -import androidx.compose.foundation.style.styleable +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ProvideTextStyle @@ -41,7 +38,11 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.RectangleShape +import androidx.compose.ui.graphics.Shape import androidx.compose.ui.semantics.Role import androidx.compose.ui.tooling.preview.Preview import com.example.jetsnack.ui.theme.JetsnackTheme @@ -50,24 +51,36 @@ import com.example.jetsnack.ui.theme.JetsnackTheme fun JetsnackButton( onClick: () -> Unit, modifier: Modifier = Modifier, - style: Style = Style, enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, + shape: Shape = ButtonShape, + border: BorderStroke? = null, + backgroundGradient: List = JetsnackTheme.colors.interactivePrimary, + disabledBackgroundGradient: List = JetsnackTheme.colors.interactiveSecondary, + contentColor: Color = JetsnackTheme.colors.textInteractive, + disabledContentColor: Color = JetsnackTheme.colors.textHelp, contentPadding: PaddingValues = ButtonDefaults.ContentPadding, content: @Composable RowScope.() -> Unit, ) { - val styleState = remember(interactionSource) { MutableStyleState(interactionSource) } - styleState.isEnabled = enabled - Row( + JetsnackSurface( + shape = shape, + color = Color.Transparent, + contentColor = if (enabled) contentColor else disabledContentColor, + border = border, modifier = modifier + .clip(shape) + .background( + Brush.horizontalGradient( + colors = if (enabled) backgroundGradient else disabledBackgroundGradient, + ), + ) .clickable( onClick = onClick, enabled = enabled, role = Role.Button, interactionSource = interactionSource, indication = null, - ) - .styleable(styleState, JetsnackTheme.styles.buttonStyle, style), + ), ) { ProvideTextStyle( value = MaterialTheme.typography.labelLarge, @@ -88,6 +101,8 @@ fun JetsnackButton( } } +private val ButtonShape = RoundedCornerShape(percent = 50) + @Preview("default", "round") @Preview("dark theme", "round", uiMode = UI_MODE_NIGHT_YES) @Preview("large font", "round", fontScale = 2f) @@ -107,7 +122,7 @@ private fun ButtonPreview() { private fun RectangleButtonPreview() { JetsnackTheme { JetsnackButton( - onClick = {}, + onClick = {}, shape = RectangleShape, ) { Text(text = "Demo") } diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt index f185ccc713..f2c0dcabc4 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt @@ -269,10 +269,9 @@ fun MaxCalories(sliderPosition: Float, onValueChanged: (Float) -> Unit) { @Composable fun FilterTitle(text: String) { -) { Text( text = text, - style = MaterialTheme.typography.titleLarg style = MaterialTheme.typography.titleLarge, + style = MaterialTheme.typography.titleLarge, color = JetsnackTheme.colors.brand, modifier = Modifier.padding(bottom = 8.dp), ) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/ComponentStyles.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/ComponentStyles.kt deleted file mode 100644 index 4300f875d9..0000000000 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/ComponentStyles.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.jetsnack.ui.theme - -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.style.Style -import androidx.compose.foundation.style.background -import androidx.compose.foundation.style.clip -import androidx.compose.foundation.style.contentColor -import androidx.compose.foundation.style.contentPadding -import androidx.compose.foundation.style.disabled -import androidx.compose.foundation.style.minHeight -import androidx.compose.foundation.style.minWidth -import androidx.compose.foundation.style.pressed -import androidx.compose.foundation.style.shape -import androidx.compose.foundation.style.textStyle -import androidx.compose.runtime.Immutable -import androidx.compose.ui.graphics.Brush -import androidx.compose.ui.unit.dp -import com.example.jetsnack.ui.theme.JetsnackTheme.colors -import com.example.jetsnack.ui.theme.JetsnackTheme.typography - -@Immutable -data class AppStyles( - val buttonStyle: Style = buttonStyle, -) - -private val buttonStyle = Style { - minWidth(58.dp) - minHeight(40.dp) - contentPadding(8.dp, 24.dp) - background(Brush.horizontalGradient(colors.interactivePrimary)) - shape(RoundedCornerShape(50)) - clip() - textStyle(typography.labelLarge) - contentColor(colors.textInteractive) - disabled { - background(Brush.horizontalGradient(colors.interactiveSecondary)) - contentColor(colors.textHelp) - } - pressed { - background(Brush.horizontalGradient(colors.interactivePrimary)) - } -} diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt index 23c7099656..87f851d5ba 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt @@ -24,7 +24,6 @@ import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color -import androidx.compose.runtime.compositionLocalOf private val LightColorPalette = JetsnackColors( brand = Shadow5, @@ -81,17 +80,14 @@ private val DarkColorPalette = JetsnackColors( @Composable fun JetsnackTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { val colors = if (darkTheme) DarkColorPalette else LightColorPalette - val styles = AppStyles() ProvideJetsnackColors(colors) { - CompositionLocalProvider(LocalAppStyles provides styles) { - MaterialTheme( - colorScheme = debugColors(darkTheme), - typography = Typography, - shapes = Shapes, - content = content, - ) - } + MaterialTheme( + colorScheme = debugColors(darkTheme), + typography = Typography, + shapes = Shapes, + content = content, + ) } } @@ -99,10 +95,6 @@ object JetsnackTheme { val colors: JetsnackColors @Composable get() = LocalJetsnackColors.current - - val styles: AppStyles - @Composable - get() = LocalAppStyles.current } /** @@ -149,8 +141,6 @@ private val LocalJetsnackColors = staticCompositionLocalOf { error("No JetsnackColorPalette provided") } -private val LocalAppStyles = compositionLocalOf { AppStyles() } - /** * A Material [Colors] implementation which sets all colors to [debugColor] to discourage usage of * [MaterialTheme.colorScheme] in preference to [JetsnackTheme.colors]. diff --git a/Jetsnack/gradle/libs.versions.toml b/Jetsnack/gradle/libs.versions.toml index 4e8175a8d6..4eee128ede 100644 --- a/Jetsnack/gradle/libs.versions.toml +++ b/Jetsnack/gradle/libs.versions.toml @@ -4,7 +4,7 @@ android-material3 = "1.14.0-alpha09" androidGradlePlugin = "9.0.1" androidx-activity-compose = "1.13.0" androidx-appcompat = "1.7.1" -androidx-compose-bom = "2026.04.01" +androidx-compose-bom = "2026.03.00" androidx-core-splashscreen = "1.2.0" androidx-corektx = "1.17.0" androidx-glance = "1.2.0-rc01" From 30b11bc5cb66733f29fe6736d351f38e6a7608f3 Mon Sep 17 00:00:00 2001 From: Meghan Date: Wed, 6 May 2026 17:20:46 -0400 Subject: [PATCH 3/6] Update dependencies to support Styles API --- Jetsnack/app/build.gradle.kts | 1 + .../app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt | 1 - Jetsnack/gradle/libs.versions.toml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jetsnack/app/build.gradle.kts b/Jetsnack/app/build.gradle.kts index 0fca21037b..2d1d6a086d 100644 --- a/Jetsnack/app/build.gradle.kts +++ b/Jetsnack/app/build.gradle.kts @@ -86,6 +86,7 @@ android { kotlin { compilerOptions { jvmTarget = JvmTarget.fromTarget("17") + freeCompilerArgs.add("-opt-in=androidx.compose.foundation.style.ExperimentalFoundationStyleApi") } } compileOptions { diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt index 87f851d5ba..0b5e4b55dc 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt @@ -139,7 +139,6 @@ fun ProvideJetsnackColors(colors: JetsnackColors, content: @Composable () -> Uni private val LocalJetsnackColors = staticCompositionLocalOf { error("No JetsnackColorPalette provided") -} /** * A Material [Colors] implementation which sets all colors to [debugColor] to discourage usage of diff --git a/Jetsnack/gradle/libs.versions.toml b/Jetsnack/gradle/libs.versions.toml index 4eee128ede..4e8175a8d6 100644 --- a/Jetsnack/gradle/libs.versions.toml +++ b/Jetsnack/gradle/libs.versions.toml @@ -4,7 +4,7 @@ android-material3 = "1.14.0-alpha09" androidGradlePlugin = "9.0.1" androidx-activity-compose = "1.13.0" androidx-appcompat = "1.7.1" -androidx-compose-bom = "2026.03.00" +androidx-compose-bom = "2026.04.01" androidx-core-splashscreen = "1.2.0" androidx-corektx = "1.17.0" androidx-glance = "1.2.0-rc01" From 69b2e42f22c10c5547622ac5b1c0cc4082158015 Mon Sep 17 00:00:00 2001 From: Meghan Date: Fri, 8 May 2026 11:00:33 -0400 Subject: [PATCH 4/6] Add style to button --- .../example/jetsnack/ui/components/Button.kt | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt index 794bd3f1d7..9ca0229917 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt @@ -17,18 +17,15 @@ package com.example.jetsnack.ui.components import android.content.res.Configuration.UI_MODE_NIGHT_YES -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.indication import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.defaultMinSize -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.style.Style import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ProvideTextStyle @@ -38,11 +35,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.RectangleShape -import androidx.compose.ui.graphics.Shape import androidx.compose.ui.semantics.Role import androidx.compose.ui.tooling.preview.Preview import com.example.jetsnack.ui.theme.JetsnackTheme @@ -53,27 +46,12 @@ fun JetsnackButton( modifier: Modifier = Modifier, enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, - shape: Shape = ButtonShape, - border: BorderStroke? = null, - backgroundGradient: List = JetsnackTheme.colors.interactivePrimary, - disabledBackgroundGradient: List = JetsnackTheme.colors.interactiveSecondary, - contentColor: Color = JetsnackTheme.colors.textInteractive, - disabledContentColor: Color = JetsnackTheme.colors.textHelp, - contentPadding: PaddingValues = ButtonDefaults.ContentPadding, + style: Style = Style, content: @Composable RowScope.() -> Unit, ) { JetsnackSurface( - shape = shape, color = Color.Transparent, - contentColor = if (enabled) contentColor else disabledContentColor, - border = border, modifier = modifier - .clip(shape) - .background( - Brush.horizontalGradient( - colors = if (enabled) backgroundGradient else disabledBackgroundGradient, - ), - ) .clickable( onClick = onClick, enabled = enabled, @@ -91,8 +69,7 @@ fun JetsnackButton( minWidth = ButtonDefaults.MinWidth, minHeight = ButtonDefaults.MinHeight, ) - .indication(interactionSource, ripple()) - .padding(contentPadding), + .indication(interactionSource, ripple()), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically, content = content, @@ -122,7 +99,7 @@ private fun ButtonPreview() { private fun RectangleButtonPreview() { JetsnackTheme { JetsnackButton( - onClick = {}, shape = RectangleShape, + onClick = {}, ) { Text(text = "Demo") } From d5f4cc99c126c74d715328fe51d72f7aa2688385 Mon Sep 17 00:00:00 2001 From: Meghan Date: Tue, 12 May 2026 10:07:20 -0400 Subject: [PATCH 5/6] Update Cart.kt --- .../src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt index 6268546131..7691fb687d 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt @@ -43,6 +43,7 @@ import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.style.Style import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -53,6 +54,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.LastBaseline @@ -449,10 +451,12 @@ private fun CheckoutBar(modifier: Modifier = Modifier) { Spacer(Modifier.weight(1f)) JetsnackButton( onClick = { /* todo */ }, - shape = RectangleShape, modifier = Modifier .padding(horizontal = 12.dp, vertical = 8.dp) .weight(1f), + style = Style { + border(2.dp, Color.Magenta) + } ) { Text( text = stringResource(id = R.string.cart_checkout), From c77fb604e005764440c2e90d642e0d53d191f655 Mon Sep 17 00:00:00 2001 From: Meghan Date: Tue, 12 May 2026 10:34:47 -0400 Subject: [PATCH 6/6] Add multiple properties --- .../main/java/com/example/jetsnack/ui/components/Button.kt | 7 ++++++- .../main/java/com/example/jetsnack/ui/home/cart/Cart.kt | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt index 9ca0229917..fb6c46881e 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Button.kt @@ -25,7 +25,9 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.style.MutableStyleState import androidx.compose.foundation.style.Style +import androidx.compose.foundation.style.styleable import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ProvideTextStyle @@ -49,6 +51,8 @@ fun JetsnackButton( style: Style = Style, content: @Composable RowScope.() -> Unit, ) { + val styleState = remember(interactionSource) { MutableStyleState(interactionSource) } + styleState.isEnabled = enabled JetsnackSurface( color = Color.Transparent, modifier = modifier @@ -58,7 +62,8 @@ fun JetsnackButton( role = Role.Button, interactionSource = interactionSource, indication = null, - ), + ) + .styleable(styleState, style), ) { ProvideTextStyle( value = MaterialTheme.typography.labelLarge, diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt index 7691fb687d..d6b460bff7 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/Cart.kt @@ -455,7 +455,9 @@ private fun CheckoutBar(modifier: Modifier = Modifier) { .padding(horizontal = 12.dp, vertical = 8.dp) .weight(1f), style = Style { - border(2.dp, Color.Magenta) + borderColor(Color.Magenta) + borderWidth(2.dp) + background(Color.Gray) } ) { Text(