From eab70564bc8dd481e12b0526945627d9028dda3d Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Sun, 27 Aug 2023 17:52:50 +0900 Subject: [PATCH 01/15] Supports retrieval of string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stringの取得に対応 --- .../confsched2023/shared/EntryPointTest.kt | 6 +++++- .../data/remoteconfig/DefaultRemoteConfigApi.kt | 5 +++++ .../data/remoteconfig/FakeRemoteConfigApi.kt | 16 ++++++++++++++-- .../data/remoteconfig/RemoteConfigApi.kt | 1 + 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app-ios-shared/src/iosTest/kotlin/io/github/droidkaigi/confsched2023/shared/EntryPointTest.kt b/app-ios-shared/src/iosTest/kotlin/io/github/droidkaigi/confsched2023/shared/EntryPointTest.kt index 58c49b565..e5e7289ca 100644 --- a/app-ios-shared/src/iosTest/kotlin/io/github/droidkaigi/confsched2023/shared/EntryPointTest.kt +++ b/app-ios-shared/src/iosTest/kotlin/io/github/droidkaigi/confsched2023/shared/EntryPointTest.kt @@ -25,6 +25,10 @@ class EntryPointTest { override suspend fun getBoolean(key: String): Boolean { return true } + + override suspend fun getString(key: String): String { + return "default" + } }, authenticator = object : Authenticator { override suspend fun currentUser(): User? { @@ -50,4 +54,4 @@ class EntryPointTest { assertNotNull(kmpEntryPoint.get()) assertNotNull(kmpEntryPoint.get()) } -} \ No newline at end of file +} diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt index c07bd8f14..a2ee09d64 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -23,4 +23,9 @@ class DefaultRemoteConfigApi : RemoteConfigApi { firebaseRemoteConfig.fetchAndActivate() return firebaseRemoteConfig[key] } + + override suspend fun getString(key: String): String { + firebaseRemoteConfig.fetchAndActivate() + return firebaseRemoteConfig[key] + } } diff --git a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt index 80c9d89d2..d1c60e159 100644 --- a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt +++ b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt @@ -5,16 +5,24 @@ import androidx.datastore.core.IOException class FakeRemoteConfigApi : RemoteConfigApi { sealed interface Status : RemoteConfigApi { - object Default : Status { + data object Default : Status { override suspend fun getBoolean(key: String): Boolean { return true } + + override suspend fun getString(key: String): String { + return "default" + } } - object ThrowException : Status { + data object ThrowException : Status { override suspend fun getBoolean(key: String): Boolean { throw IOException("FakeRemoteConfigApi throws exception") } + + override suspend fun getString(key: String): String { + throw IOException("FakeRemoteConfigApi throws exception") + } } } @@ -27,4 +35,8 @@ class FakeRemoteConfigApi : RemoteConfigApi { override suspend fun getBoolean(key: String): Boolean { return status.getBoolean(key) } + + override suspend fun getString(key: String): String { + return status.getString(key) + } } diff --git a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigApi.kt b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigApi.kt index 693b867f2..14e942fb9 100644 --- a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigApi.kt +++ b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigApi.kt @@ -2,4 +2,5 @@ package io.github.droidkaigi.confsched2023.data.remoteconfig interface RemoteConfigApi { suspend fun getBoolean(key: String): Boolean + suspend fun getString(key: String): String } From 2baa580209599df756c55518acd779ac0d83e653 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Sun, 27 Aug 2023 18:41:59 +0900 Subject: [PATCH 02/15] Delete fixed values in the wording of the details MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 詳細の文言の固定の値を削除 --- .../github/droidkaigi/confsched2023/stamps/StampsStrings.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsStrings.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsStrings.kt index 006ee5e8a..1f14d3bcf 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsStrings.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsStrings.kt @@ -8,22 +8,18 @@ sealed class StampsStrings : Strings(Bindings) { data object Title : StampsStrings() - data object Description : StampsStrings() - data object DescriptionNotes : StampsStrings() private object Bindings : StringsBindings( Lang.Japanese to { item, _ -> when (item) { Title -> "Stamps" - Description -> "会場の各部屋に設置されたNFCタグにスマホをかざしてスタンプを集めてみましょう。" DescriptionNotes -> "※ この企画は変更または中止になる可能性があります" } }, Lang.English to { item, _ -> when (item) { Title -> "Stamps" - Description -> "Let's collect stamps by holding your smartphone over the NFC tags placed in each room of the venue." DescriptionNotes -> "※ This program is subject to change or cancellation." } }, From 9197090a72c20f6b814f178e642e046bae637184 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Sun, 27 Aug 2023 18:44:04 +0900 Subject: [PATCH 03/15] Get detailed wording from Firebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 詳細の文言をFirebaseから取得 --- .../remoteconfig/DefaultRemoteConfigApi.kt | 2 +- .../remoteconfig/DefaultStampRepository.kt | 12 +++++++++ .../data/contributors/StampRepository.kt | 1 + .../confsched2023/stamps/StampsScreen.kt | 2 ++ .../stamps/StampsScreenViewModel.kt | 27 ++++++++++++++++++- .../stamps/component/StampsDetail.kt | 3 ++- .../confsched2023/stamps/section/StampList.kt | 3 ++- 7 files changed, 46 insertions(+), 4 deletions(-) diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt index a2ee09d64..439d1cb74 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -14,7 +14,7 @@ class DefaultRemoteConfigApi : RemoteConfigApi { // init { // CoroutineScope(Dispatchers.IO).launch { // firebaseRemoteConfig.settings { -// minimumFetchIntervalInSeconds = 12 * 3600L +// minimumFetchIntervalInSeconds = 10 // } // } // } diff --git a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultStampRepository.kt b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultStampRepository.kt index 700a4ac49..47fd0c35d 100644 --- a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultStampRepository.kt +++ b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultStampRepository.kt @@ -9,15 +9,27 @@ class DefaultStampRepository( private val remoteConfigApi: RemoteConfigApi, ) : StampRepository { private val isStampsEnabledStateFlow: MutableStateFlow = MutableStateFlow(false) + private val stampDetailDescriptionStateFlow: MutableStateFlow = MutableStateFlow("") + private suspend fun fetchStampsEnabled() { isStampsEnabledStateFlow.value = remoteConfigApi.getBoolean(IS_STAMPS_ENABLED_KEY) } + private suspend fun fetchStampDetailDescription() { + stampDetailDescriptionStateFlow.value = + remoteConfigApi.getString(STAMP_DETAIL_DESCRIPTION_KEY) + } + override fun getStampEnabledStream(): Flow { return isStampsEnabledStateFlow.onStart { fetchStampsEnabled() } } + override fun getStampDetailDescriptionStream(): Flow { + return stampDetailDescriptionStateFlow.onStart { fetchStampDetailDescription() } + } + companion object { const val IS_STAMPS_ENABLED_KEY = "is_stamps_enable" + const val STAMP_DETAIL_DESCRIPTION_KEY = "achievements_detail_description" } } diff --git a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/contributors/StampRepository.kt b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/contributors/StampRepository.kt index a5d2c3125..efeb88250 100644 --- a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/contributors/StampRepository.kt +++ b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/contributors/StampRepository.kt @@ -5,4 +5,5 @@ import kotlinx.coroutines.flow.Flow interface StampRepository { fun getStampEnabledStream(): Flow + fun getStampDetailDescriptionStream(): Flow } diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt index b4adefce2..0674e3114 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt @@ -70,6 +70,7 @@ fun StampsScreen( data class StampsScreenUiState( val lottieRawRes: Int?, val stamps: ImmutableList, + val detailDescription: String, ) @Composable @@ -89,6 +90,7 @@ private fun StampsScreen( StampList( stamps = uiState.stamps, + detailDescription = uiState.detailDescription, onStampsClick = onStampsClick, onReachAnimationEnd = onReachAnimationEnd, stampLottieRawId = stampLottieRawId, diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt index 0d2d428ba..53c318d86 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt @@ -1,27 +1,51 @@ package io.github.droidkaigi.confsched2023.stamps +import android.util.Log import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import io.github.droidkaigi.confsched2023.data.contributors.StampRepository +import io.github.droidkaigi.confsched2023.designsystem.strings.AppStrings import io.github.droidkaigi.confsched2023.feature.stamps.R import io.github.droidkaigi.confsched2023.model.Stamp import io.github.droidkaigi.confsched2023.ui.UserMessageStateHolder import io.github.droidkaigi.confsched2023.ui.buildUiState +import io.github.droidkaigi.confsched2023.ui.handleErrorAndRetry import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.stateIn import javax.inject.Inject @HiltViewModel class StampsScreenViewModel @Inject constructor( val userMessageStateHolder: UserMessageStateHolder, + stampRepository: StampRepository, ) : ViewModel(), UserMessageStateHolder by userMessageStateHolder { + private val stampDetailDescriptionStateFlow: StateFlow = + stampRepository.getStampDetailDescriptionStream() + .handleErrorAndRetry( + AppStrings.Retry, + userMessageStateHolder, + ) + .stateIn( + scope = viewModelScope, + started = SharingStarted.WhileSubscribed(5_000), + initialValue = "", + ) + private val stampLottieRawResStateFlow: MutableStateFlow = MutableStateFlow(null) val uiState = buildUiState( stampLottieRawResStateFlow, - ) { rawRes -> + stampDetailDescriptionStateFlow, + ) { rawRes, detailDescription -> + Log.d("StampsScreenViewModel", "rawRes: $rawRes") + Log.d("StampsScreenViewModel", "detailDescription: $detailDescription") StampsScreenUiState( lottieRawRes = rawRes, stamps = persistentListOf( @@ -56,6 +80,7 @@ class StampsScreenViewModel @Inject constructor( contentDescription = "StampE image", ), ), + detailDescription = detailDescription, ) } diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/component/StampsDetail.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/component/StampsDetail.kt index 5b2591dee..a34cfaa89 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/component/StampsDetail.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/component/StampsDetail.kt @@ -13,6 +13,7 @@ import io.github.droidkaigi.confsched2023.stamps.StampsStrings @Composable fun StampsDetail( + description: String, modifier: Modifier = Modifier, ) { Column(modifier = modifier) { @@ -25,7 +26,7 @@ fun StampsDetail( Spacer(modifier = Modifier.height(16.dp)) Text( - text = StampsStrings.Description.asString(), + text = description, style = MaterialTheme.typography.bodyLarge, modifier = Modifier.fillMaxWidth(), ) diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt index d3ef32f7f..b2e1e1bc7 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt @@ -33,6 +33,7 @@ private const val DoubleItemSpanCount = 2 / 2 @Composable fun StampList( stamps: ImmutableList, + detailDescription: String, @androidx.annotation.RawRes stampLottieRawId: Int?, onStampsClick: (Stamp) -> Unit, @@ -86,7 +87,7 @@ fun StampList( key = "stamps_header", span = { GridItemSpan(SingleItemSpanCount) }, ) { - StampsDetail() + StampsDetail(detailDescription) } items( items = stamps, From 46275faf515b7fc378c284d7e6772c1bbbf031f7 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Sun, 27 Aug 2023 18:44:54 +0900 Subject: [PATCH 04/15] Adjust acquisition interval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 取得間隔を調整 --- .../data/remoteconfig/DefaultRemoteConfigApi.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt index 439d1cb74..7d1b80b9e 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -3,6 +3,9 @@ package io.github.droidkaigi.confsched2023.data.remoteconfig import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.remoteconfig.get import dev.gitlive.firebase.remoteconfig.remoteConfig +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch class DefaultRemoteConfigApi : RemoteConfigApi { @@ -11,13 +14,13 @@ class DefaultRemoteConfigApi : RemoteConfigApi { /** * If you want to change the interval time to fetch, please change it here */ -// init { -// CoroutineScope(Dispatchers.IO).launch { -// firebaseRemoteConfig.settings { -// minimumFetchIntervalInSeconds = 10 -// } -// } -// } + init { + CoroutineScope(Dispatchers.IO).launch { + firebaseRemoteConfig.settings { + minimumFetchIntervalInSeconds = 1 * 60 + } + } + } override suspend fun getBoolean(key: String): Boolean { firebaseRemoteConfig.fetchAndActivate() From 774de0cb28586eb00d31db18705831844f89b240 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Sun, 27 Aug 2023 19:24:44 +0900 Subject: [PATCH 05/15] Change initialization logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 初期化ロジックを変更 --- .../io/github/droidkaigi/confsched2023/App.kt | 14 ++++++- .../confsched2023/data/di/ApiModule.kt | 17 ++++++++- .../remoteconfig/DefaultRemoteConfigApi.kt | 38 +++++++++---------- .../remoteconfig/RemoteConfigInitializer.kt | 16 ++++++++ 4 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigInitializer.kt diff --git a/app-android/src/main/java/io/github/droidkaigi/confsched2023/App.kt b/app-android/src/main/java/io/github/droidkaigi/confsched2023/App.kt index 92942b1bf..a8ccf4043 100644 --- a/app-android/src/main/java/io/github/droidkaigi/confsched2023/App.kt +++ b/app-android/src/main/java/io/github/droidkaigi/confsched2023/App.kt @@ -2,6 +2,18 @@ package io.github.droidkaigi.confsched2023 import android.app.Application import dagger.hilt.android.HiltAndroidApp +import io.github.droidkaigi.confsched2023.data.remoteconfig.RemoteConfigInitializer +import kotlinx.coroutines.runBlocking +import javax.inject.Inject @HiltAndroidApp -class App : Application() +class App : Application() { + @Inject lateinit var remoteConfigInitializer: RemoteConfigInitializer + + override fun onCreate() { + super.onCreate() + runBlocking { + remoteConfigInitializer.initialize() + } + } +} diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt index 50e538455..c7caf005a 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt @@ -5,6 +5,9 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import de.jensklingenberg.ktorfit.Ktorfit +import dev.gitlive.firebase.Firebase +import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfig +import dev.gitlive.firebase.remoteconfig.remoteConfig import io.github.droidkaigi.confsched2023.data.NetworkService import io.github.droidkaigi.confsched2023.data.auth.AndroidAuthenticator import io.github.droidkaigi.confsched2023.data.auth.AuthApi @@ -128,7 +131,17 @@ class AuthenticatorModule { class RemoteConfigModule { @Provides @Singleton - fun provideFirebaseRemoteConfig(): RemoteConfigApi { - return DefaultRemoteConfigApi() + fun provideRemoteConfigApi( + firebaseRemoteConfig: FirebaseRemoteConfig, + ): RemoteConfigApi { + return DefaultRemoteConfigApi( + firebaseRemoteConfig = firebaseRemoteConfig + ) + } + + @Provides + @Singleton + fun provideFirebaseRemoteConfig(): FirebaseRemoteConfig { + return Firebase.remoteConfig } } diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt index 7d1b80b9e..66e2c8b37 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -1,34 +1,30 @@ package io.github.droidkaigi.confsched2023.data.remoteconfig -import dev.gitlive.firebase.Firebase +import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfig import dev.gitlive.firebase.remoteconfig.get -import dev.gitlive.firebase.remoteconfig.remoteConfig -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch +import javax.inject.Inject +import javax.inject.Singleton -class DefaultRemoteConfigApi : RemoteConfigApi { - - private val firebaseRemoteConfig = Firebase.remoteConfig - - /** - * If you want to change the interval time to fetch, please change it here - */ - init { - CoroutineScope(Dispatchers.IO).launch { - firebaseRemoteConfig.settings { - minimumFetchIntervalInSeconds = 1 * 60 - } - } - } +@Singleton +class DefaultRemoteConfigApi @Inject constructor( + private val firebaseRemoteConfig: FirebaseRemoteConfig, +) : RemoteConfigApi { override suspend fun getBoolean(key: String): Boolean { - firebaseRemoteConfig.fetchAndActivate() + fetchConfig() return firebaseRemoteConfig[key] } override suspend fun getString(key: String): String { - firebaseRemoteConfig.fetchAndActivate() + fetchConfig() return firebaseRemoteConfig[key] } + + private suspend fun fetchConfig() { + try { + firebaseRemoteConfig.fetchAndActivate() + } catch (e: Exception) { + // handle or log exception + } + } } diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigInitializer.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigInitializer.kt new file mode 100644 index 000000000..14d095ab5 --- /dev/null +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigInitializer.kt @@ -0,0 +1,16 @@ +package io.github.droidkaigi.confsched2023.data.remoteconfig + +import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfig +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class RemoteConfigInitializer @Inject constructor( + private val firebaseRemoteConfig: FirebaseRemoteConfig, +) { + suspend fun initialize() { + firebaseRemoteConfig.settings { + minimumFetchIntervalInSeconds = 1 * 60 // 1 hour in seconds + } + } +} From dcd5b8aeab91256b437ebcc7d30f340c73858b70 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Sun, 27 Aug 2023 19:25:45 +0900 Subject: [PATCH 06/15] Minor changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 軽微な変更 --- .../droidkaigi/confsched2023/data/di/ApiModule.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt index c7caf005a..f024b9b28 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt @@ -129,6 +129,11 @@ class AuthenticatorModule { @InstallIn(SingletonComponent::class) @Module class RemoteConfigModule { + @Provides + @Singleton + fun provideFirebaseRemoteConfig(): FirebaseRemoteConfig { + return Firebase.remoteConfig + } @Provides @Singleton fun provideRemoteConfigApi( @@ -138,10 +143,4 @@ class RemoteConfigModule { firebaseRemoteConfig = firebaseRemoteConfig ) } - - @Provides - @Singleton - fun provideFirebaseRemoteConfig(): FirebaseRemoteConfig { - return Firebase.remoteConfig - } } From 5d6434cffc4fb758f51f84bc382d5c0581363081 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Sun, 27 Aug 2023 19:32:31 +0900 Subject: [PATCH 07/15] Delete unwanted logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 不要なログの削除 --- .../droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt index 53c318d86..010844f47 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt @@ -1,6 +1,5 @@ package io.github.droidkaigi.confsched2023.stamps -import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel @@ -44,8 +43,6 @@ class StampsScreenViewModel @Inject constructor( stampLottieRawResStateFlow, stampDetailDescriptionStateFlow, ) { rawRes, detailDescription -> - Log.d("StampsScreenViewModel", "rawRes: $rawRes") - Log.d("StampsScreenViewModel", "detailDescription: $detailDescription") StampsScreenUiState( lottieRawRes = rawRes, stamps = persistentListOf( From a8ae450729c20964bffeb4bc95695158c81ac02f Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Sun, 27 Aug 2023 19:43:49 +0900 Subject: [PATCH 08/15] Correction by linter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit リンターによる修正 --- .../io/github/droidkaigi/confsched2023/data/di/ApiModule.kt | 3 ++- .../confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt index f024b9b28..7c50119cd 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt @@ -134,13 +134,14 @@ class RemoteConfigModule { fun provideFirebaseRemoteConfig(): FirebaseRemoteConfig { return Firebase.remoteConfig } + @Provides @Singleton fun provideRemoteConfigApi( firebaseRemoteConfig: FirebaseRemoteConfig, ): RemoteConfigApi { return DefaultRemoteConfigApi( - firebaseRemoteConfig = firebaseRemoteConfig + firebaseRemoteConfig = firebaseRemoteConfig, ) } } diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt index 66e2c8b37..93ae947f1 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -1,5 +1,6 @@ package io.github.droidkaigi.confsched2023.data.remoteconfig +import co.touchlab.kermit.Logger import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfig import dev.gitlive.firebase.remoteconfig.get import javax.inject.Inject @@ -24,7 +25,7 @@ class DefaultRemoteConfigApi @Inject constructor( try { firebaseRemoteConfig.fetchAndActivate() } catch (e: Exception) { - // handle or log exception + Logger.e(e.message ?: "FirebaseRemoteConfig fetchAndActivate failed") } } } From 9ceae5528c4f41b775b8dc617b7572e04be2ae41 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Mon, 28 Aug 2023 00:44:09 +0900 Subject: [PATCH 09/15] Change in initialization method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 初期化方法の変更 --- .../io/github/droidkaigi/confsched2023/App.kt | 14 +--------- .../confsched2023/data/di/ApiModule.kt | 16 ++---------- .../remoteconfig/DefaultRemoteConfigApi.kt | 26 ++++++++++++++----- 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/app-android/src/main/java/io/github/droidkaigi/confsched2023/App.kt b/app-android/src/main/java/io/github/droidkaigi/confsched2023/App.kt index a8ccf4043..92942b1bf 100644 --- a/app-android/src/main/java/io/github/droidkaigi/confsched2023/App.kt +++ b/app-android/src/main/java/io/github/droidkaigi/confsched2023/App.kt @@ -2,18 +2,6 @@ package io.github.droidkaigi.confsched2023 import android.app.Application import dagger.hilt.android.HiltAndroidApp -import io.github.droidkaigi.confsched2023.data.remoteconfig.RemoteConfigInitializer -import kotlinx.coroutines.runBlocking -import javax.inject.Inject @HiltAndroidApp -class App : Application() { - @Inject lateinit var remoteConfigInitializer: RemoteConfigInitializer - - override fun onCreate() { - super.onCreate() - runBlocking { - remoteConfigInitializer.initialize() - } - } -} +class App : Application() diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt index 7c50119cd..52bac68d9 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt @@ -5,9 +5,6 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import de.jensklingenberg.ktorfit.Ktorfit -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfig -import dev.gitlive.firebase.remoteconfig.remoteConfig import io.github.droidkaigi.confsched2023.data.NetworkService import io.github.droidkaigi.confsched2023.data.auth.AndroidAuthenticator import io.github.droidkaigi.confsched2023.data.auth.AuthApi @@ -129,19 +126,10 @@ class AuthenticatorModule { @InstallIn(SingletonComponent::class) @Module class RemoteConfigModule { - @Provides - @Singleton - fun provideFirebaseRemoteConfig(): FirebaseRemoteConfig { - return Firebase.remoteConfig - } @Provides @Singleton - fun provideRemoteConfigApi( - firebaseRemoteConfig: FirebaseRemoteConfig, - ): RemoteConfigApi { - return DefaultRemoteConfigApi( - firebaseRemoteConfig = firebaseRemoteConfig, - ) + fun provideRemoteConfigApi(): RemoteConfigApi { + return DefaultRemoteConfigApi() } } diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt index 93ae947f1..0cf631c81 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -1,15 +1,27 @@ package io.github.droidkaigi.confsched2023.data.remoteconfig import co.touchlab.kermit.Logger -import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfig +import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.remoteconfig.get -import javax.inject.Inject -import javax.inject.Singleton +import dev.gitlive.firebase.remoteconfig.remoteConfig +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch -@Singleton -class DefaultRemoteConfigApi @Inject constructor( - private val firebaseRemoteConfig: FirebaseRemoteConfig, -) : RemoteConfigApi { +class DefaultRemoteConfigApi : RemoteConfigApi { + + private val firebaseRemoteConfig = Firebase.remoteConfig + + /** + * If you want to change the interval time to fetch, please change it here + */ + init { + CoroutineScope(Dispatchers.IO).launch { + firebaseRemoteConfig.settings { + minimumFetchIntervalInSeconds = 1 * 60 + } + } + } override suspend fun getBoolean(key: String): Boolean { fetchConfig() From 4735f709849deb177dd2d75382c90df7b4559616 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Mon, 28 Aug 2023 00:56:06 +0900 Subject: [PATCH 10/15] Change in initialization method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 初期化方法の変更 --- .../data/remoteconfig/DefaultRemoteConfigApi.kt | 17 +++++++---------- .../remoteconfig/RemoteConfigInitializer.kt | 16 ---------------- 2 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigInitializer.kt diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt index 0cf631c81..31c44e318 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -4,9 +4,6 @@ import co.touchlab.kermit.Logger import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.remoteconfig.get import dev.gitlive.firebase.remoteconfig.remoteConfig -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch class DefaultRemoteConfigApi : RemoteConfigApi { @@ -15,13 +12,13 @@ class DefaultRemoteConfigApi : RemoteConfigApi { /** * If you want to change the interval time to fetch, please change it here */ - init { - CoroutineScope(Dispatchers.IO).launch { - firebaseRemoteConfig.settings { - minimumFetchIntervalInSeconds = 1 * 60 - } - } - } +// init { +// CoroutineScope(Dispatchers.IO).launch { +// firebaseRemoteConfig.settings { +// minimumFetchIntervalInSeconds = 1 * 60 +// } +// } +// } override suspend fun getBoolean(key: String): Boolean { fetchConfig() diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigInitializer.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigInitializer.kt deleted file mode 100644 index 14d095ab5..000000000 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/RemoteConfigInitializer.kt +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.droidkaigi.confsched2023.data.remoteconfig - -import dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfig -import javax.inject.Inject -import javax.inject.Singleton - -@Singleton -class RemoteConfigInitializer @Inject constructor( - private val firebaseRemoteConfig: FirebaseRemoteConfig, -) { - suspend fun initialize() { - firebaseRemoteConfig.settings { - minimumFetchIntervalInSeconds = 1 * 60 // 1 hour in seconds - } - } -} From ef8ba6e9a332e2f82546d7dde4316f62e7b2007b Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Wed, 30 Aug 2023 00:44:25 +0900 Subject: [PATCH 11/15] Data class creation with StampListUiState MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit StampListUiStateでデータクラス作成 --- .../confsched2023/stamps/StampsScreen.kt | 5 +++-- .../confsched2023/stamps/StampsScreenViewModel.kt | 15 ++++++++++++--- .../confsched2023/stamps/section/StampList.kt | 8 ++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt index 0674e3114..026cc6aaa 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt @@ -20,6 +20,7 @@ import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable import io.github.droidkaigi.confsched2023.model.Stamp import io.github.droidkaigi.confsched2023.stamps.section.StampList +import io.github.droidkaigi.confsched2023.stamps.section.StampListUiState import io.github.droidkaigi.confsched2023.ui.SnackbarMessageEffect import kotlinx.collections.immutable.ImmutableList @@ -70,7 +71,7 @@ fun StampsScreen( data class StampsScreenUiState( val lottieRawRes: Int?, val stamps: ImmutableList, - val detailDescription: String, + val stampListUiState: StampListUiState, ) @Composable @@ -90,7 +91,7 @@ private fun StampsScreen( StampList( stamps = uiState.stamps, - detailDescription = uiState.detailDescription, + uiState = uiState.stampListUiState, onStampsClick = onStampsClick, onReachAnimationEnd = onReachAnimationEnd, stampLottieRawId = stampLottieRawId, diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt index 010844f47..7aec5f343 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt @@ -7,6 +7,7 @@ import io.github.droidkaigi.confsched2023.data.contributors.StampRepository import io.github.droidkaigi.confsched2023.designsystem.strings.AppStrings import io.github.droidkaigi.confsched2023.feature.stamps.R import io.github.droidkaigi.confsched2023.model.Stamp +import io.github.droidkaigi.confsched2023.stamps.section.StampListUiState import io.github.droidkaigi.confsched2023.ui.UserMessageStateHolder import io.github.droidkaigi.confsched2023.ui.buildUiState import io.github.droidkaigi.confsched2023.ui.handleErrorAndRetry @@ -39,10 +40,18 @@ class StampsScreenViewModel @Inject constructor( private val stampLottieRawResStateFlow: MutableStateFlow = MutableStateFlow(null) + private val stampListState = buildUiState( + stampDetailDescriptionStateFlow, + ) { detailDescription -> + StampListUiState( + detailDescription = detailDescription, + ) + } + val uiState = buildUiState( stampLottieRawResStateFlow, - stampDetailDescriptionStateFlow, - ) { rawRes, detailDescription -> + stampListState, + ) { rawRes, stampListUiState -> StampsScreenUiState( lottieRawRes = rawRes, stamps = persistentListOf( @@ -77,7 +86,7 @@ class StampsScreenViewModel @Inject constructor( contentDescription = "StampE image", ), ), - detailDescription = detailDescription, + stampListUiState = stampListUiState, ) } diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt index b2e1e1bc7..9e91508ea 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt @@ -30,10 +30,14 @@ private const val StampListColumns = 2 private const val SingleItemSpanCount = 2 private const val DoubleItemSpanCount = 2 / 2 +data class StampListUiState( + val detailDescription: String, +) + @Composable fun StampList( + uiState: StampListUiState, stamps: ImmutableList, - detailDescription: String, @androidx.annotation.RawRes stampLottieRawId: Int?, onStampsClick: (Stamp) -> Unit, @@ -87,7 +91,7 @@ fun StampList( key = "stamps_header", span = { GridItemSpan(SingleItemSpanCount) }, ) { - StampsDetail(detailDescription) + StampsDetail(uiState.detailDescription) } items( items = stamps, From 5f7267ff3556721c3a5b995ed39b242835ba2c68 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Wed, 30 Aug 2023 00:50:49 +0900 Subject: [PATCH 12/15] Implement the swift side of RemoteConfigApiImpl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RemoteConfigApiImplのswift側を実装 --- app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift b/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift index c391352f5..da222b911 100644 --- a/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift +++ b/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift @@ -8,4 +8,9 @@ public class RemoteConfigApiImpl: RemoteConfigApi { bool: RemoteConfig.remoteConfig().configValue(forKey: key).boolValue ) } + public func getString(key: String) async throws -> KotlinString { + .init( + string: RemoteConfig.remoteConfig().configValue(forKey: key) + ) + } } From ed3fbf03c5b0aebd727f377e29f35b56834efbba Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Wed, 30 Aug 2023 01:35:42 +0900 Subject: [PATCH 13/15] Change the placement of STAMP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stampの置き場所を変更 --- .../confsched2023/stamps/StampsScreen.kt | 3 --- .../stamps/StampsScreenViewModel.kt | 20 +++++++++---------- .../confsched2023/stamps/section/StampList.kt | 6 +++--- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt index 026cc6aaa..0f9ac3ed7 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreen.kt @@ -22,7 +22,6 @@ import io.github.droidkaigi.confsched2023.model.Stamp import io.github.droidkaigi.confsched2023.stamps.section.StampList import io.github.droidkaigi.confsched2023.stamps.section.StampListUiState import io.github.droidkaigi.confsched2023.ui.SnackbarMessageEffect -import kotlinx.collections.immutable.ImmutableList const val stampsScreenRoute = "stamps" fun NavGraphBuilder.nestedStampsScreen( @@ -70,7 +69,6 @@ fun StampsScreen( data class StampsScreenUiState( val lottieRawRes: Int?, - val stamps: ImmutableList, val stampListUiState: StampListUiState, ) @@ -90,7 +88,6 @@ private fun StampsScreen( val layoutDirection = LocalLayoutDirection.current StampList( - stamps = uiState.stamps, uiState = uiState.stampListUiState, onStampsClick = onStampsClick, onReachAnimationEnd = onReachAnimationEnd, diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt index 7aec5f343..fcff21ea4 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/StampsScreenViewModel.kt @@ -44,16 +44,6 @@ class StampsScreenViewModel @Inject constructor( stampDetailDescriptionStateFlow, ) { detailDescription -> StampListUiState( - detailDescription = detailDescription, - ) - } - - val uiState = buildUiState( - stampLottieRawResStateFlow, - stampListState, - ) { rawRes, stampListUiState -> - StampsScreenUiState( - lottieRawRes = rawRes, stamps = persistentListOf( Stamp( hasDrawableResId = R.drawable.img_stamp_a_on, @@ -86,6 +76,16 @@ class StampsScreenViewModel @Inject constructor( contentDescription = "StampE image", ), ), + detailDescription = detailDescription, + ) + } + + val uiState = buildUiState( + stampLottieRawResStateFlow, + stampListState, + ) { rawRes, stampListUiState -> + StampsScreenUiState( + lottieRawRes = rawRes, stampListUiState = stampListUiState, ) } diff --git a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt index 9e91508ea..7be50df47 100644 --- a/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt +++ b/feature/stamps/src/main/java/io/github/droidkaigi/confsched2023/stamps/section/StampList.kt @@ -31,13 +31,13 @@ private const val SingleItemSpanCount = 2 private const val DoubleItemSpanCount = 2 / 2 data class StampListUiState( + val stamps: ImmutableList, val detailDescription: String, ) @Composable fun StampList( uiState: StampListUiState, - stamps: ImmutableList, @androidx.annotation.RawRes stampLottieRawId: Int?, onStampsClick: (Stamp) -> Unit, @@ -94,11 +94,11 @@ fun StampList( StampsDetail(uiState.detailDescription) } items( - items = stamps, + items = uiState.stamps, key = { stamp -> stamp.hasDrawableResId }, span = { stamp -> GridItemSpan( - if (stamp == stamps.last() && stamps.size % StampListColumns != 0) { + if (stamp == uiState.stamps.last() && uiState.stamps.size % StampListColumns != 0) { SingleItemSpanCount } else { DoubleItemSpanCount From 2639565d2f04474177c592dd55fe584115e803eb Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Wed, 30 Aug 2023 01:41:21 +0900 Subject: [PATCH 14/15] KotlinString to String --- app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift b/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift index da222b911..aeab345fd 100644 --- a/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift +++ b/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift @@ -8,7 +8,7 @@ public class RemoteConfigApiImpl: RemoteConfigApi { bool: RemoteConfig.remoteConfig().configValue(forKey: key).boolValue ) } - public func getString(key: String) async throws -> KotlinString { + public func getString(key: String) async throws -> String { .init( string: RemoteConfig.remoteConfig().configValue(forKey: key) ) From d0436920cf8b2b8c23bba154d92aaa5c2fabd9ae Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Wed, 30 Aug 2023 02:23:32 +0900 Subject: [PATCH 15/15] Fix RemoteConfigApiImpl --- app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift b/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift index aeab345fd..37a05ae2d 100644 --- a/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift +++ b/app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift @@ -9,8 +9,6 @@ public class RemoteConfigApiImpl: RemoteConfigApi { ) } public func getString(key: String) async throws -> String { - .init( - string: RemoteConfig.remoteConfig().configValue(forKey: key) - ) + return RemoteConfig.remoteConfig().configValue(forKey: key).stringValue ?? "" } }