From 2bba8e70664a5519c51105daa2931f71b690b7e9 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 21:23:42 +0900 Subject: [PATCH 1/4] =?UTF-8?q?:books:=20=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commonMain/kotlin/club/nito/feature/top/TopScreenEvent.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/top/src/commonMain/kotlin/club/nito/feature/top/TopScreenEvent.kt b/feature/top/src/commonMain/kotlin/club/nito/feature/top/TopScreenEvent.kt index 526de9f6..6bef9e46 100644 --- a/feature/top/src/commonMain/kotlin/club/nito/feature/top/TopScreenEvent.kt +++ b/feature/top/src/commonMain/kotlin/club/nito/feature/top/TopScreenEvent.kt @@ -4,7 +4,7 @@ import club.nito.core.model.schedule.ScheduleId public sealed class TopScreenEvent { /** - * Navigate to schedule list screen + * Navigate to schedule detail screen */ public data class OnRecentScheduleClicked(val scheduleId: ScheduleId) : TopScreenEvent() From e852ae317170d9624098fc1dad09dac1aaca37a8 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 21:32:26 +0900 Subject: [PATCH 2/4] =?UTF-8?q?:wastebasket:=20navigationIcon=20=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nito/feature/schedule/detail/ScheduleDetailScreen.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailScreen.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailScreen.kt index c3fde71f..137e272e 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailScreen.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailScreen.kt @@ -24,7 +24,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Send import androidx.compose.material3.CircularProgressIndicator @@ -123,11 +122,6 @@ private fun ScheduleDetailScreen( text = "スケジュール詳細", ) }, - navigationIcon = { - IconButton(onClick = { }) { - Icon(Icons.Default.ArrowBack, contentDescription = "Back") - } - }, ) }, snackbarHost = { SnackbarHost(snackbarHostState) }, From 49e8497579477fd4e0935851e4caab8decb8a272 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 21:43:42 +0900 Subject: [PATCH 3/4] =?UTF-8?q?:sparkles:=20=E3=82=B9=E3=82=B1=E3=82=B8?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=83=AB=E4=B8=80=E8=A6=A7=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E3=81=8B=E3=82=89=E8=A9=B3=E7=B4=B0=E7=94=BB=E9=9D=A2=E3=81=B8?= =?UTF-8?q?=E3=81=AE=E7=94=BB=E9=9D=A2=E9=81=B7=E7=A7=BB=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ios/Modules/Sources/Navigation/RootView.swift | 6 +++++- .../Sources/Schedule/ComposeScheduleListScreen.swift | 11 +++++++++-- .../kotlin/club/nito/app/shared/NitoNavHost.kt | 4 +++- .../nito/feature/schedule/list/ScheduleListEvent.kt | 5 ++++- .../nito/feature/schedule/list/ScheduleListScreen.kt | 4 +++- .../feature/schedule/list/ScheduleListStateMachine.kt | 2 +- .../nito/feature/schedule/list/ScheduleNavigation.kt | 9 +++++++-- .../feature/schedule/list/ScheduleListScreen.ios.kt | 3 +++ 8 files changed, 35 insertions(+), 9 deletions(-) diff --git a/app/ios/Modules/Sources/Navigation/RootView.swift b/app/ios/Modules/Sources/Navigation/RootView.swift index 1d66dcac..4919a6ec 100644 --- a/app/ios/Modules/Sources/Navigation/RootView.swift +++ b/app/ios/Modules/Sources/Navigation/RootView.swift @@ -38,7 +38,11 @@ public struct RootView: View { ) .navigationBarBackButtonHidden(true) case .scheduleList: - ComposeScheduleListScreen() + ComposeScheduleListScreen( + onScheduleItemClick: { scheduleId in + stateMachine.dispatch(intent: .routing(.scheduleDetail(scheduleId: scheduleId))) + } + ) case .scheduleDetail(let scheduleId): ComposeScheduleDetailScreen(scheduleId: scheduleId) case .settings: diff --git a/app/ios/Modules/Sources/Schedule/ComposeScheduleListScreen.swift b/app/ios/Modules/Sources/Schedule/ComposeScheduleListScreen.swift index 81ec7727..987cbd48 100644 --- a/app/ios/Modules/Sources/Schedule/ComposeScheduleListScreen.swift +++ b/app/ios/Modules/Sources/Schedule/ComposeScheduleListScreen.swift @@ -4,7 +4,13 @@ import SwiftUI import UIKit public struct ComposeScheduleListScreen: UIViewControllerRepresentable { - public init() {} + private let onScheduleItemClick: (String) -> Void + + public init( + onScheduleItemClick: @escaping (String) -> Void + ) { + self.onScheduleItemClick = onScheduleItemClick + } public func makeUIViewController(context: Context) -> UIViewController { return ScheduleListScreen_iosKt.ScheduleListRouteViewController( @@ -13,7 +19,8 @@ public struct ComposeScheduleListScreen: UIViewControllerRepresentable { type: GetParticipantScheduleListUseCase.self), userMessageStateHolder: Container.shared.get(type: UserMessageStateHolder.self), dateFormatter: Container.shared.get(type: CommonNitoDateFormatter.self) - ) + ), + onScheduleItemClick: onScheduleItemClick ) } diff --git a/app/shared/src/commonMain/kotlin/club/nito/app/shared/NitoNavHost.kt b/app/shared/src/commonMain/kotlin/club/nito/app/shared/NitoNavHost.kt index 3033cc6d..ce2b50b2 100644 --- a/app/shared/src/commonMain/kotlin/club/nito/app/shared/NitoNavHost.kt +++ b/app/shared/src/commonMain/kotlin/club/nito/app/shared/NitoNavHost.kt @@ -59,7 +59,9 @@ fun NitoNavHost( ) }, ) - scheduleListScreen() + scheduleListScreen( + onScheduleItemClick = navigator::navigateToScheduleDetail, + ) scheduleDetailScreen() settingsScreen( onSignedOut = { diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListEvent.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListEvent.kt index 084af630..9fba136b 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListEvent.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListEvent.kt @@ -1,5 +1,8 @@ package club.nito.feature.schedule.list public sealed class ScheduleListEvent { - public data class NavigateToScheduleDetail(val scheduleId: String) : ScheduleListEvent() + /** + * Navigate to schedule detail screen + */ + public data class OnScheduleItemClick(val scheduleId: String) : ScheduleListEvent() } diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListScreen.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListScreen.kt index 392bcd95..68544be1 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListScreen.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListScreen.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.Modifier import club.nito.core.designsystem.component.CenterAlignedTopAppBar import club.nito.core.designsystem.component.Scaffold import club.nito.core.designsystem.component.Text +import club.nito.core.model.schedule.ScheduleId import club.nito.core.ui.ConfirmParticipateDialog import club.nito.core.ui.koinStateMachine import club.nito.core.ui.message.SnackbarMessageEffect @@ -23,11 +24,12 @@ import club.nito.feature.schedule.component.ScheduleListSection @Composable public fun ScheduleListRoute( stateMachine: ScheduleListStateMachine = koinStateMachine(ScheduleListStateMachine::class), + onScheduleItemClick: (ScheduleId) -> Unit = {}, ) { stateMachine.event.collectAsState(initial = null).value?.let { LaunchedEffect(it.hashCode()) { when (it) { - is ScheduleListEvent.NavigateToScheduleDetail -> {} + is ScheduleListEvent.OnScheduleItemClick -> onScheduleItemClick(it.scheduleId) } stateMachine.consume(it) } diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListStateMachine.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListStateMachine.kt index fdcc9255..e083738b 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListStateMachine.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleListStateMachine.kt @@ -50,7 +50,7 @@ public class ScheduleListStateMachine( viewModelScope.launch { when (intent) { is ScheduleListIntent.ClickShowConfirmParticipateDialog -> { - showConfirmParticipateSchedule.emit(intent.schedule) + _events.emit(_events.value + ScheduleListEvent.OnScheduleItemClick(intent.schedule.id)) } is ScheduleListIntent.ClickParticipateSchedule -> { diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleNavigation.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleNavigation.kt index 025d3075..b6061b4a 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleNavigation.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/list/ScheduleNavigation.kt @@ -1,5 +1,6 @@ package club.nito.feature.schedule.list +import club.nito.core.model.schedule.ScheduleId import moe.tlaster.precompose.navigation.NavOptions import moe.tlaster.precompose.navigation.Navigator import moe.tlaster.precompose.navigation.RouteBuilder @@ -10,10 +11,14 @@ public fun Navigator.navigateToScheduleList(navOptions: NavOptions? = null) { this.navigate(scheduleNavigationRoute, navOptions) } -public fun RouteBuilder.scheduleListScreen() { +public fun RouteBuilder.scheduleListScreen( + onScheduleItemClick: (ScheduleId) -> Unit = {}, +) { scene( route = scheduleNavigationRoute, ) { - ScheduleListRoute() + ScheduleListRoute( + onScheduleItemClick = onScheduleItemClick, + ) } } diff --git a/feature/schedule/src/iosMain/kotlin/club/nito/feature/schedule/list/ScheduleListScreen.ios.kt b/feature/schedule/src/iosMain/kotlin/club/nito/feature/schedule/list/ScheduleListScreen.ios.kt index cb034c36..1aa2a315 100644 --- a/feature/schedule/src/iosMain/kotlin/club/nito/feature/schedule/list/ScheduleListScreen.ios.kt +++ b/feature/schedule/src/iosMain/kotlin/club/nito/feature/schedule/list/ScheduleListScreen.ios.kt @@ -2,15 +2,18 @@ package club.nito.feature.schedule.list import androidx.compose.ui.window.ComposeUIViewController import club.nito.core.designsystem.theme.NitoTheme +import club.nito.core.model.schedule.ScheduleId import platform.UIKit.UIViewController @Suppress("FunctionName") public fun ScheduleListRouteViewController( stateMachine: ScheduleListStateMachine, + onScheduleItemClick: (ScheduleId) -> Unit = {}, ): UIViewController = ComposeUIViewController { NitoTheme { ScheduleListRoute( stateMachine = stateMachine, + onScheduleItemClick = onScheduleItemClick, ) } } From ba3e831c3f8226a9019d9a40cb118d075b636a92 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Tue, 5 Dec 2023 21:51:33 +0900 Subject: [PATCH 4/4] =?UTF-8?q?:sparkles:=20=E5=8F=82=E5=8A=A0=E8=A1=A8?= =?UTF-8?q?=E6=98=8E=E5=87=A6=E7=90=86=E3=81=AE=E5=AE=9F=E8=A3=85=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 --- .../Sources/Schedule/ComposeScheduleDetailScreen.swift | 1 + .../participation/model/NetworkParticipantDeclaration.kt | 8 ++++---- .../feature/schedule/detail/ScheduleDetailStateMachine.kt | 6 +++++- .../nito/feature/schedule/di/ScheduleFeatureModule.kt | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/ios/Modules/Sources/Schedule/ComposeScheduleDetailScreen.swift b/app/ios/Modules/Sources/Schedule/ComposeScheduleDetailScreen.swift index fffe0ef3..6c2d843e 100644 --- a/app/ios/Modules/Sources/Schedule/ComposeScheduleDetailScreen.swift +++ b/app/ios/Modules/Sources/Schedule/ComposeScheduleDetailScreen.swift @@ -17,6 +17,7 @@ public struct ComposeScheduleDetailScreen: UIViewControllerRepresentable { id: scheduleId, fetchParticipantScheduleById: Container.shared.get( type: FetchParticipantScheduleByIdUseCase.self), + participate: Container.shared.get(type: ParticipateUseCase.self), userMessageStateHolder: Container.shared.get(type: UserMessageStateHolder.self), dateTimeFormatter: Container.shared.get(type: CommonNitoDateFormatter.self) ) diff --git a/core/network/src/commonMain/kotlin/club/nito/core/network/participation/model/NetworkParticipantDeclaration.kt b/core/network/src/commonMain/kotlin/club/nito/core/network/participation/model/NetworkParticipantDeclaration.kt index 44f6b285..84dbd379 100644 --- a/core/network/src/commonMain/kotlin/club/nito/core/network/participation/model/NetworkParticipantDeclaration.kt +++ b/core/network/src/commonMain/kotlin/club/nito/core/network/participation/model/NetworkParticipantDeclaration.kt @@ -5,14 +5,14 @@ import kotlinx.serialization.Serializable @Serializable internal data class NetworkParticipantDeclaration( - val scheduleId: Long, - val memberId: Long, + val scheduleId: String, + val userId: String, val comment: String, ) internal fun ParticipantDeclaration.toNetworkModel(): NetworkParticipantDeclaration = NetworkParticipantDeclaration( - scheduleId = scheduleId.toLong(), - memberId = memberId.toLong(), + scheduleId = scheduleId, + userId = memberId, comment = comment, ) diff --git a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailStateMachine.kt b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailStateMachine.kt index baf30b7d..2bcb6c31 100644 --- a/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailStateMachine.kt +++ b/feature/schedule/src/commonMain/kotlin/club/nito/feature/schedule/detail/ScheduleDetailStateMachine.kt @@ -2,6 +2,7 @@ package club.nito.feature.schedule.detail import club.nito.core.common.NitoDateFormatter import club.nito.core.domain.FetchParticipantScheduleByIdUseCase +import club.nito.core.domain.ParticipateUseCase import club.nito.core.domain.model.ParticipantSchedule import club.nito.core.model.FetchSingleContentResult import club.nito.core.model.schedule.ScheduleId @@ -18,6 +19,7 @@ import moe.tlaster.precompose.viewmodel.viewModelScope public class ScheduleDetailStateMachine( id: ScheduleId, fetchParticipantScheduleById: FetchParticipantScheduleByIdUseCase, + private val participate: ParticipateUseCase, public val userMessageStateHolder: UserMessageStateHolder, private val dateTimeFormatter: NitoDateFormatter, ) : StateMachine(), @@ -52,7 +54,9 @@ public class ScheduleDetailStateMachine( viewModelScope.launch { when (intent) { is ScheduleDetailIntent.ClickParticipate -> { - showConfirmParticipateSchedule.emit(intent.schedule) + participate(intent.schedule.id, "") + val scheduledAt = dateTimeFormatter.formatDateTime(intent.schedule.scheduledAt) + userMessageStateHolder.showMessage("$scheduledAt に参加登録しました 🎉") } is ScheduleDetailIntent.ClickParticipateSchedule -> { 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 1c480d68..9caaf50c 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 @@ -18,6 +18,7 @@ public val scheduleFeatureModule: Module = module { ScheduleDetailStateMachine( id = id, fetchParticipantScheduleById = get(), + participate = get(), userMessageStateHolder = get(), dateTimeFormatter = get(), )