Add mqtt status icon in channels with uplink/downlink enabled

This commit is contained in:
Matthew Davies 2024-03-29 15:04:00 -07:00
parent dc449cc3f8
commit 769a35c485
No known key found for this signature in database
GPG key ID: 4B0314C2EFD91AC7
2 changed files with 8 additions and 4 deletions

View file

@ -9,6 +9,7 @@ struct ConnectedDevice: View {
var bluetoothOn: Bool
var deviceConnected: Bool
var name: String
var mqttProxyEnabled: Bool = false
var mqttProxyConnected: Bool = false
var phoneOnly: Bool = false
@ -18,11 +19,11 @@ struct ConnectedDevice: View {
if (phoneOnly && UIDevice.current.userInterfaceIdiom == .phone) || !phoneOnly {
if bluetoothOn {
if deviceConnected && mqttProxyConnected {
if mqttProxyConnected {
if deviceConnected && (mqttProxyEnabled || mqttProxyConnected) {
if (mqttProxyConnected || mqttProxyEnabled) {
Image(systemName: "iphone.gen3.radiowaves.left.and.right.circle.fill")
.imageScale(.large)
.foregroundColor(.green)
.foregroundColor(mqttProxyConnected ? .green : .gray)
.symbolRenderingMode(.hierarchical)
}
}

View file

@ -156,7 +156,10 @@ struct ChannelMessageList: View {
ConnectedDevice(
bluetoothOn: bleManager.isSwitchedOn,
deviceConnected: bleManager.connectedPeripheral != nil,
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?")
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?",
mqttProxyEnabled: channel.uplinkEnabled || channel.downlinkEnabled,
mqttProxyConnected: channel.uplinkEnabled || channel.downlinkEnabled ? bleManager.mqttProxyConnected : false
)
}
}
}