More updates

This commit is contained in:
Neil Alexander 2024-04-16 22:51:06 +01:00
parent 5fbb735f56
commit 0bea3a1613
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
9 changed files with 150 additions and 38 deletions

View file

@ -6,6 +6,7 @@
//
import Foundation
import SwiftUI
struct YggdrasilSummary: Codable {
var address: String
@ -17,14 +18,18 @@ struct YggdrasilSummary: Codable {
func list() -> [String] {
return peers.map { $0.remote }
}
func listUp() -> [String] {
return peers.filter { $0.up }.map { $0.remote }
}
}
struct YggdrasilPeer: Codable, Identifiable {
var id: String { remote } // For Identifiable protocol
let remote: String
let up: Bool
let address: String
let key: String
let address: String?
let key: String?
let priority: UInt8
let cost: UInt16?
@ -36,4 +41,11 @@ struct YggdrasilPeer: Codable, Identifiable {
case priority = "Priority"
case cost = "Cost"
}
public func getStatusBadgeColor() -> SwiftUI.Color {
if self.up {
return .green
}
return .gray
}
}