-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentView.swift
More file actions
73 lines (64 loc) · 2.4 KB
/
ContentView.swift
File metadata and controls
73 lines (64 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// ContentView.swift
//
// Copyright 2023 OpenAlloc LLC
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//
import os
import SwiftUI
import TrackerUI
import TroutLib
import TroutUI
let mainNavDataMRoutineKey = "main-routines-nav"
let mainNavDataHistoryKey = "main-history-nav"
let mainNavDataSettingKey = "main-settings-nav"
struct ContentView: View {
@Environment(\.verticalSizeClass) private var verticalSizeClass
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@Environment(\.managedObjectContext) private var viewContext
@EnvironmentObject private var manager: CoreDataStack
@SceneStorage(tabbedViewSelectedTabKey) private var selectedTab = PortraitTab.routines.rawValue
// private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!,
// category: String(describing: ContentView.self))
var body: some View {
GeometryReader { geo in
let isLandscape = geo.size.width > geo.size.height
let isPad = horizontalSizeClass == .regular && verticalSizeClass == .regular
VStack {
if isPad, isLandscape {
// enough vertical to show number pad, etc.
MainLandscape()
} else {
MainPortrait()
}
}
}
.task(priority: .utility, taskAction)
.onContinueUserActivity(startMRoutineActivityType) {
selectedTab = PortraitTab.routines.rawValue
handleStartMRoutineUA(viewContext, $0)
}
}
@Sendable
private func taskAction() async {
await handleTaskAction(manager)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
let manager = CoreDataStack.getPreviewStack()
let ctx = manager.container.viewContext
let routine = MRoutine.create(ctx, userOrder: 0)
routine.name = "Back & Bicep"
let e1 = MTask.create(ctx, routine: routine, userOrder: 0)
e1.name = "Lat Pulldown"
let e2 = MTask.create(ctx, routine: routine, userOrder: 1)
e2.name = "Arm Curl"
return ContentView()
.environment(\.managedObjectContext, ctx)
.environmentObject(manager)
}
}