diff --git a/BeeSwift/GoalViewController.swift b/BeeSwift/GoalViewController.swift index 8dca8f87..f3442625 100644 --- a/BeeSwift/GoalViewController.swift +++ b/BeeSwift/GoalViewController.swift @@ -15,7 +15,7 @@ import Intents import BeeKit import OSLog -class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTableViewControllerDelegate, UITextFieldDelegate, SFSafariViewControllerDelegate { +class GoalViewController: UIViewController, DatapointTableViewControllerDelegate, UITextFieldDelegate { let elementSpacing = 10 let sideMargin = 10 let buttonHeight = 42 @@ -110,7 +110,7 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl self.goalImageScrollView.showsHorizontalScrollIndicator = false self.goalImageScrollView.showsVerticalScrollIndicator = false self.goalImageScrollView.minimumZoomScale = 1.0 - self.goalImageScrollView.maximumZoomScale = 3.0 + self.goalImageScrollView.maximumZoomScale = 7.0 self.goalImageScrollView.delegate = self self.goalImageScrollView.snp.makeConstraints { (make) -> Void in make.centerX.equalTo(self.view) @@ -362,7 +362,10 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl } @objc func goalImageTapped() { - self.goalImageScrollView.setZoomScale(self.goalImageScrollView.zoomScale == 1.0 ? 2.0 : 1.0, animated: true) + let possibleNextStepUp = self.goalImageScrollView.zoomScale + 2.0 + let nextZoomLevel = possibleNextStepUp <= self.goalImageScrollView.maximumZoomScale ? possibleNextStepUp : self.goalImageScrollView.minimumZoomScale + + self.goalImageScrollView.setZoomScale(nextZoomLevel, animated: true) } func datapointTableViewController(_ datapointTableViewController: DatapointTableViewController, didSelectDatapoint datapoint: BeeDataPoint) { @@ -501,10 +504,6 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl self.refreshCountdown() self.updateLastUpdatedLabel() } - - func viewForZooming(in scrollView: UIScrollView) -> UIView? { - return self.goalImageView - } private static func makeInitialDateStepperValue(date: Date = Date(), for goal: Goal) -> Double { let daystampAccountingForTheGoalsDeadline = Daystamp(fromDate: date, @@ -523,6 +522,15 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl // MARK: - SFSafariViewControllerDelegate +} + +extension GoalViewController: UIScrollViewDelegate { + func viewForZooming(in scrollView: UIScrollView) -> UIView? { + return self.goalImageView + } +} + +extension GoalViewController: SFSafariViewControllerDelegate { func safariViewControllerDidFinish(_ controller: SFSafariViewController) { controller.dismiss(animated: true, completion: nil) }