mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Star for preferred peripheral
This commit is contained in:
parent
94723c07c2
commit
c5d6790bc6
3 changed files with 15 additions and 14 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue