diff options
author | Roopesh Chander <roop@roopc.net> | 2018-10-23 17:48:07 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-10-27 15:13:01 +0530 |
commit | 6243717a37c7f84baca700dbd9898707192ae678 (patch) | |
tree | 2367ac7c8e1b7e7df0d66df3dc1fcedfe4463a65 | |
parent | Tunnels list: Update when a tunnel is added (diff) | |
download | wireguard-apple-6243717a37c7f84baca700dbd9898707192ae678.tar.xz wireguard-apple-6243717a37c7f84baca700dbd9898707192ae678.zip |
Tunnel view model: The view model applies for both editing and viewing
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r-- | WireGuard/WireGuard/UI/TunnelViewModel.swift | 16 | ||||
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift index d6f7126..709464c 100644 --- a/WireGuard/WireGuard/UI/TunnelViewModel.swift +++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift @@ -10,7 +10,7 @@ import UIKit class TunnelViewModel { - enum InterfaceEditField: String { + enum InterfaceField: String { case name = "Name" case privateKey = "Private key" case publicKey = "Public key" @@ -21,7 +21,7 @@ class TunnelViewModel { case dns = "DNS servers" } - enum PeerEditField: String { + enum PeerField: String { case publicKey = "Public key" case preSharedKey = "Pre-shared key" case endpoint = "Endpoint" @@ -32,11 +32,11 @@ class TunnelViewModel { } class InterfaceData { - var scratchpad: [InterfaceEditField: String] = [:] - var fieldsWithError: Set<InterfaceEditField> = [] + var scratchpad: [InterfaceField: String] = [:] + var fieldsWithError: Set<InterfaceField> = [] var validatedConfiguration: InterfaceConfiguration? = nil - subscript(field: InterfaceEditField) -> String { + subscript(field: InterfaceField) -> String { get { if (scratchpad.isEmpty) { // When starting to read a config, setup the scratchpad. @@ -148,15 +148,15 @@ class TunnelViewModel { class PeerData { var index: Int - var scratchpad: [PeerEditField: String] = [:] - var fieldsWithError: Set<PeerEditField> = [] + var scratchpad: [PeerField: String] = [:] + var fieldsWithError: Set<PeerField> = [] var validatedConfiguration: PeerConfiguration? = nil init(index: Int) { self.index = index } - subscript(field: PeerEditField) -> String { + subscript(field: PeerField) -> String { get { if (scratchpad.isEmpty) { // When starting to read a config, setup the scratchpad. diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift index a98ae81..bdea868 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift @@ -12,13 +12,13 @@ import UIKit class TunnelEditTableViewController: UITableViewController { - let interfaceEditFieldsBySection: [[TunnelViewModel.InterfaceEditField]] = [ + let interfaceEditFieldsBySection: [[TunnelViewModel.InterfaceField]] = [ [.name], [.privateKey, .publicKey, .generateKeyPair], [.addresses, .listenPort, .mtu, .dns] ] - let peerEditFieldsBySection: [[TunnelViewModel.PeerEditField]] = [ + let peerEditFieldsBySection: [[TunnelViewModel.PeerField]] = [ [.publicKey, .preSharedKey, .endpoint, .allowedIPs, .excludePrivateIPs, .persistentKeepAlive, |