| 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 MeasurementPointView: View {
|
|
| 12 | ||
| 13 |
var power: Measurements.Measurement.Point |
|
| 14 |
var voltage: Measurements.Measurement.Point |
|
| 15 |
var current: Measurements.Measurement.Point |
|
| 16 | ||
| 17 |
@State var showDetail: Bool = false |
|
| 18 | ||
| 19 |
var body: some View {
|
|
| 20 |
VStack {
|
|
| 21 |
HStack {
|
|
| 22 |
Image(systemName: "pencil.and.ellipsis.rectangle") |
|
| 23 |
.imageScale(.large) |
|
| 24 |
Text ("\(voltage.timestamp.format(as: "yyyy-MM-dd hh:mm:ss"))")
|
|
| 25 |
Spacer() |
|
| 26 |
Button(action: {
|
|
| 27 |
self.showDetail.toggle() |
|
| 28 |
}) {
|
|
| 29 |
Image(systemName: "chevron.right.circle") |
|
| 30 |
.imageScale(.large) |
|
| 31 |
.rotationEffect(.degrees(showDetail ? 90 : 0)) |
|
| 32 |
.animation(.easeInOut(duration: 0.25)) |
|
| 33 |
} |
|
| 34 |
} |
|
| 35 |
if showDetail {
|
|
| 36 |
VStack {
|
|
| 37 |
HStack {
|
|
| 38 |
Text("Power:")
|
|
| 39 |
Spacer() |
|
| 40 |
Text("\(power.value.format(fractionDigits: 4))")
|
|
| 41 |
} |
|
| 42 |
HStack {
|
|
| 43 |
Text("Voltage:")
|
|
| 44 |
Spacer() |
|
| 45 |
Text("\(voltage.value.format(fractionDigits: 4))")
|
|
| 46 |
} |
|
| 47 |
HStack {
|
|
| 48 |
Text("Current:")
|
|
| 49 |
Spacer() |
|
| 50 |
Text("\(current.value.format(fractionDigits: 4))")
|
|
| 51 |
} |
|
| 52 |
} |
|
| 53 |
.padding() |
|
| 54 |
} |
|
| 55 |
} |
|
| 56 | ||
| 57 |
} |
|
| 58 |
} |