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

[iOS] fix ios timetable list/grid always reset on any action #1036

Merged
merged 1 commit into from
Sep 11, 2024
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
20 changes: 9 additions & 11 deletions app-ios/Sources/TimetableFeature/TimetableReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []) {
Expand Down Expand Up @@ -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)))
}
}
Expand All @@ -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))
}
Expand All @@ -113,6 +114,3 @@ public struct TimetableReducer : Sendable{
}
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ 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 {
HStack {
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)
})
}
Expand Down Expand Up @@ -59,7 +57,7 @@ public struct TimetableView: View {
}
.frame(width: 40, height: 40)
}

Button {
switch timetableMode {
case .list:
Expand Down
Loading