| 1 |
// |
|
| 2 |
// RecordingView.swift |
|
| 3 |
// USB Meter |
|
| 4 |
// |
|
| 5 |
// Created by Bogdan Timofte on 09/03/2020. |
|
| 6 |
// Copyright © 2020 Bogdan Timofte. All rights reserved. |
|
| 7 |
// |
|
| 8 | ||
| 9 |
import SwiftUI |
|
| 10 | ||
| 11 |
struct RecordingView: View {
|
|
| 12 | ||
| 13 |
@EnvironmentObject private var usbMeter: Meter |
|
| 14 | ||
| 15 |
var body: some View {
|
|
| 16 |
VStack {
|
|
| 17 |
Text ("Recorded Data")
|
|
| 18 |
Text ("REC")
|
|
| 19 |
.foregroundColor(usbMeter.recording ? .red : .green) |
|
| 20 |
HStack {
|
|
| 21 |
VStack {
|
|
| 22 |
Text ("Capacity")
|
|
| 23 |
Text ("Energy")
|
|
| 24 |
Text ("Duration")
|
|
| 25 |
Text ("Treshold")
|
|
| 26 |
} |
|
| 27 |
VStack {
|
|
| 28 |
Text("\(usbMeter.recordedAH.format(decimalDigits: 3)) Ah")
|
|
| 29 |
Text("\(usbMeter.recordedWH.format(decimalDigits: 3)) Wh")
|
|
| 30 |
Text("\(usbMeter.recordingDuration) Sec")
|
|
| 31 |
if usbMeter.supportsRecordingThreshold {
|
|
| 32 |
HStack {
|
|
| 33 |
Slider(value: $usbMeter.recordingTreshold, in: 0...0.30, step: 0.01) |
|
| 34 |
Text("\(usbMeter.recordingTreshold.format(decimalDigits: 2)) A")
|
|
| 35 |
} |
|
| 36 |
.padding() |
|
| 37 |
} else {
|
|
| 38 |
Text("N/A")
|
|
| 39 |
} |
|
| 40 |
}.padding() |
|
| 41 |
} |
|
| 42 |
} |
|
| 43 |
} |
|
| 44 |
} |
|
| 45 | ||
| 46 |
struct RecordingView_Previews: PreviewProvider {
|
|
| 47 |
static var previews: some View {
|
|
| 48 |
RecordingView() |
|
| 49 |
} |
|
| 50 |
} |