Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ スケジュール詳細画面を追加 #122

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/ios/Modules/Sources/Navigation/RootStateMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum Routing: Hashable {
case login
case top
case scheduleList
case scheduleDetail(scheduleId: String)
case settings
}

Expand Down
5 changes: 5 additions & 0 deletions app/ios/Modules/Sources/Navigation/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public struct RootView: View {
.ignoresSafeArea(.keyboard)
case .top:
ComposeTopScreen(
onRecentScheduleClicked: { scheduleId in
stateMachine.dispatch(intent: .routing(.scheduleDetail(scheduleId: scheduleId)))
},
onScheduleListButtonClick: {
stateMachine.dispatch(intent: .routing(.scheduleList))
},
Expand All @@ -36,6 +39,8 @@ public struct RootView: View {
.navigationBarBackButtonHidden(true)
case .scheduleList:
ComposeScheduleListScreen()
case .scheduleDetail(let scheduleId):
ComposeScheduleDetailScreen(scheduleId: scheduleId)
case .settings:
ComposeSettingsScreen()
}
Expand Down
28 changes: 28 additions & 0 deletions app/ios/Modules/Sources/Schedule/ComposeScheduleDetailScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import KmpContainer
import NitoKmp
import SwiftUI
import UIKit

public struct ComposeScheduleDetailScreen: UIViewControllerRepresentable {
private let scheduleId: String

public init(scheduleId: String) {
self.scheduleId = scheduleId
}

public func makeUIViewController(context: Context) -> UIViewController {
return ScheduleDetailScreen_iosKt.ScheduleDetailRouteViewController(
id: scheduleId,
stateMachine: ScheduleDetailStateMachine(
id: scheduleId,
fetchParticipantScheduleById: Container.shared.get(
type: FetchParticipantScheduleByIdUseCase.self),
userMessageStateHolder: Container.shared.get(type: UserMessageStateHolder.self),
dateTimeFormatter: Container.shared.get(type: CommonNitoDateFormatter.self)
)
)
}

public func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
Comment on lines +26 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateUIViewControllerメソッドが空です。これは、作成後にUIViewControllerを更新する必要がない場合に意図的なものかもしれませんが、もし将来的にUIViewControllerの状態を更新する必要が生じた場合に備えて、このメソッドの実装を検討するか、またはコメントを追加してその目的を明確にすることをお勧めします。

}
1 change: 0 additions & 1 deletion app/ios/Modules/Sources/Schedule/Schedule.swift

This file was deleted.

4 changes: 4 additions & 0 deletions app/ios/Modules/Sources/Top/ComposeTopScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import SwiftUI
import UIKit

public struct ComposeTopScreen: UIViewControllerRepresentable {
private let onRecentScheduleClicked: (String) -> Void
private let onScheduleListButtonClick: () -> Void
private let onSettingsButtonClick: () -> Void

public init(
onRecentScheduleClicked: @escaping (String) -> Void,
onScheduleListButtonClick: @escaping () -> Void,
onSettingsButtonClick: @escaping () -> Void
) {
self.onRecentScheduleClicked = onRecentScheduleClicked
self.onScheduleListButtonClick = onScheduleListButtonClick
self.onSettingsButtonClick = onSettingsButtonClick
}
Expand All @@ -22,6 +25,7 @@ public struct ComposeTopScreen: UIViewControllerRepresentable {
userMessageStateHolder: Container.shared.get(type: UserMessageStateHolder.self),
dateTimeFormatter: Container.shared.get(type: CommonNitoDateFormatter.self)
),
onRecentScheduleClicked: onRecentScheduleClicked,
onScheduleListClick: onScheduleListButtonClick,
onSettingsClick: onSettingsButtonClick
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import club.nito.core.model.AuthStatus
import club.nito.feature.auth.loginNavigationRoute
import club.nito.feature.auth.loginScreen
import club.nito.feature.auth.navigateToLogin
import club.nito.feature.schedule.detail.navigateToScheduleDetail
import club.nito.feature.schedule.detail.scheduleDetailScreen
import club.nito.feature.schedule.list.navigateToScheduleList
import club.nito.feature.schedule.list.scheduleListScreen
import club.nito.feature.settings.navigateToSettings
Expand Down Expand Up @@ -41,6 +43,7 @@ fun NitoNavHost(
)

topScreen(
onRecentScheduleClicked = navigator::navigateToScheduleDetail,
onScheduleListClick = navigator::navigateToScheduleList,
onSettingsClick = navigator::navigateToSettings,
)
Expand All @@ -57,6 +60,7 @@ fun NitoNavHost(
},
)
scheduleListScreen()
scheduleDetailScreen()
settingsScreen(
onSignedOut = {
navigator.navigateToLogin(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package club.nito.feature.schedule.detail

public sealed class ScheduleDetailEvent {
public data class NavigateToScheduleDetail(val scheduleId: String) : ScheduleDetailEvent()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package club.nito.feature.schedule.detail

import club.nito.core.domain.model.ParticipantSchedule

public sealed class ScheduleDetailIntent {
public data class ClickParticipate(val schedule: ParticipantSchedule) : ScheduleDetailIntent()
public data class ClickParticipateSchedule(val schedule: ParticipantSchedule) : ScheduleDetailIntent()
public data object ClickDismissConfirmParticipateDialog : ScheduleDetailIntent()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package club.nito.feature.schedule.detail

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
import moe.tlaster.precompose.navigation.path

private const val ROUTE: String = "/schedules"

public fun Navigator.navigateToScheduleDetail(
id: ScheduleId,
navOptions: NavOptions? = null,
) {
this.navigate("$ROUTE/$id", navOptions)
}

public fun RouteBuilder.scheduleDetailScreen() {
scene(
route = "$ROUTE/{id}",
) { backStackEntry ->
backStackEntry.path<String>("id")?.let { id ->
ScheduleDetailRoute(id = id)
}
Comment on lines +22 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

エラーハンドリングの追加を検討してください。backStackEntry.path<String>("id")がnullを返す場合、ScheduleDetailRouteが呼び出されない状況が発生する可能性があります。nullの場合に適切なフィードバックやログを提供することが重要です。

backStackEntry.path<String>("id")?.let { id ->
    ScheduleDetailRoute(id = id)
} ?: run {
    // 適切なエラーハンドリングをここに追加する
}

}
}
Loading