Meshtastic-Apple/MeshtasticClient/Views/Helpers/ConnectedDevice.swift

49 lines
1.4 KiB
Swift
Raw Normal View History

/*
Abstract:
A view draws the indicator used in the upper right corner for views using BLE
*/
import SwiftUI
struct ConnectedDevice: View {
var bluetoothOn: Bool
var deviceConnected: Bool
var name: String?
var body: some View {
2021-11-29 15:59:06 -08:00
HStack {
if bluetoothOn {
if deviceConnected {
Image(systemName: "antenna.radiowaves.left.and.right.circle.fill")
.imageScale(.large)
.foregroundColor(.green)
.symbolRenderingMode(.hierarchical)
Text(name!).font(.subheadline).foregroundColor(.gray)
2021-11-29 15:59:06 -08:00
} else {
Image(systemName: "antenna.radiowaves.left.and.right.slash")
.imageScale(.medium)
.foregroundColor(.red)
.symbolRenderingMode(.hierarchical)
2021-11-29 15:59:06 -08:00
}
2021-11-29 15:59:06 -08:00
} else {
Text("Bluetooth Off").font(.subheadline).foregroundColor(.red)
}
}
}
}
struct ConnectedDevice_Previews: PreviewProvider {
static var previews: some View {
ConnectedDevice(bluetoothOn: true, deviceConnected: false, name: "Yellow Beam")
.previewLayout(.fixed(width: 80, height: 70))
2021-11-29 15:59:06 -08:00
ConnectedDevice(bluetoothOn: true, deviceConnected: false, name: "Yellow Beam")
.previewLayout(.fixed(width: 80, height: 70))
}
2021-11-29 15:59:06 -08:00
}