Skip to content

Commit

Permalink
Remove accompanist
Browse files Browse the repository at this point in the history
  • Loading branch information
riggaroo committed Nov 21, 2023
1 parent 2feda1a commit b0c0270
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
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 @@ -90,19 +90,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,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,
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 Expand Up @@ -198,6 +200,7 @@ fun SortFilters(
}
}


@Composable
fun MaxCalories(sliderPosition: Float, onValueChanged: (Float) -> Unit) {
FlowRow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b0c0270

Please sign in to comment.