diff options
author | 2019-03-17 20:10:26 +0530 | |
---|---|---|
committer | 2019-03-18 06:46:56 +0100 | |
commit | 0440c4a33a5a2520790c0e8e77ffb4d2ec444118 (patch) | |
tree | 784302316962ef461292309e18064a5db2e72028 /WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift | |
parent | on-demand: View model should account for isActivateOnDemandEnabled (diff) | |
download | wireguard-apple-0440c4a33a5a2520790c0e8e77ffb4d2ec444118.tar.xz wireguard-apple-0440c4a33a5a2520790c0e8e77ffb4d2ec444118.zip |
on-demand: macOS: Integrate Ethernet and Wi-Fi controls in one row
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r-- | WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift index 51420c4..3d959cf 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelEditViewController.swift @@ -42,15 +42,7 @@ class TunnelEditViewController: NSViewController { return textView }() - let onDemandEthernetCheckbox: NSButton = { - let checkbox = NSButton() - checkbox.title = tr("tunnelOnDemandEthernet") - checkbox.setButtonType(.switch) - checkbox.state = .off - return checkbox - }() - - let onDemandWiFiControls = OnDemandWiFiControls() + let onDemandControlsRow = OnDemandControlsRow() let scrollView: NSScrollView = { let scrollView = NSScrollView() @@ -147,20 +139,6 @@ class TunnelEditViewController: NSViewController { override func loadView() { populateFields() - let onDemandEthernetRow = ControlRow(controlView: onDemandEthernetCheckbox) - onDemandEthernetRow.key = tr("macFieldOnDemand") - onDemandEthernetCheckbox.state = onDemandViewModel.isNonWiFiInterfaceEnabled ? .on : .off - - let onDemandWiFiRow = ControlRow(controlView: onDemandWiFiControls) - onDemandWiFiRow.key = "" - onDemandWiFiControls.onDemandViewModel = onDemandViewModel - - NSLayoutConstraint.activate([ - onDemandEthernetRow.keyLabel.firstBaselineAnchor.constraint(equalTo: onDemandEthernetRow.controlView.firstBaselineAnchor), - onDemandWiFiRow.controlView.centerYAnchor.constraint(equalTo: onDemandWiFiRow.centerYAnchor), - onDemandWiFiRow.trailingAnchor.constraint(equalTo: onDemandWiFiControls.trailingAnchor) - ]) - scrollView.documentView = textView saveButton.target = self @@ -172,10 +150,12 @@ class TunnelEditViewController: NSViewController { excludePrivateIPsCheckbox.target = self excludePrivateIPsCheckbox.action = #selector(excludePrivateIPsCheckboxToggled(sender:)) + onDemandControlsRow.onDemandViewModel = onDemandViewModel + let margin: CGFloat = 20 let internalSpacing: CGFloat = 10 - let editorStackView = NSStackView(views: [nameRow, publicKeyRow, onDemandEthernetRow, onDemandWiFiRow, scrollView]) + let editorStackView = NSStackView(views: [nameRow, publicKeyRow, onDemandControlsRow, scrollView]) editorStackView.orientation = .vertical editorStackView.setHuggingPriority(.defaultHigh, for: .horizontal) editorStackView.spacing = internalSpacing @@ -205,7 +185,7 @@ class TunnelEditViewController: NSViewController { view.window?.ignoresMouseEvents = !enabled nameRow.valueLabel.isEditable = enabled textView.isEditable = enabled - onDemandWiFiControls.onDemandSSIDsField.isEnabled = enabled + onDemandControlsRow.onDemandSSIDsField.isEnabled = enabled } @objc func handleSaveAction() { @@ -215,8 +195,7 @@ class TunnelEditViewController: NSViewController { return } - onDemandViewModel.isNonWiFiInterfaceEnabled = onDemandEthernetCheckbox.state == .on - onDemandWiFiControls.saveToViewModel() + onDemandControlsRow.saveToViewModel() let onDemandOption = onDemandViewModel.toOnDemandOption() let isTunnelModifiedWithoutChangingName = (tunnel != nil && tunnel!.name == name) |