From 5c574f5ea3c7ca549f57f1080deebd9001d86eca Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 3 Oct 2019 16:05:35 -0700 Subject: [PATCH] Starts syncing after dismissing Settings with gesture --- Delta/Base.lproj/Main.storyboard | 2 +- .../Game Selection/GamesViewController.swift | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Delta/Base.lproj/Main.storyboard b/Delta/Base.lproj/Main.storyboard index fe19716..9551acf 100644 --- a/Delta/Base.lproj/Main.storyboard +++ b/Delta/Base.lproj/Main.storyboard @@ -37,7 +37,7 @@ - + diff --git a/Delta/Game Selection/GamesViewController.swift b/Delta/Game Selection/GamesViewController.swift index 3878a70..f34cf28 100644 --- a/Delta/Game Selection/GamesViewController.swift +++ b/Delta/Game Selection/GamesViewController.swift @@ -141,12 +141,22 @@ extension GamesViewController // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - guard let identifier = segue.identifier, identifier == "embedPageViewController" else { return } + guard let identifier = segue.identifier else { return } - self.pageViewController = segue.destination as? UIPageViewController - self.pageViewController.dataSource = self - self.pageViewController.delegate = self - self.pageViewController.view.isHidden = true + switch identifier + { + case "embedPageViewController": + self.pageViewController = segue.destination as? UIPageViewController + self.pageViewController.dataSource = self + self.pageViewController.delegate = self + self.pageViewController.view.isHidden = true + + case "showSettings": + let destinationViewController = segue.destination + destinationViewController.presentationController?.delegate = self + + default: break + } } @IBAction private func unwindFromSettingsViewController(_ segue: UIStoryboardSegue) @@ -542,3 +552,11 @@ extension GamesViewController: NSFetchedResultsControllerDelegate self.updateSections(animated: true) } } + +extension GamesViewController: UIAdaptivePresentationControllerDelegate +{ + func presentationControllerWillDismiss(_ presentationController: UIPresentationController) + { + self.sync() + } +}