Skip to content

Commit

Permalink
Merge pull request #122 from 2rabs/rt/add-schedule-detail-screen
Browse files Browse the repository at this point in the history
✨ スケジュール詳細画面を追加
  • Loading branch information
tatsutakein authored Dec 5, 2023
2 parents 8338340 + 6bbac97 commit 7545806
Show file tree
Hide file tree
Showing 19 changed files with 660 additions and 2 deletions.
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) {
}
}
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)
}
}
}
Loading

0 comments on commit 7545806

Please sign in to comment.