Skip to content

Commit

Permalink
Change to Sidebar style only iPad
Browse files Browse the repository at this point in the history
  • Loading branch information
coe committed Sep 18, 2023
1 parent 78eab5b commit d81b373
Showing 1 changed file with 65 additions and 22 deletions.
87 changes: 65 additions & 22 deletions app-ios/Modules/Sources/Navigation/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ import SwiftUI
import Theme
import Timetable

enum Tab {
enum Tab: Int, CaseIterable, Identifiable {
var id: Int {
rawValue
}

case timeline
case floorMap
case achievements
case about
}

public struct RootView: View {
@Environment(\.horizontalSizeClass) var horizontalSizeClass
@Environment(\.verticalSizeClass) var verticalSizeClass
@StateObject var viewModel: RootViewModel = .init()
@State var selection = Tab.timeline
@State var selectionForSidebar: Tab.ID? = Tab.timeline.id

public init() {}

Expand Down Expand Up @@ -49,29 +56,65 @@ public struct RootView: View {
SponsorView()
}
)
TabView(selection: $selection) {
timetableView
.tag(Tab.timeline)
.tabItem {
TimetableViewLabel(selected: selection == .timeline)
}
FloorMapView()
.tag(Tab.floorMap)
.tabItem {
FloorMapViewLabel(selected: selection == .floorMap)
}
// if isAchivementEnabled {
AchievementsView()
.tag(Tab.achievements)
.tabItem {
AchievementsViewLabel(selected: selection == .achievements)
Group {
if horizontalSizeClass == .regular && verticalSizeClass == .regular {
NavigationSplitView(columnVisibility: .constant(.doubleColumn)) {
List(Tab.allCases, selection: $selectionForSidebar) {
let selected = $0.id == selectionForSidebar
switch $0 {
case .timeline:
TimetableViewLabel(selected: selected)
case .floorMap:
FloorMapViewLabel(selected: selected)
case .achievements:
AchievementsViewLabel(selected: selected)
case .about:
AboutViewLabel(selected: selected)
}
}
// }
aboutView
.tag(Tab.about)
.tabItem {
AboutViewLabel(selected: selection == .about)
} detail: {
if let selectionForSidebar, let tab = Tab(rawValue: selectionForSidebar) {
switch tab {
case .timeline:
timetableView
case .floorMap:
FloorMapView()
case .achievements:
AchievementsView()
case .about:
aboutView
}
} else {
fatalError()
}
}
.navigationSplitViewStyle(.balanced)
} else {
TabView(selection: $selection) {
timetableView
.tag(Tab.timeline)
.tabItem {
TimetableViewLabel(selected: selection == .timeline)
}
FloorMapView()
.tag(Tab.floorMap)
.tabItem {
FloorMapViewLabel(selected: selection == .floorMap)
}
// if isAchivementEnabled {
AchievementsView()
.tag(Tab.achievements)
.tabItem {
AchievementsViewLabel(selected: selection == .achievements)
}
// }
aboutView
.tag(Tab.about)
.tabItem {
AboutViewLabel(selected: selection == .about)
}
}
}
}
.tint(AssetColors.Secondary.onSecondaryContainer.swiftUIColor)
}
Expand Down

0 comments on commit d81b373

Please sign in to comment.