Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Jetsnack/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,19 +89,21 @@ 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,
colors = JetsnackTheme.colors.interactiveSecondary,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)).value
animateColorAsState(
if (showBorder) colors[i] else colors[i].copy(alpha = 0f),
label = "animated color"
).value
}
diagonalGradientBorder(
colors = animatedColors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -153,7 +156,6 @@ fun FilterScreen(
fun FilterChipSection(title: String, filters: List<Filter>) {
FilterTitle(text = title)
FlowRow(
mainAxisAlignment = FlowMainAxisAlignment.Center,
modifier = Modifier
.fillMaxWidth()
.padding(top = 12.dp, bottom = 16.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +30,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
Expand Down