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 {
2023-03-06 10:33:18 -08:00
@Environment(\.dismiss) private var dismiss
2023-03-06 10:33:18 -08:00
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()
2023-03-06 10:33:18 -08:00
HStack {
2023-03-06 10:33:18 -08:00
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
}
2023-03-06 10:33:18 -08:00
2022-10-18 19:50:42 -07:00
} label: {
2022-12-12 20:35:38 -08:00
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)
2023-03-06 10:33:18 -08:00
#if targetEnvironment(macCatalyst)
Button {
dismiss()
} label: {
2022-12-12 20:35:38 -08:00
Label("cancel", systemImage: "xmark")
2023-03-06 10:33:18 -08:00
}
.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
}
}
}