1 contributor
41 lines | 1.276kb
//
//  ControlView.swift
//  USB Meter
//
//  Created by Bogdan Timofte on 09/03/2020.
//  Copyright © 2020 Bogdan Timofte. All rights reserved.
//

import SwiftUI

struct ControlView: View {
    
    @EnvironmentObject private var meter: Meter

    var body: some View {
        HStack {
            VStack {
                HStack {
                    Button(action: { self.meter.rotateScreen() }, label: { Image(systemName: "arrow.clockwise") })
                }
                HStack {
                    Button(action: { self.meter.previousScreen() }, label: { Image(systemName: "arrowtriangle.left") })
                    Text(meter.currentScreenDescription)
                    Button(action: { self.meter.nextScreen() }, label: { Image(systemName: "arrowtriangle.right") })
                }
                if !meter.reportsCurrentScreenIndex {
                    Text("This protocol supports page navigation, but not current-page reporting.")
                        .font(.footnote)
                        .foregroundColor(.secondary)
                        .multilineTextAlignment(.center)
                }
            }
        }
    }
}

struct ControlView_Previews: PreviewProvider {
    static var previews: some View {
        ControlView()
    }
}