From 9efec04b7de1e581668fa0a1f0deaf3fe052044b Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 8 Nov 2022 22:01:32 -0800 Subject: [PATCH] Close buttons for sheets in catalyst to prevent the need to force quit --- .../Views/Bluetooth/InvalidVersion.swift | 24 +++++++++++++++---- .../Views/Settings/SaveChannelQRCode.swift | 19 +++++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Meshtastic/Views/Bluetooth/InvalidVersion.swift b/Meshtastic/Views/Bluetooth/InvalidVersion.swift index b001d95f..05fab886 100644 --- a/Meshtastic/Views/Bluetooth/InvalidVersion.swift +++ b/Meshtastic/Views/Bluetooth/InvalidVersion.swift @@ -8,6 +8,8 @@ import SwiftUI struct InvalidVersion: View { + @Environment(\.presentationMode) private var presentationMode + @State var minimumVersion = "" @State var version = "" @@ -36,7 +38,6 @@ struct InvalidVersion: View { .font(.title) .padding() - } .padding() @@ -51,16 +52,29 @@ struct InvalidVersion: View { .padding(.bottom) Text("Version \(minimumVersion) includes breaking changes to devices and the client apps. Only nodes version \(minimumVersion) and above are supported.") - .font(.caption) - .padding([.leading, .trailing]) + .font(.callout) + .padding([.leading, .trailing, .bottom]) Text("There is a build for 1.2 EOL under Other Versions in TestFlight that will be available until the end of November 2022.") - .font(.caption) - .padding() + .font(.callout) + .padding([.leading, .trailing, .bottom]) Link("Version 1.2 End of life (EOL) Info", destination: URL(string: "https://meshtastic.org/docs/1.2-End-of-life/")!) .font(.callout) + #if targetEnvironment(macCatalyst) + Button { + presentationMode.wrappedValue.dismiss() + } label: { + Label("Close", systemImage: "xmark") + + } + .buttonStyle(.bordered) + .buttonBorderShape(.capsule) + .controlSize(.large) + .padding() + #endif + }.padding() } } diff --git a/Meshtastic/Views/Settings/SaveChannelQRCode.swift b/Meshtastic/Views/Settings/SaveChannelQRCode.swift index c18f1cab..7448ac95 100644 --- a/Meshtastic/Views/Settings/SaveChannelQRCode.swift +++ b/Meshtastic/Views/Settings/SaveChannelQRCode.swift @@ -9,6 +9,7 @@ import SwiftUI struct SaveChannelQRCode: View { @Environment(\.presentationMode) private var presentationMode + var channelSetLink: String var bleManager: BLEManager @State var connectedToDevice = false @@ -22,7 +23,8 @@ struct SaveChannelQRCode: View { .font(.callout) .padding() - + HStack { + Button { let success = bleManager.saveChannelSet(base64UrlString: channelSetLink) if success { @@ -37,7 +39,20 @@ struct SaveChannelQRCode: View { .controlSize(.large) .padding() .disabled(!connectedToDevice) - + + #if targetEnvironment(macCatalyst) + Button { + presentationMode.wrappedValue.dismiss() + } label: { + Label("Cancel", systemImage: "xmark") + + } + .buttonStyle(.bordered) + .buttonBorderShape(.capsule) + .controlSize(.large) + .padding() + #endif + } } .onAppear { connectedToDevice = bleManager.connectToPreferredPeripheral()