USB-Meter / USB Meter / Views / ContentView.swift
Newer Older
51 lines | 1.736kb
Bogdan Timofte authored 2 weeks ago
1
//
2
//  ContentView.swift
3
//  USB Meter
4
//
5
//  Created by Bogdan Timofte on 01/03/2020.
6
//  Copyright © 2020 Bogdan Timofte. All rights reserved.
7
//
8

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

            
11
import SwiftUI
12

            
13
struct ContentView: View {
14

            
15
    @EnvironmentObject private var appData: AppData
16

            
17
    var body: some View {
18
        NavigationView {
19
            List {
20
                Section(header: Text("Help")) {
21
                //VStack {
22
                    NavigationLink(destination: appData.bluetoothManager.managerState.helpView ) {
23
                        Text("Bluetooth")
24
                            .foregroundColor(appData.bluetoothManager.managerState.color)
25
                    }
26
                    NavigationLink(destination: DeviceHelpView()) {
27
                        Text("Device")
28
                            .foregroundColor(appData.bluetoothManager.managerState.color)
29
                    }
30
                }
31
                Section(header: Text("Discovered Devices")) {
32
                    ForEach( [Meter](appData.meters.values), id: \.self ) { meter in
33
                        NavigationLink(destination: MeterView()
34
                            .environmentObject(meter) ) {
35
                                MeterRowView()
36
                                .environmentObject( meter )
37
                        }
38
                    }
39
                }
40
            }
41
            .navigationBarTitle(Text("USB Meters"), displayMode: .inline)
42
            .navigationBarItems(trailing:
43
                Button("Help") {
44
                    print("Help tapped!")
45
            })
46
        }
Bogdan Timofte authored 2 weeks ago
47
        .onAppear {
48
            appData.bluetoothManager.start()
49
        }
Bogdan Timofte authored 2 weeks ago
50
    }
51
}