Skip to content

Commit

Permalink
Make DroidKaigiSchedule stable
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirom committed Sep 26, 2022
1 parent faed8f1 commit e60c694
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
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

0 comments on commit e60c694

Please sign in to comment.