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

Make DroidKaigiSchedule stable #760

Merged
merged 1 commit into from
Sep 26, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers

@Serializable
@Immutable
public data class DroidKaigiSchedule(
val dayToTimetable: PersistentMap<DroidKaigi2022Day, Timetable>,
private val timetable: Timetable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers

@Serializable
@Immutable
public data class Timetable(
val timetableItems: TimetableItemList = TimetableItemList(),
val favorites: PersistentSet<TimetableItemId> = persistentSetOf(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.github.droidkaigi.confsched2022.ui

import androidx.compose.runtime.Immutable
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart

@Immutable
public sealed interface UiLoadState<out T> {
public object Loading : UiLoadState<Nothing>
public data class Success<T>(val value: T) : UiLoadState<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ fun Timetable(
Timetable(
timetable = timetable,
timetableState = timetableState,
coroutineScope = coroutineScope,
contentPadding = PaddingValues(
bottom = contentPadding.calculateBottomPadding(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import io.github.droidkaigi.confsched2022.model.Timetable
import io.github.droidkaigi.confsched2022.model.TimetableItem
import io.github.droidkaigi.confsched2022.model.TimetableRoom
import io.github.droidkaigi.confsched2022.model.fake
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.datetime.DateTimeUnit
Expand All @@ -74,11 +73,11 @@ import kotlin.math.roundToInt
fun Timetable(
timetable: Timetable,
timetableState: TimetableState,
coroutineScope: CoroutineScope,
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(),
content: @Composable (TimetableItem, Boolean) -> Unit,
) {
val coroutineScope = rememberCoroutineScope()
val itemProvider = itemProvider({ timetable.timetableItems.size }) { index ->
val timetableItemWithFavorite = timetable.contents[index]
content(timetableItemWithFavorite.timetableItem, timetableItemWithFavorite.isFavorited)
Expand Down Expand Up @@ -224,12 +223,10 @@ fun Timetable(
@Composable
fun TimetablePreview() {
val timetableState = rememberTimetableState()
val coroutineScope = rememberCoroutineScope()
Timetable(
modifier = Modifier.fillMaxSize(),
timetable = Timetable.fake(),
timetableState = timetableState,
coroutineScope = coroutineScope,
) { timetableItem, isFavorite ->
TimetableItem(timetableItem, isFavorite, 1f)
}
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ kotlin.js.compiler=ir
# in order to determine flavors.
# https://github.com/yshrsmz/BuildKonfig#product-flavor
buildkonfig.flavor=dev

enableComposeCompilerMetrics=true
enableComposeCompilerReports=true