Skip to content

Commit

Permalink
Merge pull request #832 from kosenda/feature/favorite-filters-chip-ad…
Browse files Browse the repository at this point in the history
…d-animation-icon

In FavoriteScreen, add animtion in FavoriteFilterChip icon
  • Loading branch information
takahirom authored Aug 27, 2024
2 parents db0e473 + 1acca38 commit 009bdf7
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package io.github.droidkaigi.confsched.favorites.component

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.expandHorizontally
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkHorizontally
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -43,17 +48,17 @@ fun FavoriteFilters(
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
FavoriteFilterChip(
selected = allFilterSelected,
isSelected = allFilterSelected,
onClick = onAllFilterChipClick,
text = stringResource(FavoritesRes.string.filter_all),
)
FavoriteFilterChip(
selected = day1FilterSelected,
isSelected = day1FilterSelected,
onClick = onDay1FilterChipClick,
text = stringResource(FavoritesRes.string.filter_day1),
)
FavoriteFilterChip(
selected = day2FilterSelected,
isSelected = day2FilterSelected,
onClick = onDay2FilterChipClick,
text = stringResource(FavoritesRes.string.filter_day2),
)
Expand All @@ -62,18 +67,22 @@ fun FavoriteFilters(

@Composable
private fun FavoriteFilterChip(
selected: Boolean,
isSelected: Boolean,
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
FilterChip(
modifier = modifier.padding(top = 8.dp, bottom = 12.dp),
selected = selected,
selected = isSelected,
onClick = onClick,
label = { Text(text) },
leadingIcon = {
if (selected) {
AnimatedVisibility(
visible = isSelected,
enter = fadeIn() + expandHorizontally(),
exit = fadeOut() + shrinkHorizontally(),
) {
Icon(
imageVector = Icons.Filled.Check,
contentDescription = null,
Expand Down

0 comments on commit 009bdf7

Please sign in to comment.