Use more recognized icons
This commit is contained in:
@@ -14,16 +14,21 @@ struct RelayStatus: View {
|
|||||||
let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect()
|
let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect()
|
||||||
|
|
||||||
@State var conn_color: Color = .gray
|
@State var conn_color: Color = .gray
|
||||||
|
@State var conn_image: String = "wifi.slash"
|
||||||
|
@State var connecting: Bool = false
|
||||||
|
|
||||||
func update_connection_color() {
|
func update_connection() {
|
||||||
for relay in pool.relays {
|
for relay in pool.relays {
|
||||||
if relay.id == self.relay {
|
if relay.id == self.relay {
|
||||||
let c = relay.connection
|
let c = relay.connection
|
||||||
if c.isConnected {
|
if c.isConnected {
|
||||||
conn_color = .green
|
conn_image = "checkmark"
|
||||||
|
conn_color = .accentColor
|
||||||
} else if c.isConnecting || c.isReconnecting {
|
} else if c.isConnecting || c.isReconnecting {
|
||||||
conn_color = .yellow
|
connecting = true
|
||||||
} else {
|
} else {
|
||||||
|
//conn_image = "wifi.exclamationmark"
|
||||||
|
conn_image = "xmark"
|
||||||
conn_color = .red
|
conn_color = .red
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,15 +36,25 @@ struct RelayStatus: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Circle()
|
HStack {
|
||||||
.frame(width: 8.0, height: 8.0)
|
if connecting {
|
||||||
.foregroundColor(conn_color)
|
ProgressView()
|
||||||
.onReceive(timer) { _ in
|
.padding(.trailing, 5)
|
||||||
update_connection_color()
|
} else {
|
||||||
}
|
Image(systemName: conn_image)
|
||||||
.onAppear() {
|
.frame(width: 8.0, height: 8.0)
|
||||||
update_connection_color()
|
.foregroundColor(conn_color)
|
||||||
|
.padding(.leading, 5)
|
||||||
|
.padding(.trailing, 10)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.onReceive(timer) { _ in
|
||||||
|
update_connection()
|
||||||
|
}
|
||||||
|
.onAppear() {
|
||||||
|
update_connection()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user