diff --git a/Cartfile b/Cartfile index 5abe0d1..05195c5 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "LoopKit/LoopKit" ~> 2.0 +github "LoopKit/LoopKit" "dev" diff --git a/Cartfile.resolved b/Cartfile.resolved index ea5e0dd..d43c89f 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "LoopKit/LoopKit" "v2.2.1" +github "LoopKit/LoopKit" "bf4166bc77f89e22971f2030ad006967881ff082" diff --git a/ShareClientUI/ShareClientManager+UI.swift b/ShareClientUI/ShareClientManager+UI.swift index e16b503..dcac4a0 100644 --- a/ShareClientUI/ShareClientManager+UI.swift +++ b/ShareClientUI/ShareClientManager+UI.swift @@ -11,12 +11,14 @@ import ShareClient extension ShareClientManager: CGMManagerUI { - public static func setupViewController() -> (UIViewController & CGMManagerSetupViewController)? { + public static func setupViewController() -> (UIViewController & CGMManagerSetupViewController & CompletionNotifying)? { return ShareClientSetupViewController() } - public func settingsViewController(for glucoseUnit: HKUnit) -> UIViewController { - return ShareClientSettingsViewController(cgmManager: self, glucoseUnit: glucoseUnit, allowsDeletion: true) + public func settingsViewController(for glucoseUnit: HKUnit) -> (UIViewController & CompletionNotifying) { + let settings = ShareClientSettingsViewController(cgmManager: self, glucoseUnit: glucoseUnit, allowsDeletion: true) + let nav = SettingsNavigationViewController(rootViewController: settings) + return nav } public var smallImage: UIImage? { diff --git a/ShareClientUI/ShareClientSettingsViewController.swift b/ShareClientUI/ShareClientSettingsViewController.swift index 9181c0b..b137785 100644 --- a/ShareClientUI/ShareClientSettingsViewController.swift +++ b/ShareClientUI/ShareClientSettingsViewController.swift @@ -45,6 +45,19 @@ public class ShareClientSettingsViewController: UITableViewController { tableView.register(SettingsTableViewCell.self, forCellReuseIdentifier: SettingsTableViewCell.className) tableView.register(TextButtonTableViewCell.self, forCellReuseIdentifier: TextButtonTableViewCell.className) + + let button = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(doneTapped(_:))) + self.navigationItem.setRightBarButton(button, animated: false) + } + + @objc func doneTapped(_ sender: Any) { + complete() + } + + private func complete() { + if let nav = navigationController as? SettingsNavigationViewController { + nav.notifyComplete() + } } // MARK: - UITableViewDataSource @@ -168,7 +181,7 @@ public class ShareClientSettingsViewController: UITableViewController { case .delete: let confirmVC = UIAlertController(cgmDeletionHandler: { self.cgmManager.cgmManagerDelegate?.cgmManagerWantsDeletion(self.cgmManager) - self.navigationController?.popViewController(animated: true) + self.complete() }) present(confirmVC, animated: true) { diff --git a/ShareClientUI/ShareClientSetupViewController.swift b/ShareClientUI/ShareClientSetupViewController.swift index 79ee2fa..b396cbe 100644 --- a/ShareClientUI/ShareClientSetupViewController.swift +++ b/ShareClientUI/ShareClientSetupViewController.swift @@ -11,9 +11,11 @@ import LoopKitUI import ShareClient -class ShareClientSetupViewController: UINavigationController, CGMManagerSetupViewController { +class ShareClientSetupViewController: UINavigationController, CGMManagerSetupViewController, CompletionNotifying { var setupDelegate: CGMManagerSetupViewControllerDelegate? + weak var completionDelegate: CompletionDelegate? + let cgmManager = ShareClientManager() init() { @@ -37,11 +39,11 @@ class ShareClientSetupViewController: UINavigationController, CGMManagerSetupVie } @objc private func cancel() { - setupDelegate?.cgmManagerSetupViewControllerDidCancel(self) + completionDelegate?.completionNotifyingDidComplete(self) } @objc private func save() { setupDelegate?.cgmManagerSetupViewController(self, didSetUpCGMManager: cgmManager) + completionDelegate?.completionNotifyingDidComplete(self) } - }