// // MapSettingsForm.swift // Meshtastic // // Created by Garth Vander Houwen on 10/3/23. // import SwiftUI #if canImport(MapKit) import MapKit #endif @available(iOS 17.0, macOS 14.0, *) struct MapSettingsForm: View { @Environment(\.dismiss) private var dismiss @State var nodeHistory = false @State var routeLines = false @State var convexHull = false @State var traffic: Bool = false @State var pointsOfInterest: Bool = false @State var mapLayer: MapLayer = .standard var body: some View { VStack { Form { Section(header: Text("Map Options")) { Picker(selection: $mapLayer, label: Text("")) { ForEach(MapLayer.allCases, id: \.self) { layer in if layer != MapLayer.offline { Text(layer.localized) } } } .pickerStyle(SegmentedPickerStyle()) .padding(.top, 5) .padding(.bottom, 5) Toggle(isOn: $nodeHistory) { Label("Node History", systemImage: "building.columns.fill") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) .onTapGesture { self.nodeHistory.toggle() UserDefaults.enableMapNodeHistoryPins = self.nodeHistory } Toggle(isOn: $routeLines) { Label("Route Lines", systemImage: "road.lanes") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) .onTapGesture { self.routeLines.toggle() UserDefaults.enableMapRouteLines = self.routeLines } Toggle(isOn: $convexHull) { Label("Convex Hull", systemImage: "button.angledbottom.horizontal.right") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) .onTapGesture { self.convexHull.toggle() UserDefaults.enableMapConvexHull = self.convexHull } Toggle(isOn: $traffic) { Label("Traffic", systemImage: "car") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) .onTapGesture { self.traffic.toggle() UserDefaults.enableMapTraffic = self.traffic } Toggle(isOn: $pointsOfInterest) { Label("Points of Interest", systemImage: "mappin.and.ellipse") } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) .onTapGesture { self.pointsOfInterest.toggle() UserDefaults.enableMapPointsOfInterest = self.pointsOfInterest } } } #if targetEnvironment(macCatalyst) Button { dismiss() } label: { Label("close", systemImage: "xmark") } .buttonStyle(.bordered) .buttonBorderShape(.capsule) .controlSize(.large) .padding() #endif } .presentationDetents([.fraction(0.60)]) //.presentationDetents([.medium, .large]) .presentationDragIndicator(.automatic) } }