|
|
|
|
@ -23,28 +23,9 @@ struct CompactHomeView: View { |
|
|
|
|
var body: some View { |
|
|
|
|
|
|
|
|
|
NavigationStack { |
|
|
|
|
|
|
|
|
|
ContentView<AbstractTimer>() |
|
|
|
|
.environment(\.managedObjectContext, viewContext) |
|
|
|
|
.environmentObject(Conductor.maestro) |
|
|
|
|
|
|
|
|
|
// 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) |
|
|
|
|
// ActivitiesView() |
|
|
|
|
// .environment(\.managedObjectContext, viewContext) |
|
|
|
|
// .tabItem { Label("Stats", systemImage: "chart.bar.fill") } |
|
|
|
|
// .tag(2) |
|
|
|
|
// } |
|
|
|
|
// .navigationBarTitleDisplayMode(NavigationBarItem.TitleDisplayMode.large) |
|
|
|
|
// .tabViewStyle(.page(indexDisplayMode: .never)) |
|
|
|
|
} |
|
|
|
|
.onAppear { |
|
|
|
|
if self.timers.count > 0 { |
|
|
|
|
@ -58,59 +39,59 @@ struct CompactHomeView: View { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct RegularHomeView: View { |
|
|
|
|
|
|
|
|
|
@Environment(\.managedObjectContext) private var viewContext |
|
|
|
|
|
|
|
|
|
@State private var tabSelection: Int = 1 |
|
|
|
|
|
|
|
|
|
@State private var columnVisibility: NavigationSplitViewVisibility = .detailOnly |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
|
|
|
|
|
NavigationSplitView(columnVisibility: $columnVisibility) { |
|
|
|
|
PresetsView(tabSelection: $tabSelection) |
|
|
|
|
.environment(\.managedObjectContext, viewContext) |
|
|
|
|
.tabItem { Label("Presets", systemImage: "globe") } |
|
|
|
|
.tag(0) |
|
|
|
|
} detail: { |
|
|
|
|
NavigationStack { |
|
|
|
|
TabView(selection: $tabSelection) { |
|
|
|
|
ContentView<AbstractTimer>() |
|
|
|
|
.environment(\.managedObjectContext, viewContext) |
|
|
|
|
.environmentObject(Conductor.maestro) |
|
|
|
|
.tabItem { Label("Home", systemImage: "clock.fill") } |
|
|
|
|
.tag(1) |
|
|
|
|
ActivitiesView() |
|
|
|
|
.environment(\.managedObjectContext, viewContext) |
|
|
|
|
.tabItem { Label("Stats", systemImage: "chart.bar.fill") } |
|
|
|
|
.tag(2) |
|
|
|
|
}.tabViewStyle(.page(indexDisplayMode: .never)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.onAppear { |
|
|
|
|
self._setColumnVisibility() |
|
|
|
|
} |
|
|
|
|
.onContinueUserActivity(Shortcut.newCountdown.rawValue, perform: _handleNewCountdown) |
|
|
|
|
.onOpenURL { _ in |
|
|
|
|
self.tabSelection = 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _setColumnVisibility() { |
|
|
|
|
let count = viewContext.count(entityName: "AbstractTimer") |
|
|
|
|
if count > 0 { |
|
|
|
|
self.columnVisibility = .detailOnly |
|
|
|
|
} else { |
|
|
|
|
self.columnVisibility = .automatic |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _handleNewCountdown(_ userActivity: NSUserActivity) { |
|
|
|
|
print(">>> new countdown") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//struct RegularHomeView: View { |
|
|
|
|
// |
|
|
|
|
// @Environment(\.managedObjectContext) private var viewContext |
|
|
|
|
// |
|
|
|
|
// @State private var tabSelection: Int = 1 |
|
|
|
|
// |
|
|
|
|
// @State private var columnVisibility: NavigationSplitViewVisibility = .detailOnly |
|
|
|
|
// |
|
|
|
|
// var body: some View { |
|
|
|
|
// |
|
|
|
|
// NavigationSplitView(columnVisibility: $columnVisibility) { |
|
|
|
|
// PresetsView(tabSelection: $tabSelection) |
|
|
|
|
// .environment(\.managedObjectContext, viewContext) |
|
|
|
|
// .tabItem { Label("Presets", systemImage: "globe") } |
|
|
|
|
// .tag(0) |
|
|
|
|
// } detail: { |
|
|
|
|
// NavigationStack { |
|
|
|
|
// TabView(selection: $tabSelection) { |
|
|
|
|
// ContentView<AbstractTimer>() |
|
|
|
|
// .environment(\.managedObjectContext, viewContext) |
|
|
|
|
// .environmentObject(Conductor.maestro) |
|
|
|
|
// .tabItem { Label("Home", systemImage: "clock.fill") } |
|
|
|
|
// .tag(1) |
|
|
|
|
// ActivitiesView() |
|
|
|
|
// .environment(\.managedObjectContext, viewContext) |
|
|
|
|
// .tabItem { Label("Stats", systemImage: "chart.bar.fill") } |
|
|
|
|
// .tag(2) |
|
|
|
|
// }.tabViewStyle(.page(indexDisplayMode: .never)) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// .onAppear { |
|
|
|
|
// self._setColumnVisibility() |
|
|
|
|
// } |
|
|
|
|
// .onContinueUserActivity(Shortcut.newCountdown.rawValue, perform: _handleNewCountdown) |
|
|
|
|
// .onOpenURL { _ in |
|
|
|
|
// self.tabSelection = 1 |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// fileprivate func _setColumnVisibility() { |
|
|
|
|
// let count = viewContext.count(entityName: "AbstractTimer") |
|
|
|
|
// if count > 0 { |
|
|
|
|
// self.columnVisibility = .detailOnly |
|
|
|
|
// } else { |
|
|
|
|
// self.columnVisibility = .automatic |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// fileprivate func _handleNewCountdown(_ userActivity: NSUserActivity) { |
|
|
|
|
// print(">>> new countdown") |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
struct CompactHomeView_Previews: PreviewProvider { |
|
|
|
|
static var previews: some View { |
|
|
|
|
@ -121,11 +102,11 @@ struct CompactHomeView_Previews: PreviewProvider { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct RegularHomeView_Previews: PreviewProvider { |
|
|
|
|
static var previews: some View { |
|
|
|
|
RegularHomeView() |
|
|
|
|
.environmentObject(Conductor.maestro) |
|
|
|
|
.environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//struct RegularHomeView_Previews: PreviewProvider { |
|
|
|
|
// static var previews: some View { |
|
|
|
|
// RegularHomeView() |
|
|
|
|
// .environmentObject(Conductor.maestro) |
|
|
|
|
// .environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) |
|
|
|
|
// |
|
|
|
|
// } |
|
|
|
|
//} |
|
|
|
|
|