From f259cb15fdd67fafa889c9dff1a307e19d6f07d2 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 8 Nov 2022 23:18:50 -0800 Subject: [PATCH] Dismiss buttons for sheets on mac Add icon to clear app data button Convert settings view to navigationsplitview --- Meshtastic/Views/Bluetooth/InvalidVersion.swift | 4 ++-- Meshtastic/Views/Messages/Contacts.swift | 2 +- Meshtastic/Views/Settings/AppSettings.swift | 6 ++++-- Meshtastic/Views/Settings/SaveChannelQRCode.swift | 6 +++--- Meshtastic/Views/Settings/Settings.swift | 9 ++++----- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Meshtastic/Views/Bluetooth/InvalidVersion.swift b/Meshtastic/Views/Bluetooth/InvalidVersion.swift index 05fab886..92868cca 100644 --- a/Meshtastic/Views/Bluetooth/InvalidVersion.swift +++ b/Meshtastic/Views/Bluetooth/InvalidVersion.swift @@ -8,7 +8,7 @@ import SwiftUI struct InvalidVersion: View { - @Environment(\.presentationMode) private var presentationMode + @Environment(\.dismiss) private var dismiss @State var minimumVersion = "" @State var version = "" @@ -64,7 +64,7 @@ struct InvalidVersion: View { #if targetEnvironment(macCatalyst) Button { - presentationMode.wrappedValue.dismiss() + dismiss() } label: { Label("Close", systemImage: "xmark") diff --git a/Meshtastic/Views/Messages/Contacts.swift b/Meshtastic/Views/Messages/Contacts.swift index 4238ad61..e07f8333 100644 --- a/Meshtastic/Views/Messages/Contacts.swift +++ b/Meshtastic/Views/Messages/Contacts.swift @@ -183,7 +183,7 @@ struct Contacts: View { UserMessageList(user:user) } else { - Text("Select a user") + Text("Select a Contact") } } } diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index 29ec50b1..46a9b892 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -159,9 +159,11 @@ struct AppSettings: View { } } HStack { - - Button("Clear App Data", role: .destructive) { + Button { isPresentingCoreDataResetConfirm = true + } label: { + Label("Clear App Data", systemImage: "clear") + .foregroundColor(.red) } .buttonStyle(.bordered) .buttonBorderShape(.capsule) diff --git a/Meshtastic/Views/Settings/SaveChannelQRCode.swift b/Meshtastic/Views/Settings/SaveChannelQRCode.swift index 7448ac95..7f375268 100644 --- a/Meshtastic/Views/Settings/SaveChannelQRCode.swift +++ b/Meshtastic/Views/Settings/SaveChannelQRCode.swift @@ -8,7 +8,7 @@ import SwiftUI struct SaveChannelQRCode: View { - @Environment(\.presentationMode) private var presentationMode + @Environment(\.dismiss) private var dismiss var channelSetLink: String var bleManager: BLEManager @@ -28,7 +28,7 @@ struct SaveChannelQRCode: View { Button { let success = bleManager.saveChannelSet(base64UrlString: channelSetLink) if success { - presentationMode.wrappedValue.dismiss() + dismiss() } } label: { @@ -42,7 +42,7 @@ struct SaveChannelQRCode: View { #if targetEnvironment(macCatalyst) Button { - presentationMode.wrappedValue.dismiss() + dismiss() } label: { Label("Cancel", systemImage: "xmark") diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 10b53412..4fa60868 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -12,15 +12,12 @@ struct Settings: View { @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager @EnvironmentObject var userSettings: UserSettings - @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "lastHeard", ascending: false)], animation: .default) private var nodes: FetchedResults var body: some View { - NavigationView { - + NavigationSplitView { List { - let connectedNodeNum = bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.num : 0 NavigationLink() { @@ -31,7 +28,6 @@ struct Settings: View { .symbolRenderingMode(.hierarchical) Text("App Settings") } - Section("Radio Configuration") { NavigationLink { @@ -201,5 +197,8 @@ struct Settings: View { MeshtasticLogo() ) } + detail: { + Text("Select an item from the menu") + } } }