From 5e972dbf2dfb770524c9f2cbee97ea5adc899929 Mon Sep 17 00:00:00 2001 From: ericholguin Date: Thu, 23 Mar 2023 23:55:40 -0600 Subject: [PATCH] Use more recognized icons --- damus/Views/Relays/RelayStatus.swift | 37 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/damus/Views/Relays/RelayStatus.swift b/damus/Views/Relays/RelayStatus.swift index 47cada28..b05187aa 100644 --- a/damus/Views/Relays/RelayStatus.swift +++ b/damus/Views/Relays/RelayStatus.swift @@ -14,16 +14,21 @@ struct RelayStatus: View { let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect() @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 { if relay.id == self.relay { let c = relay.connection if c.isConnected { - conn_color = .green + conn_image = "checkmark" + conn_color = .accentColor } else if c.isConnecting || c.isReconnecting { - conn_color = .yellow + connecting = true } else { + //conn_image = "wifi.exclamationmark" + conn_image = "xmark" conn_color = .red } } @@ -31,15 +36,25 @@ struct RelayStatus: View { } var body: some View { - Circle() - .frame(width: 8.0, height: 8.0) - .foregroundColor(conn_color) - .onReceive(timer) { _ in - update_connection_color() - } - .onAppear() { - update_connection_color() + HStack { + if connecting { + ProgressView() + .padding(.trailing, 5) + } else { + Image(systemName: conn_image) + .frame(width: 8.0, height: 8.0) + .foregroundColor(conn_color) + .padding(.leading, 5) + .padding(.trailing, 10) } + } + .onReceive(timer) { _ in + update_connection() + } + .onAppear() { + update_connection() + } + } }