From e60c69459463c2677f55f80d183b2bae55ed6a06 Mon Sep 17 00:00:00 2001 From: takahirom Date: Mon, 26 Sep 2022 09:57:52 +0900 Subject: [PATCH] Make DroidKaigiSchedule stable --- .../droidkaigi/confsched2022/model/DroidKaigiSchedule.kt | 1 + .../io/github/droidkaigi/confsched2022/model/Timetable.kt | 1 + .../io/github/droidkaigi/confsched2022/ui/UiLoadState.kt | 2 ++ .../droidkaigi/confsched2022/feature/sessions/Sessions.kt | 1 - .../droidkaigi/confsched2022/feature/sessions/Timetable.kt | 5 +---- gradle.properties | 3 +++ 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/DroidKaigiSchedule.kt b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/DroidKaigiSchedule.kt index 2c177ba15..beeb6f97c 100644 --- a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/DroidKaigiSchedule.kt +++ b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/DroidKaigiSchedule.kt @@ -10,6 +10,7 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers @Serializable +@Immutable public data class DroidKaigiSchedule( val dayToTimetable: PersistentMap, private val timetable: Timetable diff --git a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/Timetable.kt b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/Timetable.kt index 6b50d9e59..b74d061c6 100644 --- a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/Timetable.kt +++ b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/Timetable.kt @@ -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 = persistentSetOf(), diff --git a/core/ui/src/main/java/io/github/droidkaigi/confsched2022/ui/UiLoadState.kt b/core/ui/src/main/java/io/github/droidkaigi/confsched2022/ui/UiLoadState.kt index 338db3885..f1b6b4b4c 100644 --- a/core/ui/src/main/java/io/github/droidkaigi/confsched2022/ui/UiLoadState.kt +++ b/core/ui/src/main/java/io/github/droidkaigi/confsched2022/ui/UiLoadState.kt @@ -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 { public object Loading : UiLoadState public data class Success(val value: T) : UiLoadState diff --git a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt index eca80447e..71983dab1 100644 --- a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt +++ b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Sessions.kt @@ -266,7 +266,6 @@ fun Timetable( Timetable( timetable = timetable, timetableState = timetableState, - coroutineScope = coroutineScope, contentPadding = PaddingValues( bottom = contentPadding.calculateBottomPadding(), ) diff --git a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Timetable.kt b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Timetable.kt index d0a000424..ca9e9ba0c 100644 --- a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Timetable.kt +++ b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/Timetable.kt @@ -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 @@ -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) @@ -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) } diff --git a/gradle.properties b/gradle.properties index 34048319a..30123aa66 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file