From 06dc4265b61fd5d03a63fed04d56698e2788705e Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Thu, 23 Nov 2023 11:39:17 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:=20schedule=20=E3=83=A2=E3=82=B8?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=AB=20explicitApi=20=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/schedule/build.gradle.kts | 2 ++ .../feature/schedule/ScheduleListEvent.kt | 4 ++-- .../feature/schedule/ScheduleListIntent.kt | 8 +++---- .../schedule/ScheduleListScreenUiState.kt | 8 +++---- .../feature/schedule/ScheduleListViewModel.kt | 21 ++++++++++++------- .../feature/schedule/ScheduleNavigation.kt | 6 +++--- .../nito/feature/schedule/ScheduleScreen.kt | 2 +- .../schedule/di/ScheduleFeatureModule.kt | 2 +- 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/feature/schedule/build.gradle.kts b/feature/schedule/build.gradle.kts index a8962e7b..4b6835e7 100644 --- a/feature/schedule/build.gradle.kts +++ b/feature/schedule/build.gradle.kts @@ -8,6 +8,8 @@ plugins { android.namespace = "club.nito.feature.schedule" kotlin { + explicitApi() + sourceSets { commonMain { dependencies { diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListEvent.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListEvent.kt index aea4d703..056601aa 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListEvent.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListEvent.kt @@ -1,5 +1,5 @@ package club.nito.feature.schedule -sealed class ScheduleListEvent { - data class NavigateToScheduleDetail(val scheduleId: String) : ScheduleListEvent() +public sealed class ScheduleListEvent { + public data class NavigateToScheduleDetail(val scheduleId: String) : ScheduleListEvent() } diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListIntent.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListIntent.kt index eae9d826..abdd113a 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListIntent.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListIntent.kt @@ -2,8 +2,8 @@ package club.nito.feature.schedule import club.nito.core.domain.model.ParticipantSchedule -sealed class ScheduleListIntent { - data class ClickShowConfirmParticipateDialog(val schedule: ParticipantSchedule) : ScheduleListIntent() - data class ClickParticipateSchedule(val schedule: ParticipantSchedule) : ScheduleListIntent() - data object ClickDismissConfirmParticipateDialog : ScheduleListIntent() +public sealed class ScheduleListIntent { + public data class ClickShowConfirmParticipateDialog(val schedule: ParticipantSchedule) : ScheduleListIntent() + public data class ClickParticipateSchedule(val schedule: ParticipantSchedule) : ScheduleListIntent() + public data object ClickDismissConfirmParticipateDialog : ScheduleListIntent() } diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListScreenUiState.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListScreenUiState.kt index 5c450f36..28244bed 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListScreenUiState.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListScreenUiState.kt @@ -4,13 +4,13 @@ import club.nito.core.common.NitoDateTimeFormatter import club.nito.core.domain.model.ParticipantSchedule import club.nito.core.model.FetchMultipleContentResult -data class ScheduleListScreenUiState( +public data class ScheduleListScreenUiState( val dateTimeFormatter: NitoDateTimeFormatter, val scheduleList: FetchMultipleContentResult, val confirmParticipateDialog: ConfirmParticipateDialogUiState, ) -sealed class ConfirmParticipateDialogUiState { - data class Show(val schedule: ParticipantSchedule) : ConfirmParticipateDialogUiState() - data object Hide : ConfirmParticipateDialogUiState() +public sealed class ConfirmParticipateDialogUiState { + public data class Show(val schedule: ParticipantSchedule) : ConfirmParticipateDialogUiState() + public data object Hide : ConfirmParticipateDialogUiState() } diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListViewModel.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListViewModel.kt index 48ef5fb9..a13c3187 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListViewModel.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleListViewModel.kt @@ -16,9 +16,9 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import moe.tlaster.precompose.viewmodel.viewModelScope -class ScheduleListViewModel internal constructor( +public class ScheduleListViewModel internal constructor( getParticipantScheduleListUseCase: GetParticipantScheduleListUseCase, - val userMessageStateHolder: UserMessageStateHolder, + public val userMessageStateHolder: UserMessageStateHolder, private val dateTimeFormatter: NitoDateTimeFormatter, ) : StateMachine(), UserMessageStateHolder by userMessageStateHolder { @@ -30,7 +30,7 @@ class ScheduleListViewModel internal constructor( initialValue = FetchMultipleContentResult.Loading, ) - val uiState: StateFlow = buildUiState( + public val uiState: StateFlow = buildUiState( showConfirmParticipateSchedule, scheduleList, ) { showConfirmParticipateSchedule, scheduleList -> @@ -44,12 +44,15 @@ class ScheduleListViewModel internal constructor( } private val _events = MutableStateFlow>(emptyList()) - val event: Flow = _events.map { it.firstOrNull() } + public val event: Flow = _events.map { it.firstOrNull() } - fun dispatch(intent: ScheduleListIntent) { + public fun dispatch(intent: ScheduleListIntent) { viewModelScope.launch { when (intent) { - is ScheduleListIntent.ClickShowConfirmParticipateDialog -> showConfirmParticipateSchedule.emit(intent.schedule) + is ScheduleListIntent.ClickShowConfirmParticipateDialog -> { + showConfirmParticipateSchedule.emit(intent.schedule) + } + is ScheduleListIntent.ClickParticipateSchedule -> { showConfirmParticipateSchedule.emit(null) @@ -57,12 +60,14 @@ class ScheduleListViewModel internal constructor( userMessageStateHolder.showMessage("$scheduledAt に参加登録しました 🎉") } - ScheduleListIntent.ClickDismissConfirmParticipateDialog -> showConfirmParticipateSchedule.emit(null) + ScheduleListIntent.ClickDismissConfirmParticipateDialog -> { + showConfirmParticipateSchedule.emit(null) + } } } } - fun consume(event: ScheduleListEvent) { + public fun consume(event: ScheduleListEvent) { viewModelScope.launch { _events.emit(_events.value.filterNot { it == event }) } diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleNavigation.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleNavigation.kt index ba05c906..896e4e28 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleNavigation.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleNavigation.kt @@ -4,13 +4,13 @@ import moe.tlaster.precompose.navigation.NavOptions import moe.tlaster.precompose.navigation.Navigator import moe.tlaster.precompose.navigation.RouteBuilder -const val scheduleNavigationRoute = "schedule_route" +public const val scheduleNavigationRoute: String = "schedule_route" -fun Navigator.navigateToSchedule(navOptions: NavOptions? = null) { +public fun Navigator.navigateToSchedule(navOptions: NavOptions? = null) { this.navigate(scheduleNavigationRoute, navOptions) } -fun RouteBuilder.scheduleScreen() { +public fun RouteBuilder.scheduleScreen() { scene( route = scheduleNavigationRoute, ) { diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleScreen.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleScreen.kt index 60f5c24f..2f36ef0c 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleScreen.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/ScheduleScreen.kt @@ -21,7 +21,7 @@ import club.nito.core.ui.message.SnackbarMessageEffect import club.nito.feature.schedule.component.ScheduleListSection @Composable -fun ScheduleRoute( +public fun ScheduleRoute( viewModel: ScheduleListViewModel = koinStateMachine(), ) { viewModel.event.collectAsState(initial = null).value?.let { diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/di/ScheduleFeatureModule.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/di/ScheduleFeatureModule.kt index f40c112a..09c0b65c 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/di/ScheduleFeatureModule.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/di/ScheduleFeatureModule.kt @@ -4,7 +4,7 @@ import club.nito.feature.schedule.ScheduleListViewModel import org.koin.core.module.Module import org.koin.dsl.module -val scheduleFeatureModule: Module = module { +public val scheduleFeatureModule: Module = module { factory { ScheduleListViewModel( getParticipantScheduleListUseCase = get(),