mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Start of QR Code, updated protobufs
This commit is contained in:
parent
2145f43a42
commit
8171b84272
8 changed files with 292 additions and 27 deletions
|
|
@ -26,7 +26,8 @@
|
|||
DD5394FE276BA0EF00AD86B1 /* PositionEntityExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD5394FD276BA0EF00AD86B1 /* PositionEntityExtension.swift */; };
|
||||
DD539502276DAA6A00AD86B1 /* MapLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD539501276DAA6A00AD86B1 /* MapLocation.swift */; };
|
||||
DD6B85A62800915B000ACD6B /* CarBode in Frameworks */ = {isa = PBXBuildFile; productRef = DD6B85A52800915B000ACD6B /* CarBode */; };
|
||||
DD6B85A828009258000ACD6B /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6B85A728009258000ACD6B /* Channel.swift */; };
|
||||
DD6B85A828009258000ACD6B /* ShareChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6B85A728009258000ACD6B /* ShareChannel.swift */; };
|
||||
DD6B85AA2800DFE5000ACD6B /* QRCamera.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6B85A92800DFE5000ACD6B /* QRCamera.swift */; };
|
||||
DD8169F9271F1A6100F4AB02 /* MeshLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8169F8271F1A6100F4AB02 /* MeshLogger.swift */; };
|
||||
DD8169FB271F1F3A00F4AB02 /* MeshLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8169FA271F1F3A00F4AB02 /* MeshLog.swift */; };
|
||||
DD8169FF272476C700F4AB02 /* LogDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8169FE272476C700F4AB02 /* LogDocument.swift */; };
|
||||
|
|
@ -93,7 +94,8 @@
|
|||
DD4DED8F27AD2975004BA27E /* cannedmessages.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = cannedmessages.pb.swift; sourceTree = "<group>"; };
|
||||
DD5394FD276BA0EF00AD86B1 /* PositionEntityExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PositionEntityExtension.swift; sourceTree = "<group>"; };
|
||||
DD539501276DAA6A00AD86B1 /* MapLocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapLocation.swift; sourceTree = "<group>"; };
|
||||
DD6B85A728009258000ACD6B /* Channel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Channel.swift; sourceTree = "<group>"; };
|
||||
DD6B85A728009258000ACD6B /* ShareChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareChannel.swift; sourceTree = "<group>"; };
|
||||
DD6B85A92800DFE5000ACD6B /* QRCamera.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCamera.swift; sourceTree = "<group>"; };
|
||||
DD8169F8271F1A6100F4AB02 /* MeshLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshLogger.swift; sourceTree = "<group>"; };
|
||||
DD8169FA271F1F3A00F4AB02 /* MeshLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshLog.swift; sourceTree = "<group>"; };
|
||||
DD8169FE272476C700F4AB02 /* LogDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogDocument.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -204,7 +206,7 @@
|
|||
DD4A911D2708C65400501B7E /* AppSettings.swift */,
|
||||
DD8169FA271F1F3A00F4AB02 /* MeshLog.swift */,
|
||||
DD8169FE272476C700F4AB02 /* LogDocument.swift */,
|
||||
DD6B85A728009258000ACD6B /* Channel.swift */,
|
||||
DD6B85A728009258000ACD6B /* ShareChannel.swift */,
|
||||
);
|
||||
path = Settings;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -348,6 +350,7 @@
|
|||
DD47E3D826F3093800029299 /* MessageBubble.swift */,
|
||||
DD90860B26F684AF00DC5189 /* BatteryIcon.swift */,
|
||||
DDF924C926FBB953009FE055 /* ConnectedDevice.swift */,
|
||||
DD6B85A92800DFE5000ACD6B /* QRCamera.swift */,
|
||||
);
|
||||
path = Helpers;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -536,12 +539,13 @@
|
|||
files = (
|
||||
DD4DED9027AD2975004BA27E /* cannedmessages.pb.swift in Sources */,
|
||||
DD836AE726F6B38600ABCC23 /* Connect.swift in Sources */,
|
||||
DD6B85AA2800DFE5000ACD6B /* QRCamera.swift in Sources */,
|
||||
DDAF8C6E26ED19040058C060 /* Extensions.swift in Sources */,
|
||||
DDC2E1A726CEB3400042C5E4 /* LocationHelper.swift in Sources */,
|
||||
DDAF8C5F26ED09B50058C060 /* radioconfig.pb.swift in Sources */,
|
||||
DD5394FE276BA0EF00AD86B1 /* PositionEntityExtension.swift in Sources */,
|
||||
DD913639270DFF4C00D7ACF3 /* LocalNotificationManager.swift in Sources */,
|
||||
DD6B85A828009258000ACD6B /* Channel.swift in Sources */,
|
||||
DD6B85A828009258000ACD6B /* ShareChannel.swift in Sources */,
|
||||
DDAF8C5326EB1DF10058C060 /* BLEManager.swift in Sources */,
|
||||
DDC4D568275499A500A4208E /* Persistence.swift in Sources */,
|
||||
DD90860E26F69BAE00DC5189 /* NodeMap.swift in Sources */,
|
||||
|
|
@ -745,6 +749,7 @@
|
|||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = MeshtasticClient/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 15.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
|
|
@ -776,6 +781,7 @@
|
|||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = MeshtasticClient/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 15.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
|
|
|
|||
|
|
@ -384,6 +384,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
switch characteristic.uuid {
|
||||
|
||||
case FROMRADIO_UUID:
|
||||
|
||||
if characteristic.value == nil || characteristic.value!.isEmpty {
|
||||
return
|
||||
}
|
||||
|
|
@ -405,6 +406,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
let myInfo = MyInfoEntity(context: context!)
|
||||
myInfo.myNodeNum = Int64(decodedInfo.myInfo.myNodeNum)
|
||||
myInfo.hasGps = decodedInfo.myInfo.hasGps_p
|
||||
myInfo.bitrate = decodedInfo.myInfo.bitrate
|
||||
|
||||
// Swift does strings weird, this does work to get the version without the github hash
|
||||
let lastDotIndex = decodedInfo.myInfo.firmwareVersion.lastIndex(of: ".")
|
||||
|
|
@ -437,6 +439,18 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
print("💾 Saved the All - Broadcast User")
|
||||
}
|
||||
|
||||
var settingsCalled = self.getSettings()
|
||||
|
||||
if settingsCalled {
|
||||
|
||||
print("💾 Called Get Settings")
|
||||
|
||||
} else {
|
||||
|
||||
print("💥 Get Settings Call Failed")
|
||||
}
|
||||
|
||||
|
||||
} catch {
|
||||
|
||||
print("💥 Error Saving the All - Broadcast User")
|
||||
|
|
@ -1146,6 +1160,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
return success
|
||||
}
|
||||
|
||||
// Send Position
|
||||
public func sendPosition(destNum: Int64, wantResponse: Bool) -> Bool {
|
||||
|
||||
var success = false
|
||||
|
|
@ -1223,4 +1238,40 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Device Settings
|
||||
public func getSettings() -> Bool {
|
||||
|
||||
var adminPacket = AdminMessage()
|
||||
adminPacket.getRadioRequest = true
|
||||
|
||||
var meshPacket: MeshPacket = MeshPacket()
|
||||
meshPacket.to = UInt32(connectedPeripheral.num)
|
||||
meshPacket.from = UInt32(connectedPeripheral.num)
|
||||
meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
|
||||
meshPacket.priority = MeshPacket.Priority.reliable
|
||||
meshPacket.wantAck = true
|
||||
meshPacket.hopLimit = 0
|
||||
|
||||
var dataMessage = DataMessage()
|
||||
dataMessage.payload = try! adminPacket.serializedData()
|
||||
dataMessage.portnum = PortNum.adminApp
|
||||
|
||||
meshPacket.decoded = dataMessage
|
||||
|
||||
var toRadio: ToRadio!
|
||||
toRadio = ToRadio()
|
||||
toRadio.packet = meshPacket
|
||||
|
||||
let binaryData: Data = try! toRadio.serializedData()
|
||||
|
||||
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
|
||||
|
||||
connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,14 @@ enum HardwareModel: SwiftProtobuf.Enum {
|
|||
/// RAK WisBlock ESP32 core: https://docs.rakwireless.com/Product-Categories/WisBlock/RAK11200/Overview/
|
||||
case rak11200 // = 40
|
||||
|
||||
///
|
||||
/// B&Q Consulting Nano Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:nano
|
||||
case nanoG1 // = 41
|
||||
|
||||
///
|
||||
/// nRF52840 Dongle : https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dongle/
|
||||
case nrf52840Pca10059 // = 42
|
||||
|
||||
///
|
||||
/// Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits.
|
||||
case privateHw // = 255
|
||||
|
|
@ -146,6 +154,8 @@ enum HardwareModel: SwiftProtobuf.Enum {
|
|||
case 38: self = .androidSim
|
||||
case 39: self = .diyV1
|
||||
case 40: self = .rak11200
|
||||
case 41: self = .nanoG1
|
||||
case 42: self = .nrf52840Pca10059
|
||||
case 255: self = .privateHw
|
||||
default: self = .UNRECOGNIZED(rawValue)
|
||||
}
|
||||
|
|
@ -174,6 +184,8 @@ enum HardwareModel: SwiftProtobuf.Enum {
|
|||
case .androidSim: return 38
|
||||
case .diyV1: return 39
|
||||
case .rak11200: return 40
|
||||
case .nanoG1: return 41
|
||||
case .nrf52840Pca10059: return 42
|
||||
case .privateHw: return 255
|
||||
case .UNRECOGNIZED(let i): return i
|
||||
}
|
||||
|
|
@ -207,6 +219,8 @@ extension HardwareModel: CaseIterable {
|
|||
.androidSim,
|
||||
.diyV1,
|
||||
.rak11200,
|
||||
.nanoG1,
|
||||
.nrf52840Pca10059,
|
||||
.privateHw,
|
||||
]
|
||||
}
|
||||
|
|
@ -2293,6 +2307,8 @@ extension HardwareModel: SwiftProtobuf._ProtoNameProviding {
|
|||
38: .same(proto: "ANDROID_SIM"),
|
||||
39: .same(proto: "DIY_V1"),
|
||||
40: .same(proto: "RAK11200"),
|
||||
41: .same(proto: "NANO_G1"),
|
||||
42: .same(proto: "NRF52840_PCA10059"),
|
||||
255: .same(proto: "PRIVATE_HW"),
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -704,13 +704,6 @@ struct RadioConfig {
|
|||
set {_uniqueStorage()._positionBroadcastSmartDisabled = newValue}
|
||||
}
|
||||
|
||||
///
|
||||
/// Send our owner info at least this often (also we always send once at boot - to rejoin the mesh)
|
||||
var sendOwnerInterval: UInt32 {
|
||||
get {return _storage._sendOwnerInterval}
|
||||
set {_uniqueStorage()._sendOwnerInterval = newValue}
|
||||
}
|
||||
|
||||
///
|
||||
/// Power management state machine option.
|
||||
/// See [power management](/docs/software/other/power) for details.
|
||||
|
|
@ -1741,7 +1734,6 @@ extension RadioConfig.UserPreferences: SwiftProtobuf.Message, SwiftProtobuf._Mes
|
|||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .standard(proto: "position_broadcast_secs"),
|
||||
17: .standard(proto: "position_broadcast_smart_disabled"),
|
||||
2: .standard(proto: "send_owner_interval"),
|
||||
4: .standard(proto: "wait_bluetooth_secs"),
|
||||
5: .standard(proto: "screen_on_secs"),
|
||||
6: .standard(proto: "phone_timeout_secs"),
|
||||
|
|
@ -1829,7 +1821,6 @@ extension RadioConfig.UserPreferences: SwiftProtobuf.Message, SwiftProtobuf._Mes
|
|||
fileprivate class _StorageClass {
|
||||
var _positionBroadcastSecs: UInt32 = 0
|
||||
var _positionBroadcastSmartDisabled: Bool = false
|
||||
var _sendOwnerInterval: UInt32 = 0
|
||||
var _waitBluetoothSecs: UInt32 = 0
|
||||
var _screenOnSecs: UInt32 = 0
|
||||
var _phoneTimeoutSecs: UInt32 = 0
|
||||
|
|
@ -1920,7 +1911,6 @@ extension RadioConfig.UserPreferences: SwiftProtobuf.Message, SwiftProtobuf._Mes
|
|||
init(copying source: _StorageClass) {
|
||||
_positionBroadcastSecs = source._positionBroadcastSecs
|
||||
_positionBroadcastSmartDisabled = source._positionBroadcastSmartDisabled
|
||||
_sendOwnerInterval = source._sendOwnerInterval
|
||||
_waitBluetoothSecs = source._waitBluetoothSecs
|
||||
_screenOnSecs = source._screenOnSecs
|
||||
_phoneTimeoutSecs = source._phoneTimeoutSecs
|
||||
|
|
@ -2022,7 +2012,6 @@ extension RadioConfig.UserPreferences: SwiftProtobuf.Message, SwiftProtobuf._Mes
|
|||
// enabled. https://github.com/apple/swift-protobuf/issues/1034
|
||||
switch fieldNumber {
|
||||
case 1: try { try decoder.decodeSingularUInt32Field(value: &_storage._positionBroadcastSecs) }()
|
||||
case 2: try { try decoder.decodeSingularUInt32Field(value: &_storage._sendOwnerInterval) }()
|
||||
case 4: try { try decoder.decodeSingularUInt32Field(value: &_storage._waitBluetoothSecs) }()
|
||||
case 5: try { try decoder.decodeSingularUInt32Field(value: &_storage._screenOnSecs) }()
|
||||
case 6: try { try decoder.decodeSingularUInt32Field(value: &_storage._phoneTimeoutSecs) }()
|
||||
|
|
@ -2117,9 +2106,6 @@ extension RadioConfig.UserPreferences: SwiftProtobuf.Message, SwiftProtobuf._Mes
|
|||
if _storage._positionBroadcastSecs != 0 {
|
||||
try visitor.visitSingularUInt32Field(value: _storage._positionBroadcastSecs, fieldNumber: 1)
|
||||
}
|
||||
if _storage._sendOwnerInterval != 0 {
|
||||
try visitor.visitSingularUInt32Field(value: _storage._sendOwnerInterval, fieldNumber: 2)
|
||||
}
|
||||
if _storage._waitBluetoothSecs != 0 {
|
||||
try visitor.visitSingularUInt32Field(value: _storage._waitBluetoothSecs, fieldNumber: 4)
|
||||
}
|
||||
|
|
@ -2380,7 +2366,6 @@ extension RadioConfig.UserPreferences: SwiftProtobuf.Message, SwiftProtobuf._Mes
|
|||
let rhs_storage = _args.1
|
||||
if _storage._positionBroadcastSecs != rhs_storage._positionBroadcastSecs {return false}
|
||||
if _storage._positionBroadcastSmartDisabled != rhs_storage._positionBroadcastSmartDisabled {return false}
|
||||
if _storage._sendOwnerInterval != rhs_storage._sendOwnerInterval {return false}
|
||||
if _storage._waitBluetoothSecs != rhs_storage._waitBluetoothSecs {return false}
|
||||
if _storage._screenOnSecs != rhs_storage._screenOnSecs {return false}
|
||||
if _storage._phoneTimeoutSecs != rhs_storage._phoneTimeoutSecs {return false}
|
||||
|
|
|
|||
133
MeshtasticClient/Views/Helpers/QRCamera.swift
Normal file
133
MeshtasticClient/Views/Helpers/QRCamera.swift
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
//
|
||||
// QRCamera.swift
|
||||
// MeshtasticClient
|
||||
//
|
||||
// Created by Garth Vander Houwen on 4/8/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CarBode
|
||||
import AVFoundation
|
||||
|
||||
struct cameraFrame: Shape {
|
||||
func path(in rect: CGRect) -> Path {
|
||||
Path { path in
|
||||
let width = rect.width
|
||||
let height = rect.height
|
||||
|
||||
path.addLines( [
|
||||
|
||||
CGPoint(x: 0, y: height * 0.25),
|
||||
CGPoint(x: 0, y: 0),
|
||||
CGPoint(x:width * 0.25, y:0)
|
||||
])
|
||||
|
||||
path.addLines( [
|
||||
|
||||
CGPoint(x: width * 0.75, y: 0),
|
||||
CGPoint(x: width, y: 0),
|
||||
CGPoint(x:width, y:height * 0.25)
|
||||
])
|
||||
|
||||
path.addLines( [
|
||||
|
||||
CGPoint(x: width, y: height * 0.75),
|
||||
CGPoint(x: width, y: height),
|
||||
CGPoint(x:width * 0.75, y: height)
|
||||
])
|
||||
|
||||
path.addLines( [
|
||||
|
||||
CGPoint(x:width * 0.25, y: height),
|
||||
CGPoint(x:0, y: height),
|
||||
CGPoint(x:0, y:height * 0.75)
|
||||
|
||||
])
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct QRCamera: View {
|
||||
@State var barcodeValue = ""
|
||||
@State var torchIsOn = false
|
||||
@State var showingAlert = false
|
||||
@State var cameraPosition = AVCaptureDevice.Position.back
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text("QRCode Scanner")
|
||||
|
||||
Spacer()
|
||||
|
||||
if cameraPosition == .back{
|
||||
Text("Using back camera")
|
||||
}else{
|
||||
Text("Using front camera")
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
if cameraPosition == .back {
|
||||
cameraPosition = .front
|
||||
}else{
|
||||
cameraPosition = .back
|
||||
}
|
||||
}) {
|
||||
if cameraPosition == .back{
|
||||
Text("Switch Camera to Front")
|
||||
}else{
|
||||
Text("Switch Camera to Back")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Button(action: {
|
||||
self.torchIsOn.toggle()
|
||||
}) {
|
||||
Text("Toggle Torch Light")
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
CBScanner(
|
||||
supportBarcode: .constant([.qr, .code128]),
|
||||
torchLightIsOn: $torchIsOn,
|
||||
cameraPosition: $cameraPosition,
|
||||
mockBarCode: .constant(BarcodeData(value:"My Test Data", type: .qr))
|
||||
){
|
||||
print("BarCodeType =",$0.type.rawValue, "Value =",$0.value)
|
||||
barcodeValue = $0.value
|
||||
}
|
||||
onDraw: {
|
||||
print("Preview View Size = \($0.cameraPreviewView.bounds)")
|
||||
print("Barcode Corners = \($0.corners)")
|
||||
|
||||
let lineColor = UIColor.green
|
||||
let fillColor = UIColor(red: 0, green: 1, blue: 0.2, alpha: 0.4)
|
||||
//Draw Barcode corner
|
||||
$0.draw(lineWidth: 1, lineColor: lineColor, fillColor: fillColor)
|
||||
|
||||
}.frame(minWidth: 0, maxWidth: .infinity, minHeight: 400, maxHeight: 400, alignment: .topLeading)
|
||||
.overlay(cameraFrame()
|
||||
.stroke(lineWidth: 5)
|
||||
.frame(width: 500, height: 250)
|
||||
.foregroundColor(.blue))
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(barcodeValue)
|
||||
|
||||
Spacer()
|
||||
|
||||
}.alert(isPresented: $showingAlert) {
|
||||
Alert(title: Text("Found Barcode"), message: Text("\(barcodeValue)"), dismissButton: .default(Text("Close")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ModalScannerView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
QRCamera()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +206,13 @@ struct AppSettings: View {
|
|||
.listRowSeparator(.visible)
|
||||
}
|
||||
}
|
||||
Section(header: Text("MESH OPTIONS")) {
|
||||
|
||||
NavigationLink(destination: ShareChannel()) {
|
||||
Text("Share Your Channel vis QR Code")
|
||||
}
|
||||
|
||||
}
|
||||
Section(header: Text("MESSAGING OPTIONS")) {
|
||||
|
||||
Picker("Keyboard Type", selection: $userSettings.keyboardType) {
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
//
|
||||
// Channel.swift
|
||||
// MeshtasticClient
|
||||
//
|
||||
// Created by Garth Vander Houwen on 4/8/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
75
MeshtasticClient/Views/Settings/ShareChannel.swift
Normal file
75
MeshtasticClient/Views/Settings/ShareChannel.swift
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
//
|
||||
// Channel.swift
|
||||
// MeshtasticClient
|
||||
//
|
||||
// Created by Garth Vander Houwen on 4/8/22.
|
||||
//
|
||||
import SwiftUI
|
||||
import CoreData
|
||||
import CarBode
|
||||
|
||||
|
||||
struct ShareChannel: View {
|
||||
|
||||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@EnvironmentObject var userSettings: UserSettings
|
||||
|
||||
|
||||
@State var dataString = "Hello Carbode"
|
||||
@State var barcodeType = CBBarcodeView.BarcodeType.qrCode
|
||||
@State var rotate = CBBarcodeView.Orientation.up
|
||||
|
||||
@State var barcodeImage: UIImage?
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
||||
HStack {
|
||||
|
||||
GeometryReader { bounds in
|
||||
|
||||
ScrollView {
|
||||
|
||||
VStack {
|
||||
|
||||
let smallest = min(bounds.size.width, bounds.size.height)
|
||||
|
||||
Text("Channel Name").font(.largeTitle)
|
||||
CBBarcodeView(data: $dataString,
|
||||
barcodeType: $barcodeType,
|
||||
orientation: $rotate)
|
||||
{ image in
|
||||
self.barcodeImage = image
|
||||
}.frame(
|
||||
minWidth: smallest * 0.9,
|
||||
maxWidth: smallest * 0.9,
|
||||
minHeight: smallest * 0.9,
|
||||
maxHeight: smallest * 0.9,
|
||||
alignment: .topLeading
|
||||
)
|
||||
.padding(.bottom)
|
||||
Text("Channel Details").font(.title)
|
||||
|
||||
Text("Some helpful text about how this whole thing works goes here, also could add a share sheet icon and pass the link around.")
|
||||
Spacer()
|
||||
Text("Some helpful text about how this whole thing works goes here, also could add a share sheet icon and pass the link around.")
|
||||
}
|
||||
}
|
||||
}.padding()
|
||||
}
|
||||
.navigationTitle("Share Channel")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarItems(trailing:
|
||||
|
||||
ZStack {
|
||||
|
||||
ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "???")
|
||||
})
|
||||
.onAppear {
|
||||
|
||||
self.bleManager.context = context
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue