2022-07-14 07:14:43 -07:00
|
|
|
//
|
|
|
|
|
// SaveChannelQRCode.swift
|
|
|
|
|
// Meshtastic
|
|
|
|
|
//
|
|
|
|
|
// Copyright(c) Garth Vander Houwen 7/13/22.
|
|
|
|
|
//
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
|
|
struct SaveChannelQRCode: View {
|
2023-03-06 10:33:18 -08:00
|
|
|
|
2022-11-08 23:18:50 -08:00
|
|
|
@Environment(\.dismiss) private var dismiss
|
2023-03-06 10:33:18 -08:00
|
|
|
|
2022-10-18 20:25:11 -07:00
|
|
|
var channelSetLink: String
|
2022-10-18 19:50:42 -07:00
|
|
|
var bleManager: BLEManager
|
|
|
|
|
@State var connectedToDevice = false
|
|
|
|
|
|
2022-07-14 07:14:43 -07:00
|
|
|
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
|
|
|
|
2022-11-08 22:01:32 -08:00
|
|
|
HStack {
|
2023-03-06 10:33:18 -08:00
|
|
|
|
2022-10-18 19:50:42 -07:00
|
|
|
Button {
|
2022-10-18 20:25:11 -07:00
|
|
|
let success = bleManager.saveChannelSet(base64UrlString: channelSetLink)
|
2022-10-19 16:58:49 -07:00
|
|
|
if success {
|
2022-11-08 23:18:50 -08:00
|
|
|
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
|
|
|
|
2022-11-08 22:01:32 -08:00
|
|
|
#if targetEnvironment(macCatalyst)
|
|
|
|
|
Button {
|
2022-11-08 23:18:50 -08:00
|
|
|
dismiss()
|
2022-11-08 22:01:32 -08:00
|
|
|
} label: {
|
2022-12-12 20:35:38 -08:00
|
|
|
Label("cancel", systemImage: "xmark")
|
2023-03-06 10:33:18 -08:00
|
|
|
|
2022-11-08 22:01:32 -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
|
|
|
}
|
2022-07-14 07:14:43 -07:00
|
|
|
}
|
|
|
|
|
}
|