parent
152e88138b
commit
2f19388cbf
@ -0,0 +1,86 @@ |
||||
// |
||||
// HomeView.swift |
||||
// LeCountdown |
||||
// |
||||
// Created by Laurent Morvillier on 15/02/2023. |
||||
// |
||||
|
||||
import SwiftUI |
||||
|
||||
struct CompactHomeView: View { |
||||
|
||||
@Environment(\.managedObjectContext) private var viewContext |
||||
|
||||
@State private var tabSelection: Int = 1 |
||||
|
||||
var body: some View { |
||||
|
||||
NavigationStack { |
||||
TabView(selection: $tabSelection) { |
||||
PresetsView(tabSelection: $tabSelection) |
||||
.environment(\.managedObjectContext, viewContext) |
||||
.tabItem { Label("Presets", systemImage: "globe") } |
||||
.tag(0) |
||||
ContentView<AbstractTimer>() |
||||
.environment(\.managedObjectContext, viewContext) |
||||
.environmentObject(Conductor.maestro) |
||||
.tabItem { Label("Home", systemImage: "clock.fill") } |
||||
.tag(1) |
||||
RecordsView() |
||||
.environment(\.managedObjectContext, viewContext) |
||||
.tabItem { Label("Stats", systemImage: "chart.bar.fill") } |
||||
.tag(2) |
||||
} |
||||
.tabViewStyle(.page) |
||||
.onOpenURL { _ in |
||||
self.tabSelection = 1 |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
struct RegularHomeView: View { |
||||
|
||||
@Environment(\.managedObjectContext) private var viewContext |
||||
|
||||
@State private var tabSelection: Int = 1 |
||||
|
||||
var body: some View { |
||||
|
||||
NavigationStack { |
||||
TabView(selection: $tabSelection) { |
||||
PresetsView(tabSelection: $tabSelection) |
||||
.environment(\.managedObjectContext, viewContext) |
||||
.tabItem { Label("Presets", systemImage: "globe") } |
||||
.tag(0) |
||||
ContentView<AbstractTimer>() |
||||
.environment(\.managedObjectContext, viewContext) |
||||
.environmentObject(Conductor.maestro) |
||||
.tabItem { Label("Home", systemImage: "clock.fill") } |
||||
.tag(1) |
||||
RecordsView() |
||||
.environment(\.managedObjectContext, viewContext) |
||||
.tabItem { Label("Stats", systemImage: "chart.bar.fill") } |
||||
.tag(2) |
||||
} |
||||
} |
||||
.tabViewStyle(.page) |
||||
.onOpenURL { _ in |
||||
self.tabSelection = 1 |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
struct CompactHomeView_Previews: PreviewProvider { |
||||
static var previews: some View { |
||||
CompactHomeView().previewDevice(PreviewDevice(rawValue: "iPhone 12 Pro")) |
||||
} |
||||
} |
||||
|
||||
struct RegularHomeView_Previews: PreviewProvider { |
||||
static var previews: some View { |
||||
RegularHomeView().previewDevice(PreviewDevice(rawValue: "iPad Pro (11-inch)")) |
||||
} |
||||
} |
||||
Loading…
Reference in new issue