|
|
|
|
@ -58,14 +58,16 @@ struct RegularHomeView: View { |
|
|
|
|
|
|
|
|
|
@State private var tabSelection: Int = 1 |
|
|
|
|
|
|
|
|
|
@State private var columnVisibility: NavigationSplitViewVisibility = .detailOnly |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
|
|
|
|
|
NavigationView { |
|
|
|
|
NavigationSplitView(columnVisibility: $columnVisibility) { |
|
|
|
|
PresetsView(tabSelection: $tabSelection) |
|
|
|
|
.environment(\.managedObjectContext, viewContext) |
|
|
|
|
.tabItem { Label("Presets", systemImage: "globe") } |
|
|
|
|
.tag(0) |
|
|
|
|
|
|
|
|
|
} detail: { |
|
|
|
|
TabView(selection: $tabSelection) { |
|
|
|
|
ContentView<AbstractTimer>() |
|
|
|
|
.environment(\.managedObjectContext, viewContext) |
|
|
|
|
@ -78,12 +80,28 @@ struct RegularHomeView: View { |
|
|
|
|
.tag(2) |
|
|
|
|
}.tabViewStyle(.page(indexDisplayMode: .never)) |
|
|
|
|
} |
|
|
|
|
.onAppear { |
|
|
|
|
self._setColumnVisibility() |
|
|
|
|
} |
|
|
|
|
.onContinueUserActivity(Shortcut.newCountdown.rawValue, perform: _handleNewCountdown) |
|
|
|
|
.onOpenURL { _ in |
|
|
|
|
self.tabSelection = 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _setColumnVisibility() { |
|
|
|
|
do { |
|
|
|
|
let count = try viewContext.count(entityName: "AbstractTimer") |
|
|
|
|
if count > 0 { |
|
|
|
|
self.columnVisibility = .detailOnly |
|
|
|
|
} else { |
|
|
|
|
self.columnVisibility = .automatic |
|
|
|
|
} |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _handleNewCountdown(_ userActivity: NSUserActivity) { |
|
|
|
|
print(">>> new countdown") |
|
|
|
|
} |
|
|
|
|
|