mirror of
https://github.com/yggdrasil-network/yggdrasil-ios.git
synced 2025-04-28 14:15:09 +03:00
Some SwiftUI
This commit is contained in:
parent
b58f8e3852
commit
291b12b785
24 changed files with 901 additions and 89 deletions
77
YggdrasilSwiftUI/PeersView.swift
Normal file
77
YggdrasilSwiftUI/PeersView.swift
Normal file
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
// StatisticsView.swift
|
||||
// YggdrasilSwiftUI
|
||||
//
|
||||
// Created by Neil on 10/02/2023.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PeersView: View {
|
||||
@State private var peers = ["Paul", "Taylor", "Adele"]
|
||||
|
||||
@State private var multicastAdvertise = false
|
||||
@State private var multicastListen = false
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section(content: {
|
||||
ForEach(peers, id: \.self) { peer in
|
||||
Text(peer)
|
||||
}
|
||||
.onDelete(perform: delete)
|
||||
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))
|
||||
.foregroundColor(.gray)
|
||||
}, header: {
|
||||
Text("Configured peers")
|
||||
})
|
||||
|
||||
Section(content: {
|
||||
Toggle(isOn: $multicastAdvertise) {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Discoverable over multicast")
|
||||
Text("Make your device discoverable to other Yggdrasil nodes on the same Wi-Fi network.")
|
||||
.font(.system(size: 11))
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
Toggle(isOn: $multicastListen) {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Search for multicast peers")
|
||||
Text("Automatically connect to discoverable Yggdrasil nodes on the same Wi-Fi network.")
|
||||
.font(.system(size: 11))
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
}, header: {
|
||||
Text("Local connectivity")
|
||||
})
|
||||
}
|
||||
#if os(iOS)
|
||||
.toolbar {
|
||||
Button(role: nil, action: {
|
||||
|
||||
}, label: {
|
||||
Image(systemName: "plus")
|
||||
})
|
||||
EditButton()
|
||||
}
|
||||
#endif
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle("Peers")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
#endif
|
||||
}
|
||||
|
||||
func delete(at offsets: IndexSet) {
|
||||
peers.remove(atOffsets: offsets)
|
||||
}
|
||||
}
|
||||
|
||||
struct PeersView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
PeersView()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue