Meshtastic-Apple/Meshtastic/Views/Settings/SaveChannelQRCode.swift

62 lines
1.3 KiB
Swift
Raw Normal View History

//
// SaveChannelQRCode.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 7/13/22.
//
import SwiftUI
struct SaveChannelQRCode: View {
2022-10-19 16:58:49 -07:00
@Environment(\.dismiss) private var dismiss
var channelSetLink: String
2022-10-18 19:50:42 -07:00
var bleManager: BLEManager
@State var connectedToDevice = false
var body: some View {
VStack {
2022-10-12 22:15:15 -07:00
Text("Save Channel Settings?")
.font(.title)
2022-10-13 07:45:23 -07:00
Text("These settings will replace the current LoRa Config and Channel Settings on your radio. After everything saves your device will reboot.")
2022-10-12 22:15:15 -07:00
.foregroundColor(.gray)
.font(.callout)
.padding()
2022-10-13 07:45:23 -07:00
HStack {
2022-10-18 19:50:42 -07:00
Button {
let success = bleManager.saveChannelSet(base64UrlString: channelSetLink)
2022-10-19 16:58:49 -07:00
if success {
dismiss()
2022-10-19 16:58:49 -07:00
}
2022-10-18 19:50:42 -07:00
} label: {
Label("Save", systemImage: "square.and.arrow.down")
2022-10-10 21:21:58 -07:00
}
2022-10-18 19:50:42 -07:00
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.padding()
.disabled(!connectedToDevice)
#if targetEnvironment(macCatalyst)
Button {
dismiss()
} label: {
Label("Cancel", systemImage: "xmark")
}
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.padding()
#endif
}
2022-10-18 19:50:42 -07:00
}
.onAppear {
connectedToDevice = bleManager.connectToPreferredPeripheral()
2022-10-10 21:21:58 -07:00
}
}
}