Skip to content

Commit

Permalink
Navigate to courses screen from home
Browse files Browse the repository at this point in the history
  • Loading branch information
X1nto committed Nov 1, 2024
1 parent 4aa3b85 commit 22e29ef
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions iosApp/Argos/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ struct HomeScreen: View {

var body: some View {
_HomeScreen(
state: viewModel.state
state: viewModel.state,
courseScreen: { courseId in
CourseScreen(courseId: courseId)
}
)
}
}
Expand All @@ -56,13 +59,15 @@ enum HomeScreenState {
case error
}

struct _HomeScreen: View {
struct _HomeScreen<CourseScreen: View>: View {
let state: HomeScreenState
let courseScreen: (String) -> CourseScreen

@State private var selectedDay: Int

init(state: HomeScreenState) {
init(state: HomeScreenState, courseScreen: @escaping (String) -> CourseScreen) {
self.state = state
self.courseScreen = courseScreen

if case let .success(selectedDay, _) = state {
self.selectedDay = selectedDay
Expand All @@ -83,7 +88,7 @@ struct _HomeScreen: View {
ForEach(lecturesByDay[day]!, id: \.hashValue) { lecture in
NavigationLink(
destination: {

courseScreen(lecture.id)
}
) {
VStack(alignment: .leading) {
Expand Down

0 comments on commit 22e29ef

Please sign in to comment.