From 6ee79d48446f44e3e82c622fda3f0ca0a46b631c Mon Sep 17 00:00:00 2001 From: ryoya ito Date: Wed, 11 Sep 2024 14:47:45 +0900 Subject: [PATCH] fix bug --- .../TimetableFeature/TimetableReducer.swift | 20 +++++++++---------- ...ableListView.swift => TimetableView.swift} | 8 +++----- 2 files changed, 12 insertions(+), 16 deletions(-) rename app-ios/Sources/TimetableFeature/{TimetableListView.swift => TimetableView.swift} (97%) diff --git a/app-ios/Sources/TimetableFeature/TimetableReducer.swift b/app-ios/Sources/TimetableFeature/TimetableReducer.swift index 37dcf5aae..bf995b052 100644 --- a/app-ios/Sources/TimetableFeature/TimetableReducer.swift +++ b/app-ios/Sources/TimetableFeature/TimetableReducer.swift @@ -13,6 +13,7 @@ public struct TimetableReducer : Sendable{ @ObservableState public struct State: Equatable { + var selectedDay: DayTab = .day1 var timetableItems: [TimetableTimeGroupItems] = [] //Should be simple objects public init(timetableItems: [TimetableTimeGroupItems] = []) { @@ -70,14 +71,13 @@ public struct TimetableReducer : Sendable{ case let .requestDay(dayTab): return .run { send in - let internalDay: DroidKaigi2024Day = switch dayTab { - case DayTab.day1: - DroidKaigi2024Day.conferenceDay1 - case DayTab.day2: - DroidKaigi2024Day.conferenceDay2 - } - for try await timetables in try timetableClient.streamTimetable() { + let internalDay: DroidKaigi2024Day = switch dayTab { + case DayTab.day1: + DroidKaigi2024Day.conferenceDay1 + case DayTab.day2: + DroidKaigi2024Day.conferenceDay2 + } await send(.response(.success(timetables.dayTimetable(droidKaigi2024Day: internalDay).contents))) } } @@ -92,7 +92,8 @@ public struct TimetableReducer : Sendable{ case .view(.timetableItemTapped), .view(.searchTapped): return .none case .view(.selectDay(let dayTab)): - + state.selectedDay = dayTab + return .run { send in await send(.requestDay(dayTab)) } @@ -113,6 +114,3 @@ public struct TimetableReducer : Sendable{ } } } - - - diff --git a/app-ios/Sources/TimetableFeature/TimetableListView.swift b/app-ios/Sources/TimetableFeature/TimetableView.swift similarity index 97% rename from app-ios/Sources/TimetableFeature/TimetableListView.swift rename to app-ios/Sources/TimetableFeature/TimetableView.swift index 9d9f0ab8a..a1c4a8070 100644 --- a/app-ios/Sources/TimetableFeature/TimetableListView.swift +++ b/app-ios/Sources/TimetableFeature/TimetableView.swift @@ -13,7 +13,6 @@ public struct TimetableView: View { @State private var timetableMode = TimetableMode.list @State private var switchModeIcon: ImageResource = .icGrid - @State private var selectedTab: DayTab = DayTab.day1 public var body: some View { VStack { @@ -21,12 +20,11 @@ public struct TimetableView: View { ForEach(DayTab.allCases) { tabItem in Button(action: { store.send(.view(.selectDay(tabItem))) - selectedTab = tabItem }, label: { HStack(spacing: 6) { - Text(tabItem.rawValue).textStyle(.titleMedium).underline(selectedTab == tabItem) + Text(tabItem.rawValue).textStyle(.titleMedium).underline(store.selectedDay == tabItem) } - .foregroundStyle(selectedTab == tabItem ? AssetColors.Custom.iguana.swiftUIColor : AssetColors.Surface.onSurface.swiftUIColor) + .foregroundStyle(store.selectedDay == tabItem ? AssetColors.Custom.iguana.swiftUIColor : AssetColors.Surface.onSurface.swiftUIColor) .padding(6) }) } @@ -59,7 +57,7 @@ public struct TimetableView: View { } .frame(width: 40, height: 40) } - + Button { switch timetableMode { case .list: