|
Bogdan Timofte
authored
2 weeks ago
|
1
|
//
|
|
|
2
|
// MeasurementView.swift
|
|
|
3
|
// USB Meter
|
|
|
4
|
//
|
|
|
5
|
// Created by Bogdan Timofte on 13/04/2020.
|
|
|
6
|
// Copyright © 2020 Bogdan Timofte. All rights reserved.
|
|
|
7
|
//
|
|
|
8
|
|
|
|
9
|
import SwiftUI
|
|
|
10
|
|
|
|
11
|
struct MeasurementsView: View {
|
|
|
12
|
|
|
|
13
|
@EnvironmentObject private var measurements: Measurements
|
|
|
14
|
|
|
|
15
|
@Binding var visibility: Bool
|
|
|
16
|
|
|
|
17
|
var body: some View {
|
|
|
18
|
NavigationView {
|
|
|
19
|
VStack {
|
|
Bogdan Timofte
authored
2 weeks ago
|
20
|
Text("Local timeline captured by the app while connected to the meter.")
|
|
|
21
|
.font(.footnote)
|
|
|
22
|
.foregroundColor(.secondary)
|
|
|
23
|
.multilineTextAlignment(.center)
|
|
|
24
|
.padding(.horizontal)
|
|
|
25
|
.padding(.top, 8)
|
|
Bogdan Timofte
authored
2 weeks ago
|
26
|
List {
|
|
|
27
|
ForEach (measurements.power.points) { point in
|
|
|
28
|
// MARK: Crapa la stergere daca lista incape in fereastra: Fatal error: Index out of range
|
|
|
29
|
MeasurementPointView(power: point, voltage: self.measurements.voltage.points[point.id], current: self.measurements.current.points[point.id])
|
|
|
30
|
}.onDelete { (indexSet) in
|
|
|
31
|
for idx in indexSet {
|
|
|
32
|
self.measurements.remove(at: idx)
|
|
|
33
|
}
|
|
|
34
|
}
|
|
|
35
|
}
|
|
|
36
|
}
|
|
|
37
|
.navigationBarItems(leading: HStack{
|
|
|
38
|
Button(action: {self.visibility.toggle()}) {
|
|
Bogdan Timofte
authored
2 weeks ago
|
39
|
Text("Done")
|
|
Bogdan Timofte
authored
2 weeks ago
|
40
|
}
|
|
|
41
|
},
|
|
|
42
|
trailing: HStack{
|
|
|
43
|
#if targetEnvironment(macCatalyst)
|
|
|
44
|
EditButton()
|
|
|
45
|
#endif
|
|
|
46
|
Button(action: {
|
|
|
47
|
self.measurements.power.reset()
|
|
|
48
|
self.measurements.voltage.reset()
|
|
|
49
|
self.measurements.current.reset()
|
|
|
50
|
}) {
|
|
|
51
|
Text("🗑")
|
|
|
52
|
.foregroundColor(.red)
|
|
|
53
|
}
|
|
|
54
|
})
|
|
Bogdan Timofte
authored
2 weeks ago
|
55
|
.navigationBarTitle("App History", displayMode: .inline)
|
|
Bogdan Timofte
authored
2 weeks ago
|
56
|
}
|
|
|
57
|
.navigationViewStyle(StackNavigationViewStyle())
|
|
|
58
|
}
|
|
|
59
|
}
|