1 contributor
//
// 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!")
})
}
.onAppear {
appData.bluetoothManager.start()
}
}
}