Meshtastic-Apple/Meshtastic/Views/Settings/SaveChannelQRCode.swift
Garth Vander Houwen 0bea6f8fa3 handle base64 urls
2022-10-11 05:36:49 -07:00

53 lines
1 KiB
Swift

//
// SaveChannelQRCode.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 7/13/22.
//
import SwiftUI
struct SaveChannelQRCode: View {
var channelHash: String
var body: some View {
VStack {
Text("Save Channel Settings?")
.font(.title)
Text("These settings will replace the current settings on your radio.")
.foregroundColor(.gray)
.font(.callout)
.padding()
Text(channelHash)
.font(.caption2)
.padding()
Text("Error Message")
.font(.callout)
.foregroundColor(.red)
.padding()
Text("Swipe down to dismiss.")
.padding()
}
.onChange(of: channelHash) { newSettings in
var decodedString = newSettings.base64urlToBase64()
if let decodedData = Data(base64Encoded: decodedString) {
decodedString = String(data: decodedData, encoding: .utf8)!
do {
var channelSet: ChannelSet = try ChannelSet(serializedData: decodedData)
print(channelSet)
} catch {
print("Invalid Meshtastic QR Code Link")
}
}
}
}
}