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

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

View file

@ -76,6 +76,7 @@ struct PeersView: View {
}
}
TextField("Multicast password", text: $appDelegate.yggdrasilConfig.multicastPassword)
.labelStyle(.titleAndIcon)
}, header: {
Text("Local connectivity")
})

View file

@ -34,6 +34,7 @@ struct SettingsView: View {
Text("Automatically start when connected to")
})
/*
Section(content: {
VStack(alignment: .leading) {
Button("Import configuration") {
@ -76,6 +77,7 @@ struct SettingsView: View {
}, header: {
Text("Configuration")
})
*/
}
.formStyle(.grouped)
.navigationTitle("Settings")

View file

@ -22,13 +22,12 @@ struct StatusView: View {
private func getStatusBadgeColor() -> SwiftUI.Color {
if !appDelegate.yggdrasilSupported {
return .gray
} else if !appDelegate.yggdrasilEnabled {
return .gray
} else if !appDelegate.yggdrasilConnected {
return .yellow
} else {
} else if appDelegate.yggdrasilConnected {
return .green
} else if appDelegate.yggdrasilEnabled {
return .yellow
}
return .gray
}
private func getStatusBadgeText() -> String {
@ -39,7 +38,7 @@ struct StatusView: View {
} else if !appDelegate.yggdrasilConnected {
return "No peers connected"
} else {
return "Connected to \(appDelegate.yggdrasilPeers.count) peer(s)"
return "Connected to \(appDelegate.yggdrasilPeers.filter { $0.up }.count) peer(s)"
}
}
@ -49,6 +48,7 @@ struct StatusView: View {
VStack(alignment: .leading) {
Toggle("Enable Yggdrasil", isOn: $appDelegate.yggdrasilEnabled)
.disabled(!appDelegate.yggdrasilSupported)
.padding(.bottom, 2)
HStack {
Image(systemName: "circlebadge.fill")
.foregroundColor(statusBadgeColor)
@ -116,15 +116,6 @@ struct StatusView: View {
.lineLimit(1)
.textSelection(.enabled)
}
/*HStack {
Text("Coordinates")
Spacer()
Text(appDelegate.yggdrasilCoords)
.foregroundColor(Color.gray)
.truncationMode(.tail)
.lineLimit(1)
.textSelection(.enabled)
}*/
HStack {
Text("Public Key")
Spacer()
@ -139,10 +130,20 @@ struct StatusView: View {
Text("Details")
})
if self.appDelegate.yggdrasilEnabled {
Section(content: {
Section(content: {
if self.appDelegate.yggdrasilPeers.count == 0 {
Text("No peers are connected")
.foregroundStyle(.tertiary)
.frame(maxWidth: .infinity, alignment: .center)
} else {
List(self.appDelegate.yggdrasilPeers.sorted(by: { a, b in
a.key < a.key
if a.up && !b.up {
return true
}
if !a.up && b.up {
return false
}
return a.remote < b.remote
}), id: \.remote) { peer in
VStack {
Text(peer.remote)
@ -150,20 +151,30 @@ struct StatusView: View {
.truncationMode(.tail)
.lineLimit(1)
.textSelection(.enabled)
Text(peer.address)
.frame(maxWidth: .infinity, alignment: .leading)
.foregroundColor(Color.gray)
.font(.system(size: 11, design: .monospaced))
.truncationMode(.tail)
.lineLimit(1)
.textSelection(.enabled)
.padding(.bottom, 2)
HStack {
Image(systemName: "circlebadge.fill")
.foregroundColor(peer.getStatusBadgeColor())
.onChange(of: peer.up) { newValue in
statusBadgeColor = peer.getStatusBadgeColor()
}
Text(peer.up ? peer.address ?? "Unknown IP address" : "Not connected")
.frame(maxWidth: .infinity, alignment: .leading)
.foregroundColor(Color.gray)
.font(.system(size: 11))
.truncationMode(.tail)
.lineLimit(1)
.textSelection(.enabled)
}
}
.padding(.all, 2)
.padding(.top, 4)
.padding(.bottom, 4)
}
}, header: {
Text("Peers")
})
}
}
}, header: {
Text("Peers")
})
}
.formStyle(.grouped)
.navigationTitle("Yggdrasil")