2021-09-22 13:00:46 -07:00
|
|
|
/*
|
|
|
|
|
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
|
|
|
|
2021-09-22 13:00:46 -07:00
|
|
|
HStack {
|
2021-10-07 22:51:40 -07:00
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
|
2021-10-07 22:51:40 -07:00
|
|
|
Image(systemName: "antenna.radiowaves.left.and.right.slash")
|
|
|
|
|
.imageScale(.medium)
|
|
|
|
|
.foregroundColor(.red)
|
|
|
|
|
.symbolRenderingMode(.hierarchical)
|
2021-11-29 15:59:06 -08:00
|
|
|
|
2021-09-22 13:00:46 -07:00
|
|
|
}
|
2021-11-29 15:59:06 -08:00
|
|
|
} else {
|
2021-10-07 22:51:40 -07:00
|
|
|
Text("Bluetooth Off").font(.subheadline).foregroundColor(.red)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-22 13:00:46 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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")
|
2021-09-22 13:00:46 -07:00
|
|
|
.previewLayout(.fixed(width: 80, height: 70))
|
|
|
|
|
}
|
2021-11-29 15:59:06 -08:00
|
|
|
|
2021-09-22 13:00:46 -07:00
|
|
|
}
|