USB-Meter / USB Meter / Views / ContentView.swift
1 contributor
49 lines | 1.662kb
//
//  ContentView.swift
//  USB Meter
//
//  Created by Bogdan Timofte on 01/03/2020.
//  Copyright © 2020 Bogdan Timofte. All rights reserved.
//

//MARK: Bluetooth Icon: https://upload.wikimedia.org/wikipedia/commons/d/da/Bluetooth.svg

import SwiftUI

struct ContentView: View {
    
    @EnvironmentObject private var appData: AppData
    
    var body: some View {
        NavigationView {
            List {
                Section(header: Text("Help")) {
                //VStack {
                    NavigationLink(destination: appData.bluetoothManager.managerState.helpView ) {
                        Text("Bluetooth")
                            .foregroundColor(appData.bluetoothManager.managerState.color)
                    }
                    NavigationLink(destination: DeviceHelpView()) {
                        Text("Device")
                            .foregroundColor(appData.bluetoothManager.managerState.color)
                    }
                }
                Section(header: Text("Discovered Devices")) {
                    ForEach( [Meter](appData.meters.values), id: \.self ) { meter in
                        NavigationLink(destination: MeterView()
                            .environmentObject(meter) ) {
                                MeterRowView()
                                .environmentObject( meter )
                        }
                    }
                }
            }
            .navigationBarTitle(Text("USB Meters"), displayMode: .inline)
            .navigationBarItems(trailing:
                Button("Help") {
                    print("Help tapped!")
            })
        }
    }
}