//
//  RecordingView.swift
//  USB Meter
//
//  Created by Bogdan Timofte on 09/03/2020.
//  Copyright © 2020 Bogdan Timofte. All rights reserved.
//

import SwiftUI

struct RecordingView: View {
    
    @EnvironmentObject private var usbMeter: Meter
    
    var body: some View {
        VStack {
            Text ("Recorded Data")
            Text ("REC")
                .foregroundColor(usbMeter.recording ? .red : .green)
            HStack {
                VStack {
                    Text ("Capacity")
                    Text ("Energy")
                    Text ("Duration")
                    Text ("Treshold")
                }
                VStack {
                    Text("\(usbMeter.recordedAH.format(decimalDigits: 3)) Ah")
                    Text("\(usbMeter.recordedWH.format(decimalDigits: 3)) Wh")
                    Text("\(usbMeter.recordingDuration) Sec")
                    HStack {
                        Slider(value: $usbMeter.recordingTreshold, in: 0...0.30, step: 0.01)
                        //.frame(width: 300)
                        Text("\(usbMeter.recordingTreshold.format(decimalDigits: 2)) A")
                    }.padding()
                }.padding()
            }
        }
    }
}

struct RecordingView_Previews: PreviewProvider {
    static var previews: some View {
        RecordingView()
    }
}
