Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement list animation on TimetableTime and timetable items of FavoriteList. #824

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import io.github.droidkaigi.confsched.favorites.section.FavoriteSheet
import io.github.droidkaigi.confsched.favorites.section.FavoritesSheetUiState
import io.github.droidkaigi.confsched.favorites.section.FavoritesSheetUiState.FavoriteListUiState.TimeSlot
import io.github.droidkaigi.confsched.model.DroidKaigi2024Day
import io.github.droidkaigi.confsched.model.Timetable
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.model.TimetableItem.Session
import io.github.droidkaigi.confsched.model.fake
Expand Down Expand Up @@ -184,6 +185,7 @@ fun FavoritesScreenPreview() {
Session.fake(),
),
),
timetable = Timetable.fake(),
),
userMessageStateHolder = UserMessageStateHolderImpl(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ fun favoritesScreenPresenter(
sessionsRepository: SessionsRepository = localSessionsRepository(),
): FavoritesScreenUiState = providePresenterDefaults { userMessageStateHolder ->
val favoriteSessions by rememberUpdatedState(
sessionsRepository
.timetable()
.filtered(Filters(filterFavorite = true)),
sessionsRepository.timetable(),
)
var allFilterSelected by remember { mutableStateOf(true) }
var currentDayFilters by remember { mutableStateOf(emptySet<DroidKaigi2024Day>()) }
Expand Down Expand Up @@ -102,7 +100,6 @@ private fun favoritesSheet(
favoriteSessions
.filtered(
Filters(
filterFavorite = true,
days = selectedDayFilters.toList(),
),
)
Expand All @@ -125,6 +122,7 @@ private fun favoritesSheet(
currentDayFilter = selectedDayFilters.toPersistentList(),
allFilterSelected = allFilterSelected,
timetableItemMap = filteredSessions,
timetable = favoriteSessions,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.github.droidkaigi.confsched.favorites.section

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -40,17 +44,19 @@ import io.github.droidkaigi.confsched.droidkaigiui.component.TimetableItemTag
import io.github.droidkaigi.confsched.droidkaigiui.component.TimetableTime
import io.github.droidkaigi.confsched.droidkaigiui.icon
import io.github.droidkaigi.confsched.favorites.section.FavoritesSheetUiState.FavoriteListUiState.TimeSlot
import io.github.droidkaigi.confsched.model.Timetable
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.model.TimetableItem.Session
import io.github.droidkaigi.confsched.model.fake
import kotlinx.collections.immutable.PersistentMap
import kotlinx.collections.immutable.persistentMapOf
import org.jetbrains.compose.ui.tooling.preview.Preview

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class, ExperimentalFoundationApi::class)
@Composable
fun FavoriteList(
timetableItemMap: PersistentMap<TimeSlot, List<TimetableItem>>,
timetable: Timetable,
onBookmarkClick: (TimetableItem) -> Unit,
onTimetableItemClick: (TimetableItem) -> Unit,
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -99,17 +105,22 @@ fun FavoriteList(
modifier = Modifier
.onGloballyPositioned {
rowHeight = it.size.height
},
}
.animateItemPlacement(),
) {
TimetableTime(
modifier = Modifier
.onGloballyPositioned {
timeTextHeight = it.size.height
}
.offset { IntOffset(0, timeTextOffset) },
startTime = time.startTimeString,
endTime = time.endTimeString,
)
val bookmarkedTimetableItems = timetableItems.filter { timetable.bookmarks.contains(it.id) }

if (bookmarkedTimetableItems.isNotEmpty()) {
TimetableTime(
modifier = Modifier
.onGloballyPositioned {
timeTextHeight = it.size.height
}
.offset { IntOffset(0, timeTextOffset) },
startTime = time.startTimeString,
endTime = time.endTimeString,
)
}
Spacer(modifier = Modifier.width(16.dp))
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
timetableItems.windowed(columnNum, columnNum, true).forEach { windowedItems ->
Expand All @@ -118,35 +129,45 @@ fun FavoriteList(
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
windowedItems.onEach { timetableItem ->
TimetableItemCard(
modifier = Modifier
.weight(1F)
.fillMaxHeight(),
isBookmarked = true,
tags = {
TimetableItemTag(
tagText = timetableItem.room.name.currentLangTitle,
icon = timetableItem.room.icon,
tagColor = LocalRoomTheme.current.primaryColor,
modifier = Modifier.background(LocalRoomTheme.current.containerColor),
)
timetableItem.language.labels.forEach { label ->
TimetableItemTag(
tagText = label,
tagColor = MaterialTheme.colorScheme.outline,
)
}
timetableItem.day?.let {
val isBookmarked =
timetable.bookmarks.contains(timetableItem.id)
AnimatedVisibility(
visible = isBookmarked,
enter = fadeIn(),
exit = fadeOut(),
) {
TimetableItemCard(
modifier = Modifier
.weight(1F)
.fillMaxHeight(),
isBookmarked = true,
tags = {
TimetableItemTag(
tagText = "9/${it.dayOfMonth}",
tagColor = MaterialTheme.colorScheme.outline,
tagText = timetableItem.room.name.currentLangTitle,
icon = timetableItem.room.icon,
tagColor = LocalRoomTheme.current.primaryColor,
modifier = Modifier.background(
LocalRoomTheme.current.containerColor,
),
)
}
},
timetableItem = timetableItem,
onTimetableItemClick = onTimetableItemClick,
onBookmarkClick = { item, _ -> onBookmarkClick(item) },
)
timetableItem.language.labels.forEach { label ->
TimetableItemTag(
tagText = label,
tagColor = MaterialTheme.colorScheme.outline,
)
}
timetableItem.day?.let {
TimetableItemTag(
tagText = "9/${it.dayOfMonth}",
tagColor = MaterialTheme.colorScheme.outline,
)
}
},
timetableItem = timetableItem,
onTimetableItemClick = onTimetableItemClick,
onBookmarkClick = { item, _ -> onBookmarkClick(item) },
)
}
}
if (windowedItems.size < columnNum) {
repeat(columnNum - windowedItems.size) {
Expand Down Expand Up @@ -175,6 +196,7 @@ fun FavoriteListPreview() {
Session.fake(),
),
),
timetable = Timetable.fake(),
onBookmarkClick = {},
onTimetableItemClick = {},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import io.github.droidkaigi.confsched.favorites.section.FavoritesSheetUiState.Fa
import io.github.droidkaigi.confsched.model.DroidKaigi2024Day
import io.github.droidkaigi.confsched.model.DroidKaigi2024Day.ConferenceDay1
import io.github.droidkaigi.confsched.model.DroidKaigi2024Day.ConferenceDay2
import io.github.droidkaigi.confsched.model.Timetable
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.model.TimetableItem.Session
import io.github.droidkaigi.confsched.model.fake
Expand All @@ -64,6 +65,7 @@ sealed interface FavoritesSheetUiState {
override val currentDayFilter: PersistentList<DroidKaigi2024Day>,
override val allFilterSelected: Boolean,
val timetableItemMap: PersistentMap<TimeSlot, List<TimetableItem>>,
val timetable: Timetable,
) : FavoritesSheetUiState {
data class TimeSlot(
val startTimeString: String,
Expand Down Expand Up @@ -122,6 +124,7 @@ fun FavoriteSheet(
is FavoritesSheetUiState.FavoriteListUiState -> {
FavoriteList(
timetableItemMap = uiState.timetableItemMap,
timetable = uiState.timetable,
onBookmarkClick = onBookmarkClick,
onTimetableItemClick = onTimetableItemClick,
contentPadding = contentPadding,
Expand Down Expand Up @@ -192,6 +195,7 @@ fun FavoriteSheetPreview() {
Session.fake(),
),
),
timetable = Timetable.fake(),
),
filterBackgroundColor = MaterialTheme.colorScheme.surface,
onAllFilterChipClick = {},
Expand Down
Loading