Star for preferred peripheral

This commit is contained in:
Garth Vander Houwen 2023-03-14 20:45:09 -07:00
parent 94723c07c2
commit c5d6790bc6
3 changed files with 15 additions and 14 deletions

View file

@ -158,12 +158,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
isConnected = true
if userSettings?.preferredPeripheralId.count ?? 0 < 1 {
userSettings?.preferredPeripheralId = peripheral.identifier.uuidString
// preferredPeripheral = true
} else if userSettings!.preferredPeripheralId == peripheral.identifier.uuidString {
// preferredPeripheral = true
} else {
// preferredPeripheral = false
print("Trying to connect a non prefered peripheral")
}
UserDefaults.standard.synchronize()
// Invalidate and reset connection timer count

View file

@ -162,9 +162,16 @@ struct Connect: View {
Section(header: Text("available.radios").font(.title)) {
ForEach(bleManager.peripherals.filter({ $0.peripheral.state == CBPeripheralState.disconnected }).sorted(by: { $0.name > $1.name })) { peripheral in
HStack {
Image(systemName: "circle.fill")
.imageScale(.large).foregroundColor(.gray)
.padding(.trailing)
if userSettings.preferredPeripheralId == peripheral.peripheral.identifier.uuidString {
Image(systemName: "star.fill")
.imageScale(.large).foregroundColor(.yellow)
.padding(.trailing)
} else {
Image(systemName: "circle.fill")
.imageScale(.large).foregroundColor(.gray)
.padding(.trailing)
}
Button(action: {
if userSettings.preferredPeripheralId.count > 0 && peripheral.peripheral.identifier.uuidString != userSettings.preferredPeripheralId {
presentingSwitchPreferredPeripheral = true
@ -173,7 +180,7 @@ struct Connect: View {
self.bleManager.connectTo(peripheral: peripheral.peripheral)
}
}) {
Text(peripheral.name).font(.title3)
Text(peripheral.name).font(.callout)
}
Spacer()
VStack {

View file

@ -33,17 +33,17 @@ struct EnvironmentMetricsLog: View {
}
TableColumn("Humidity") { em in
if em.metricsType == 1 {
Text("\(String(format: "%.2f", em.relativeHumidity))")
Text("\(String(format: "%.2f", em.relativeHumidity))%")
}
}
TableColumn("Barometric Pressure") { em in
if em.metricsType == 1 {
Text("\(String(format: "%.2f", em.barometricPressure))")
Text("\(String(format: "%.2f", em.barometricPressure)) hPa")
}
}
TableColumn("gas.resistance") { em in
if em.metricsType == 1 {
Text("\(String(format: "%.2f", em.gasResistance))")
Text("\(String(format: "%.2f", em.gasResistance)) ohms")
}
}
TableColumn("current") { em in
@ -98,7 +98,7 @@ struct EnvironmentMetricsLog: View {
Text(em.temperature.formattedTemperature())
.font(.caption)
Text("\(String(format: "%.2f", em.relativeHumidity))")
Text("\(String(format: "%.2f", em.relativeHumidity))%")
.font(.caption)
Text("\(String(format: "%.2f", em.barometricPressure))")
.font(.caption)