Close buttons for sheets in catalyst to prevent the need to force quit

This commit is contained in:
Garth Vander Houwen 2022-11-08 22:01:32 -08:00
parent e798cd3e7a
commit 9efec04b7d
2 changed files with 36 additions and 7 deletions

View file

@ -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()
}
}

View file

@ -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()