diff options
author | Jeroen Leenarts <jeroen.leenarts@gmail.com> | 2018-05-24 22:07:04 +0200 |
---|---|---|
committer | Jeroen Leenarts <jeroen.leenarts@gmail.com> | 2018-05-24 22:07:04 +0200 |
commit | 972407344781dde2b2a2c0d1b3405a042eb73c33 (patch) | |
tree | 8bc49a2f3b93d35a73936540731ed831f5854c2e /Wireguard/Coordinators | |
parent | Basic setup of ConnectionsTableViewController. (diff) | |
download | wireguard-apple-972407344781dde2b2a2c0d1b3405a042eb73c33.tar.xz wireguard-apple-972407344781dde2b2a2c0d1b3405a042eb73c33.zip |
Add bare bones `ProfileConfigurationTableViewController`.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'Wireguard/Coordinators')
-rw-r--r-- | Wireguard/Coordinators/AppCoordinator.swift | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/Wireguard/Coordinators/AppCoordinator.swift b/Wireguard/Coordinators/AppCoordinator.swift index b03807f..477911d 100644 --- a/Wireguard/Coordinators/AppCoordinator.swift +++ b/Wireguard/Coordinators/AppCoordinator.swift @@ -85,8 +85,8 @@ class AppCoordinator: RootViewCoordinator { extension AppCoordinator: ConnectionsTableViewControllerDelegate { func addProvider(connectionsTableViewController: ConnectionsTableViewController) { - // TODO implement - print("Add provider") + let addContext = persistentContainer.newBackgroundContext() + showProfileConfigurationViewController(profile: nil, context: addContext) } func connect(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { @@ -97,6 +97,23 @@ extension AppCoordinator: ConnectionsTableViewControllerDelegate { func configure(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { // TODO implement print("configure profile \(profile)") + let editContext = persistentContainer.newBackgroundContext() + var backgroundProfile: Profile? + editContext.performAndWait { + + backgroundProfile = editContext.object(with: profile.objectID) as? Profile + } + + showProfileConfigurationViewController(profile: backgroundProfile, context: editContext) + } + + func showProfileConfigurationViewController(profile: Profile?, context: NSManagedObjectContext) { + let profileConfigurationViewController = storyboard.instantiateViewController(type: ProfileConfigurationTableViewController.self) + + profileConfigurationViewController.viewContext = context + profileConfigurationViewController.delegate = self + + self.navigationController.pushViewController(profileConfigurationViewController, animated: true) } func delete(profile: Profile, connectionsTableViewController: ConnectionsTableViewController) { @@ -104,3 +121,7 @@ extension AppCoordinator: ConnectionsTableViewControllerDelegate { print("delete profile \(profile)") } } + +extension AppCoordinator: ProfileConfigurationTableViewControllerDelegate { + +} |