mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
49 lines
1.2 KiB
Swift
49 lines
1.2 KiB
Swift
//
|
|
// DeviceHome.swift
|
|
// Landmarks
|
|
//
|
|
// Created by Garth Vander Houwen on 8/7/21.
|
|
// See LICENSE folder for app licensing information.
|
|
//
|
|
|
|
// Abstract:
|
|
// A view showing devices above a list of devices
|
|
// grouped by device.
|
|
|
|
import SwiftUI
|
|
|
|
struct DeviceList: View {
|
|
@EnvironmentObject var modelData: ModelData
|
|
@State private var showGPSOnly = false
|
|
|
|
var filteredDevices: [Device] {
|
|
modelData.devices.filter { device in
|
|
(!showGPSOnly || device.hasGPS)
|
|
}
|
|
}
|
|
var body: some View {
|
|
NavigationView {
|
|
|
|
List {
|
|
Toggle(isOn: $showGPSOnly) {
|
|
Text("GPS only")
|
|
}
|
|
|
|
ForEach(filteredDevices) { device in
|
|
NavigationLink(destination: DeviceDetail(device: device)) {
|
|
DeviceRow(device: device)
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("All Devices")
|
|
}.navigationViewStyle(StackNavigationViewStyle())
|
|
|
|
}
|
|
}
|
|
|
|
struct DeviceList_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
DeviceHome()
|
|
.environmentObject(ModelData())
|
|
}
|
|
}
|