From b0c0270668f9b6131e19a5ec0af5da32a091bebd Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Tue, 21 Nov 2023 15:59:30 +0000 Subject: [PATCH 1/3] Remove accompanist --- Jetsnack/app/build.gradle.kts | 2 -- .../com/example/jetsnack/ui/components/Filters.kt | 8 +++++--- .../com/example/jetsnack/ui/components/Gradient.kt | 2 +- .../java/com/example/jetsnack/ui/home/FilterScreen.kt | 11 +++++++---- .../example/jetsnack/ui/home/cart/SwipeDismissItem.kt | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Jetsnack/app/build.gradle.kts b/Jetsnack/app/build.gradle.kts index b721b8684c..06b1280815 100644 --- a/Jetsnack/app/build.gradle.kts +++ b/Jetsnack/app/build.gradle.kts @@ -111,8 +111,6 @@ dependencies { implementation(libs.androidx.compose.ui.tooling.preview) debugImplementation(libs.androidx.compose.ui.tooling) - implementation(libs.accompanist.flowlayout) - implementation(libs.coil.kt.compose) androidTestImplementation(libs.junit) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Filters.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Filters.kt index f137d39da3..9e3f3aa969 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Filters.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Filters.kt @@ -90,7 +90,8 @@ fun FilterChip( ) { val (selected, setSelected) = filter.enabled val backgroundColor by animateColorAsState( - if (selected) JetsnackTheme.colors.brandSecondary else JetsnackTheme.colors.uiBackground + if (selected) JetsnackTheme.colors.brandSecondary else JetsnackTheme.colors.uiBackground, + label = "background color" ) val border = Modifier.fadeInDiagonalGradientBorder( showBorder = !selected, @@ -98,11 +99,12 @@ fun FilterChip( shape = shape ) val textColor by animateColorAsState( - if (selected) Color.Black else JetsnackTheme.colors.textSecondary + if (selected) Color.Black else JetsnackTheme.colors.textSecondary, + label = "text color" ) JetsnackSurface( - modifier = modifier.height(28.dp), + modifier = modifier, color = backgroundColor, contentColor = textColor, shape = shape, diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt index ec26fe92f0..e48b5b5afe 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt @@ -71,7 +71,7 @@ fun Modifier.fadeInDiagonalGradientBorder( shape: Shape ) = composed { val animatedColors = List(colors.size) { i -> - animateColorAsState(if (showBorder) colors[i] else colors[i].copy(alpha = 0f)).value + animateColorAsState(if (showBorder) colors[i] else colors[i].copy(alpha = 0f), label = "animated color").value } diagonalGradientBorder( colors = animatedColors, 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 cfcf1ebffb..694d99d1af 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 @@ -14,9 +14,13 @@ * limitations under the License. */ +@file:OptIn(ExperimentalLayoutApi::class) + package com.example.jetsnack.ui.home import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -39,6 +43,7 @@ import androidx.compose.material.icons.filled.Done import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -55,15 +60,13 @@ import com.example.jetsnack.model.SnackRepo import com.example.jetsnack.ui.components.FilterChip import com.example.jetsnack.ui.components.JetsnackScaffold import com.example.jetsnack.ui.theme.JetsnackTheme -import com.google.accompanist.flowlayout.FlowMainAxisAlignment -import com.google.accompanist.flowlayout.FlowRow @Composable fun FilterScreen( onDismiss: () -> Unit ) { var sortState by remember { mutableStateOf(SnackRepo.getSortDefault()) } - var maxCalories by remember { mutableStateOf(0f) } + var maxCalories by remember { mutableFloatStateOf(0f) } val defaultFilter = SnackRepo.getSortDefault() Dialog(onDismissRequest = onDismiss) { @@ -153,7 +156,6 @@ fun FilterScreen( fun FilterChipSection(title: String, filters: List) { FilterTitle(text = title) FlowRow( - mainAxisAlignment = FlowMainAxisAlignment.Center, modifier = Modifier .fillMaxWidth() .padding(top = 12.dp, bottom = 16.dp) @@ -198,6 +200,7 @@ fun SortFilters( } } + @Composable fun MaxCalories(sliderPosition: Float, onValueChanged: (Float) -> Unit) { FlowRow { diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt index ff5f68f43f..bcd42ce483 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt @@ -31,7 +31,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.Dp -@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterialApi::class) @Composable /** * Holds the Swipe to dismiss composable, its animation and the current state From 5798937e2135fdad1741c2422b603c893a3d8f9b Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Thu, 23 Nov 2023 10:56:41 +0000 Subject: [PATCH 2/3] ktlint --- .../main/java/com/example/jetsnack/ui/components/Gradient.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt index e48b5b5afe..63037d661f 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt @@ -71,7 +71,10 @@ fun Modifier.fadeInDiagonalGradientBorder( shape: Shape ) = composed { val animatedColors = List(colors.size) { i -> - animateColorAsState(if (showBorder) colors[i] else colors[i].copy(alpha = 0f), label = "animated color").value + animateColorAsState( + if (showBorder) colors[i] else colors[i].copy(alpha = 0f), + label = "animated color" + ).value } diagonalGradientBorder( colors = animatedColors, From c21d8f3c8609ccc7e14429910371c5fc5d600d91 Mon Sep 17 00:00:00 2001 From: riggaroo Date: Thu, 23 Nov 2023 10:59:18 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A4=96=20Apply=20Spotless?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/example/jetsnack/ui/components/Filters.kt | 1 - .../src/main/java/com/example/jetsnack/ui/home/FilterScreen.kt | 1 - .../java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt | 1 - 3 files changed, 3 deletions(-) diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Filters.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Filters.kt index 9e3f3aa969..7e93f00084 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Filters.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Filters.kt @@ -24,7 +24,6 @@ import androidx.compose.foundation.interaction.collectIsPressedAsState import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyRow 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 694d99d1af..8dadd4248f 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 @@ -200,7 +200,6 @@ fun SortFilters( } } - @Composable fun MaxCalories(sliderPosition: Float, onValueChanged: (Float) -> Unit) { FlowRow { diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt index bcd42ce483..53c0fe4d21 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/home/cart/SwipeDismissItem.kt @@ -19,7 +19,6 @@ package com.example.jetsnack.ui.home.cart import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.EnterTransition import androidx.compose.animation.ExitTransition -import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.expandVertically import androidx.compose.animation.shrinkVertically import androidx.compose.material.DismissDirection