From ce73d07d5105e02bc5ce4c0063370238a20e8f25 Mon Sep 17 00:00:00 2001 From: oguzman Date: Tue, 15 Mar 2016 22:43:03 -0600 Subject: [PATCH 1/2] Adding swipe gestures to navigate thru Onboard; also fixed some issues with Float and CGFLoat (now used in swift 2) --- Gulps/AppDelegate.swift | 1 + Gulps/Base.lproj/Main.storyboard | 157 +++++------------- Gulps/Base.lproj/Onboarding.storyboard | 19 +-- .../CalendarViewController.swift | 4 +- .../ViewControllers/DrinkViewController.swift | 2 +- .../Onboarding/GoalViewController.swift | 8 + .../Onboarding/GulpsViewController.swift | 8 + .../Onboarding/MeasureViewController.swift | 8 + .../NotificationViewController.swift | 8 + .../Onboarding/OnboardingViewController.swift | 23 ++- 10 files changed, 104 insertions(+), 134 deletions(-) diff --git a/Gulps/AppDelegate.swift b/Gulps/AppDelegate.swift index 0aef76c..26e5030 100644 --- a/Gulps/AppDelegate.swift +++ b/Gulps/AppDelegate.swift @@ -16,6 +16,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WCSessionDelegate { watchConnectivityHelper.setupWatchConnectivity(delegate: self) let userDefaults = NSUserDefaults.groupUserDefaults() + userDefaults.setBool(false, forKey: Constants.General.OnboardingShown.key()) if (!userDefaults.boolForKey(Constants.General.OnboardingShown.key())) { loadOnboardingInterface() } else { diff --git a/Gulps/Base.lproj/Main.storyboard b/Gulps/Base.lproj/Main.storyboard index a9ac1b9..5c35c38 100644 --- a/Gulps/Base.lproj/Main.storyboard +++ b/Gulps/Base.lproj/Main.storyboard @@ -1,7 +1,7 @@ - + - + @@ -36,10 +36,8 @@ - - @@ -51,7 +49,6 @@ - @@ -208,14 +199,12 @@ - @@ -278,21 +264,18 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -375,7 +356,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -461,7 +438,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -485,7 +461,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -511,7 +486,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -519,7 +493,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -527,42 +500,36 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -642,7 +608,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -661,60 +626,53 @@ By the way, we’d love some feedback! How do you feel about Gulps? - - + - + - - - + - + - - @@ -744,18 +700,16 @@ By the way, we’d love some feedback! How do you feel about Gulps? - - + - + - @@ -766,22 +720,19 @@ By the way, we’d love some feedback! How do you feel about Gulps? - - @@ -792,18 +743,16 @@ By the way, we’d love some feedback! How do you feel about Gulps? - - + - + - @@ -814,22 +763,19 @@ By the way, we’d love some feedback! How do you feel about Gulps? - - @@ -840,35 +786,31 @@ By the way, we’d love some feedback! How do you feel about Gulps? - - + - + - - @@ -878,119 +820,103 @@ By the way, we’d love some feedback! How do you feel about Gulps? - - + - + - - - + - + - - - + - + - - - + - + - - @@ -1000,7 +926,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -1039,7 +964,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - @@ -1058,7 +982,6 @@ By the way, we’d love some feedback! How do you feel about Gulps? - diff --git a/Gulps/Base.lproj/Onboarding.storyboard b/Gulps/Base.lproj/Onboarding.storyboard index 8036731..7ce14c4 100644 --- a/Gulps/Base.lproj/Onboarding.storyboard +++ b/Gulps/Base.lproj/Onboarding.storyboard @@ -1,7 +1,7 @@ - + - + @@ -13,7 +13,7 @@ - + @@ -94,7 +94,7 @@ - + @@ -275,7 +275,7 @@ what measurement system do you prefer? - + @@ -480,7 +480,7 @@ what measurement system do you prefer? - + @@ -620,7 +620,7 @@ what measurement system do you prefer? - + @@ -894,10 +894,5 @@ what measurement system do you prefer? - - - - - diff --git a/Gulps/ViewControllers/CalendarViewController.swift b/Gulps/ViewControllers/CalendarViewController.swift index 350d850..c288c41 100644 --- a/Gulps/ViewControllers/CalendarViewController.swift +++ b/Gulps/ViewControllers/CalendarViewController.swift @@ -113,8 +113,8 @@ private extension CalendarViewController { } func updateStats() { - daysCountLabel.countFromZeroTo(Float(EntryHandler.sharedHandler.daysTracked())) - quantityLabel.countFromZeroTo(Float(EntryHandler.sharedHandler.overallQuantity())) + daysCountLabel.countFromZeroTo(CGFloat(EntryHandler.sharedHandler.daysTracked())) + quantityLabel.countFromZeroTo(CGFloat(EntryHandler.sharedHandler.overallQuantity())) measureLabel.text = String(format: NSLocalizedString("unit format", comment: ""), unitName()) } diff --git a/Gulps/ViewControllers/DrinkViewController.swift b/Gulps/ViewControllers/DrinkViewController.swift index 33cc558..aa72c5a 100644 --- a/Gulps/ViewControllers/DrinkViewController.swift +++ b/Gulps/ViewControllers/DrinkViewController.swift @@ -103,7 +103,7 @@ public class DrinkViewController: UIViewController, UIAlertViewDelegate, UIViewC func updateUI() { let percentage = EntryHandler.sharedHandler.currentPercentage() - percentageLabel.countFromCurrentValueTo(Float(round(percentage))) + percentageLabel.countFromCurrentValueTo(CGFloat(round(percentage))) let fillTo = CGFloat(percentage / 100.0) progressMeter?.fillTo(fillTo > 1 ? 1 : fillTo) } diff --git a/Gulps/ViewControllers/Onboarding/GoalViewController.swift b/Gulps/ViewControllers/Onboarding/GoalViewController.swift index 0f91ab9..f5cef8d 100644 --- a/Gulps/ViewControllers/Onboarding/GoalViewController.swift +++ b/Gulps/ViewControllers/Onboarding/GoalViewController.swift @@ -52,4 +52,12 @@ class GoalViewController: OnboardingViewController, UITextFieldDelegate { self.goalSuffixLabel.text = unit.suffixForUnitOfMeasure() } } + + override func goNextScreen(gesture: UIGestureRecognizer) { + self.navigationController?.pushViewController((self.storyboard?.instantiateViewControllerWithIdentifier("NotificationViewController"))!, animated: true) + } + + override func goPrevScreen(gesture: UIGestureRecognizer) { + self.navigationController?.popViewControllerAnimated(true) + } } diff --git a/Gulps/ViewControllers/Onboarding/GulpsViewController.swift b/Gulps/ViewControllers/Onboarding/GulpsViewController.swift index fe627aa..3431b1e 100644 --- a/Gulps/ViewControllers/Onboarding/GulpsViewController.swift +++ b/Gulps/ViewControllers/Onboarding/GulpsViewController.swift @@ -25,6 +25,14 @@ class GulpsViewController: OnboardingViewController, UITextFieldDelegate { NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil) } + + override func goNextScreen(gesture: UIGestureRecognizer) { + self.navigationController?.pushViewController((self.storyboard?.instantiateViewControllerWithIdentifier("GoalViewController"))!, animated: true) + } + + override func goPrevScreen(gesture: UIGestureRecognizer) { + self.navigationController?.popViewControllerAnimated(true) + } func dismissAndSave() { let numberFormatter = NSNumberFormatter() diff --git a/Gulps/ViewControllers/Onboarding/MeasureViewController.swift b/Gulps/ViewControllers/Onboarding/MeasureViewController.swift index b54e548..e46cd4a 100644 --- a/Gulps/ViewControllers/Onboarding/MeasureViewController.swift +++ b/Gulps/ViewControllers/Onboarding/MeasureViewController.swift @@ -12,6 +12,14 @@ class MeasureViewController: OnboardingViewController { _ = [litersCheck, ouncesCheck].map({$0.transform = CGAffineTransformMakeScale(0.001, 0.001)}) } + override func goNextScreen(gesture: UIGestureRecognizer) { + self.navigationController?.pushViewController((self.storyboard?.instantiateViewControllerWithIdentifier("GulpsViewController"))!, animated: true) + } + + override func goPrevScreen(gesture: UIGestureRecognizer) { + self.navigationController?.popViewControllerAnimated(true) + } + override func updateUI() { let unit = Constants.UnitsOfMeasure(rawValue: self.userDefaults.integerForKey(Constants.General.UnitOfMeasure.key())) diff --git a/Gulps/ViewControllers/Onboarding/NotificationViewController.swift b/Gulps/ViewControllers/Onboarding/NotificationViewController.swift index 1c128f9..82eb386 100644 --- a/Gulps/ViewControllers/Onboarding/NotificationViewController.swift +++ b/Gulps/ViewControllers/Onboarding/NotificationViewController.swift @@ -46,6 +46,14 @@ class NotificationViewController: OnboardingViewController, UIActionSheetDelegat self.intervalLabel.text = "\(interval) \(hour)" self.notificationSwitch.on = self.userDefaults.boolForKey(Constants.Notification.On.key()) } + + override func goPrevScreen(gesture: UIGestureRecognizer) { + self.navigationController?.popViewControllerAnimated(true) + } + + override func goNextScreen(gesture: UIGestureRecognizer) { + + } @IBAction func openFromSelection(sender: UIButton) { self.fromActionSheet.show() diff --git a/Gulps/ViewControllers/Onboarding/OnboardingViewController.swift b/Gulps/ViewControllers/Onboarding/OnboardingViewController.swift index bc89174..02bcc7c 100644 --- a/Gulps/ViewControllers/Onboarding/OnboardingViewController.swift +++ b/Gulps/ViewControllers/Onboarding/OnboardingViewController.swift @@ -1,18 +1,37 @@ import UIKit import AMWaveTransition -class OnboardingViewController: AMWaveViewController { +class OnboardingViewController: AMWaveViewController, UIGestureRecognizerDelegate { @IBOutlet var viewArray: [UIView]! + + //var arrVC = ["OnboardingViewController", "MeasureViewController", "GulpsViewController", "GoalViewController", "NotificationViewController"] // this is the stack of viewControllers used on Onboarding.storyboard override func viewDidLoad() { super.viewDidLoad() self.navigationController?.view.backgroundColor = UIColor.mainColor() self.view.backgroundColor = UIColor.clearColor() - + let lsg = UISwipeGestureRecognizer(target: self, action:"goNextScreen:") + lsg.direction = .Left + lsg.delegate = self + self.view.addGestureRecognizer(lsg) + let rsg = UISwipeGestureRecognizer(target: self, action:"goPrevScreen:") + rsg.direction = .Right + rsg.delegate = self + self.view.addGestureRecognizer(rsg) updateUI() } + + func goNextScreen(gesture:UIGestureRecognizer) + { + self.navigationController?.pushViewController((self.storyboard?.instantiateViewControllerWithIdentifier("MeasureViewController"))!, animated: true) + } + + func goPrevScreen(gesture:UIGestureRecognizer) + { + + } override func prefersStatusBarHidden() -> Bool { return true From 9cf501a06fdbc475ab8030a5ab746137701dfaa5 Mon Sep 17 00:00:00 2001 From: oguzman Date: Tue, 15 Mar 2016 22:44:33 -0600 Subject: [PATCH 2/2] removed hardcoded value to see onboarding scene --- Gulps/AppDelegate.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Gulps/AppDelegate.swift b/Gulps/AppDelegate.swift index 26e5030..0aef76c 100644 --- a/Gulps/AppDelegate.swift +++ b/Gulps/AppDelegate.swift @@ -16,7 +16,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WCSessionDelegate { watchConnectivityHelper.setupWatchConnectivity(delegate: self) let userDefaults = NSUserDefaults.groupUserDefaults() - userDefaults.setBool(false, forKey: Constants.General.OnboardingShown.key()) if (!userDefaults.boolForKey(Constants.General.OnboardingShown.key())) { loadOnboardingInterface() } else {