mirror of
https://github.com/yggdrasil-network/yggdrasil-ios.git
synced 2025-04-28 14:15:09 +03:00
App updates
This commit is contained in:
parent
2cb5eebcd2
commit
5fbb735f56
9 changed files with 204 additions and 91 deletions
|
@ -23,7 +23,7 @@ struct Application: App {
|
|||
var body: some Scene {
|
||||
WindowGroup {
|
||||
NavigationSplitView {
|
||||
ZStack {
|
||||
VStack {
|
||||
List(selection: $selection) {
|
||||
NavigationLink(destination: StatusView()) {
|
||||
HStack {
|
||||
|
|
|
@ -8,22 +8,25 @@
|
|||
import SwiftUI
|
||||
|
||||
struct PeersView: View {
|
||||
// @Binding public var yggdrasilConfiguration: ConfigurationProxy
|
||||
@ObservedObject private var appDelegate = Application.appDelegate
|
||||
#if os(iOS)
|
||||
@Environment(\.editMode) var editMode
|
||||
#endif
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section(content: {
|
||||
ForEach(Array(appDelegate.yggdrasilConfig.peers.enumerated()), id: \.offset) { index, peer in
|
||||
HStack() {
|
||||
Text(peer)
|
||||
//TextField("", text: $yggdrasilConfiguration.peers[index])
|
||||
// .multilineTextAlignment(.leading)
|
||||
TextField("Peer", text: $appDelegate.yggdrasilConfig.peers[index])
|
||||
.labelsHidden()
|
||||
#if os(iOS)
|
||||
.disabled(!editMode!.wrappedValue.isEditing)
|
||||
#endif
|
||||
#if os(macOS)
|
||||
Spacer()
|
||||
Button(role: .destructive) {
|
||||
// appDelegate.yggdrasilConfig.peers.remove { $0 == peerURI }
|
||||
// self.delete(at: appDelegate.yggdrasilConfig.peers.firstIndex { $0 == peerURI })
|
||||
appDelegate.yggdrasilConfig.peers.remove(at: index)
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
}
|
||||
|
@ -38,13 +41,15 @@ struct PeersView: View {
|
|||
appDelegate.yggdrasilConfig.peers.remove(atOffsets: indexSet)
|
||||
}
|
||||
|
||||
#if os(macOS)
|
||||
Button {
|
||||
appDelegate.yggdrasilConfig.peers.append("foo")
|
||||
appDelegate.yggdrasilConfig.peers.append("")
|
||||
} label: {
|
||||
Label("Add peer", systemImage: "plus")
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundColor(.accentColor)
|
||||
#endif
|
||||
|
||||
Text("Yggdrasil will automatically attempt to connect to configured peers when started. If you configure more than one peer, your device may carry traffic on behalf of other network nodes. Avoid this by configuring only a single peer. Data charges may apply when using mobile data.")
|
||||
.font(.system(size: 11))
|
||||
|
@ -70,20 +75,27 @@ struct PeersView: View {
|
|||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
TextField("Multicast password", text: $appDelegate.yggdrasilConfig.multicastPassword)
|
||||
}, header: {
|
||||
Text("Local connectivity")
|
||||
})
|
||||
}
|
||||
#if os(iOS)
|
||||
.toolbar {
|
||||
// EditButton()
|
||||
}
|
||||
#endif
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle("Peers")
|
||||
#if os(iOS)
|
||||
#if os(iOS)
|
||||
.toolbar {
|
||||
Button("Add", systemImage: "plus") {
|
||||
appDelegate.yggdrasilConfig.peers.append("")
|
||||
}
|
||||
EditButton()
|
||||
.onChange(of: editMode!.wrappedValue) { edit in
|
||||
if !edit.isEditing {
|
||||
try? appDelegate.yggdrasilConfig.save(to: &appDelegate.vpnManager)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ struct SettingsView: View {
|
|||
var body: some View {
|
||||
Form {
|
||||
Section(content: {
|
||||
TextField("Device Name", text: $deviceName)
|
||||
TextField("Device Name", text: $appDelegate.yggdrasilConfig.deviceName)
|
||||
}, header: {
|
||||
Text("Public Identity")
|
||||
})
|
||||
|
|
|
@ -93,6 +93,8 @@ struct StatusView: View {
|
|||
Text(appDelegate.yggdrasilVersion())
|
||||
.foregroundColor(Color.gray)
|
||||
}
|
||||
}, header: {
|
||||
Text("Status")
|
||||
})
|
||||
|
||||
Section(content: {
|
||||
|
@ -114,7 +116,7 @@ struct StatusView: View {
|
|||
.lineLimit(1)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
HStack {
|
||||
/*HStack {
|
||||
Text("Coordinates")
|
||||
Spacer()
|
||||
Text(appDelegate.yggdrasilCoords)
|
||||
|
@ -122,7 +124,7 @@ struct StatusView: View {
|
|||
.truncationMode(.tail)
|
||||
.lineLimit(1)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}*/
|
||||
HStack {
|
||||
Text("Public Key")
|
||||
Spacer()
|
||||
|
@ -133,7 +135,35 @@ struct StatusView: View {
|
|||
.lineLimit(1)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}, header: {
|
||||
Text("Details")
|
||||
})
|
||||
|
||||
if self.appDelegate.yggdrasilEnabled {
|
||||
Section(content: {
|
||||
List(self.appDelegate.yggdrasilPeers.sorted(by: { a, b in
|
||||
a.key < a.key
|
||||
}), id: \.remote) { peer in
|
||||
VStack {
|
||||
Text(peer.remote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.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(.all, 2)
|
||||
}
|
||||
}, header: {
|
||||
Text("Peers")
|
||||
})
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle("Yggdrasil")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue