aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-03 01:16:27 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-14 14:52:31 +0530
commitada7db3dca0a2756f5a24f0fcbdfcbfa8f092457 (patch)
tree0c135c02af0c08f698a87a7dbd55525f489971f0 /WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
parentmacOS: Manage tunnels: Add a filler button (diff)
downloadwireguard-apple-ada7db3dca0a2756f5a24f0fcbdfcbfa8f092457.tar.xz
wireguard-apple-ada7db3dca0a2756f5a24f0fcbdfcbfa8f092457.zip
macOS: Manage tunnels: Tunnel detail view
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift44
1 files changed, 37 insertions, 7 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
index e63235a..3f16673 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
@@ -6,6 +6,8 @@ import Cocoa
class ManageTunnelsRootViewController: NSViewController {
let tunnelsManager: TunnelsManager
+ let tunnelDetailContainerView = NSView()
+ var tunnelDetailContentVC: NSViewController?
init(tunnelsManager: TunnelsManager) {
self.tunnelsManager = tunnelsManager
@@ -32,25 +34,53 @@ class ManageTunnelsRootViewController: NSViewController {
])
let tunnelsListVC = TunnelsListTableViewController(tunnelsManager: tunnelsManager)
+ tunnelsListVC.delegate = self
let tunnelsListView = tunnelsListVC.view
- let tunnelDetailView = NSView()
- tunnelDetailView.wantsLayer = true
- tunnelDetailView.layer?.backgroundColor = NSColor.gray.cgColor
addChild(tunnelsListVC)
view.addSubview(tunnelsListView)
- view.addSubview(tunnelDetailView)
+ view.addSubview(tunnelDetailContainerView)
tunnelsListView.translatesAutoresizingMaskIntoConstraints = false
- tunnelDetailView.translatesAutoresizingMaskIntoConstraints = false
+ tunnelDetailContainerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
tunnelsListView.topAnchor.constraint(equalTo: container.topAnchor),
tunnelsListView.bottomAnchor.constraint(equalTo: container.bottomAnchor),
tunnelsListView.leadingAnchor.constraint(equalTo: container.leadingAnchor),
- tunnelDetailView.leadingAnchor.constraint(equalTo: tunnelsListView.trailingAnchor, constant: horizontalSpacing),
- tunnelDetailView.trailingAnchor.constraint(equalTo: container.trailingAnchor),
+ tunnelDetailContainerView.topAnchor.constraint(equalTo: container.topAnchor),
+ tunnelDetailContainerView.bottomAnchor.constraint(equalTo: container.bottomAnchor),
+ tunnelDetailContainerView.leadingAnchor.constraint(equalTo: tunnelsListView.trailingAnchor, constant: horizontalSpacing),
+ tunnelDetailContainerView.trailingAnchor.constraint(equalTo: container.trailingAnchor),
tunnelsListView.widthAnchor.constraint(equalTo: container.widthAnchor, multiplier: 0.3)
])
}
+
+ private func setTunnelDetailContentVC(_ contentVC: NSViewController) {
+ if let currentContentVC = tunnelDetailContentVC {
+ currentContentVC.view.removeFromSuperview()
+ currentContentVC.removeFromParent()
+ }
+ addChild(contentVC)
+ tunnelDetailContainerView.addSubview(contentVC.view)
+ contentVC.view.translatesAutoresizingMaskIntoConstraints = false
+ NSLayoutConstraint.activate([
+ tunnelDetailContainerView.topAnchor.constraint(equalTo: contentVC.view.topAnchor),
+ tunnelDetailContainerView.bottomAnchor.constraint(equalTo: contentVC.view.bottomAnchor),
+ tunnelDetailContainerView.leadingAnchor.constraint(equalTo: contentVC.view.leadingAnchor),
+ tunnelDetailContainerView.trailingAnchor.constraint(equalTo: contentVC.view.trailingAnchor)
+ ])
+ tunnelDetailContentVC = contentVC
+ }
+}
+
+extension ManageTunnelsRootViewController: TunnelsListTableViewControllerDelegate {
+ func tunnelSelected(tunnel: TunnelContainer) {
+ let tunnelDetailVC = TunnelDetailTableViewController(tunnelsManager: tunnelsManager, tunnel: tunnel)
+ setTunnelDetailContentVC(tunnelDetailVC)
+ }
+
+ func tunnelListEmpty() {
+ // TODO
+ }
}