-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecordingView.swift
78 lines (65 loc) · 3.29 KB
/
RecordingView.swift
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
74
75
76
77
78
import SwiftUI
import CoreLocation
struct RecordingView: View {
@ObservedObject var locationManager: LocationManager
@EnvironmentObject var userSettings: UserSettings
var body: some View {
GeometryReader { geometry in
ZStack {
// SignalStrengthElement (top left)
signalStrengthElement
.position(x: geometry.size.width * 0.12, y: geometry.size.height * 0.19)
RecordingIndicator()
.position(x: WKInterfaceDevice.current().screenBounds.width == 198.0 ?
(geometry.size.width * 0.12 + 29 + 50) :
geometry.size.width / 2,
y: geometry.size.height * 0.064)
// LiveCoreStatistics (centered horizontally and vertically)
LiveCoreStatistics(locationManager: locationManager)
.environmentObject(userSettings)
.position(x: geometry.size.width / 2, y: geometry.size.height / 2.2)
// LocationNameElement (1/4 down the screen vertically, centered horizontally)
LocationNameElement(locationManager: locationManager)
.position(x: geometry.size.width / 2, y: geometry.size.height * 0.2)
// ElevationElement (bottom left)
ElevationElement(locationManager: locationManager)
.frame(width: geometry.size.width * 0.4)
.position(x: geometry.size.width * 0.20, y: geometry.size.height * 0.8)
// TotalTimeElement (bottom right)
GeometryReader { geometry in
TotalTimeElement(locationManager: locationManager)
.frame(maxWidth: geometry.size.width * 0.4, alignment: .trailing)
.position(x: min(geometry.size.width * 0.75, geometry.size.width - geometry.size.width * 0.2), y: geometry.size.height * 0.8)
}
pauseOverlay(size: geometry.size)
.opacity(locationManager.paused ? 1 : 0)
.animation(.easeInOut(duration: 0.35), value: locationManager.paused)
.allowsHitTesting(locationManager.paused)
}
}
.edgesIgnoringSafeArea(.all)
}
private func pauseOverlay(size: CGSize) -> some View {
ZStack {
Color.black.opacity(0.95)
VStack(spacing: 20) {
Image(systemName: "pause.circle.fill")
.font(.system(size: size.width * 0.2))
.foregroundColor(.white)
Text("Journey Paused")
.font(.system(size: size.width * 0.08, weight: .bold))
.foregroundColor(.white)
}
}
.frame(width: size.width, height: size.height)
.position(x: size.width / 2, y: size.height / 2)
}
private var signalStrengthElement: some View {
Group {
if let accuracy = locationManager.gpsAccuracy {
SignalStrengthElement(accuracy: accuracy)
.frame(width: 50, height: 20)
}
}
}
}