From 698eb7b5d08519ba11236739dc9daf96b2b83ad9 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 26 Aug 2024 22:31:03 -0700 Subject: [PATCH] Update app settings clear button --- Meshtastic/Views/Settings/AppSettings.swift | 5 +++- Meshtastic/Views/Settings/Channels.swift | 6 ++++- .../Views/Settings/Channels/ChannelForm.swift | 27 +++++++------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index 0bb86bc1..f641b77b 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -78,8 +78,11 @@ struct AppSettings: View { context.refreshAllObjects() } } - Button("Reset App Settings", systemImage: "clipboard") { + Button { UserDefaults.standard.reset() + } label: { + Label("Reset App Settings", systemImage: "arrow.counterclockwise.circle") + .foregroundColor(.red) } } if totalDownloadedTileSize != "0MB" { diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index 3bb6ab38..61cddcea 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -92,7 +92,11 @@ struct Channels: View { positionPrecision = 32 preciseLocation = true positionsEnabled = true - + if channelKey == "AQ==" { + positionPrecision = 13 + preciseLocation = false + positionsEnabled = true + } } else if !supportedVersion && channelRole == 2 { positionPrecision = 0 preciseLocation = false diff --git a/Meshtastic/Views/Settings/Channels/ChannelForm.swift b/Meshtastic/Views/Settings/Channels/ChannelForm.swift index 28fe1116..52e1f59e 100644 --- a/Meshtastic/Views/Settings/Channels/ChannelForm.swift +++ b/Meshtastic/Views/Settings/Channels/ChannelForm.swift @@ -157,20 +157,12 @@ struct ChannelForm: View { if !preciseLocation { VStack(alignment: .leading) { Label("Approximate Location", systemImage: "location.slash.circle.fill") - if channelKeySize == -1 { - Slider(value: $positionPrecision, in: 10...16, step: 1) { - } minimumValueLabel: { - Image(systemName: "minus") - } maximumValueLabel: { - Image(systemName: "plus") - } - } else { - Slider(value: $positionPrecision, in: 10...19, step: 1) { - } minimumValueLabel: { - Image(systemName: "minus") - } maximumValueLabel: { - Image(systemName: "plus") - } + + Slider(value: $positionPrecision, in: 10...16, step: 1) { + } minimumValueLabel: { + Image(systemName: "minus") + } maximumValueLabel: { + Image(systemName: "plus") } Text(PositionPrecision(rawValue: Int(positionPrecision))?.description ?? "") .foregroundColor(.gray) @@ -211,6 +203,7 @@ struct ChannelForm: View { .onChange(of: channelKeySize) { _ in if channelKeySize == -1 { preciseLocation = false + channelKey = "AQ==" } } .onChange(of: channelRole) { _ in @@ -220,7 +213,7 @@ struct ChannelForm: View { if loc == true { positionPrecision = 32 } else { - positionPrecision = 14 + positionPrecision = 13 } hasChanges = true } @@ -230,7 +223,7 @@ struct ChannelForm: View { .onChange(of: positionsEnabled) { pe in if pe { if positionPrecision == 0 { - positionPrecision = 32 + positionPrecision = 13 } } else { positionPrecision = 0 @@ -243,7 +236,7 @@ struct ChannelForm: View { .onChange(of: downlink) { _ in hasChanges = true } - .onAppear { + .onFirstAppear { let tempKey = Data(base64Encoded: channelKey) ?? Data() if tempKey.count == channelKeySize || channelKeySize == -1 { hasValidKey = true