diff --git a/Gulps/Base.lproj/Main.storyboard b/Gulps/Base.lproj/Main.storyboard
index 256a507..62e1f39 100644
--- a/Gulps/Base.lproj/Main.storyboard
+++ b/Gulps/Base.lproj/Main.storyboard
@@ -118,9 +118,23 @@
+
+
@@ -138,6 +152,7 @@
+
@@ -151,6 +166,7 @@
+
@@ -158,6 +174,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -652,6 +686,7 @@
+
diff --git a/Gulps/Images.xcassets/star.imageset/Contents.json b/Gulps/Images.xcassets/star.imageset/Contents.json
new file mode 100644
index 0000000..630617b
--- /dev/null
+++ b/Gulps/Images.xcassets/star.imageset/Contents.json
@@ -0,0 +1,12 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "star.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/Gulps/Images.xcassets/star.imageset/star.pdf b/Gulps/Images.xcassets/star.imageset/star.pdf
new file mode 100644
index 0000000..da1b925
Binary files /dev/null and b/Gulps/Images.xcassets/star.imageset/star.pdf differ
diff --git a/Gulps/ViewControllers/DrinkViewController.swift b/Gulps/ViewControllers/DrinkViewController.swift
index ddbb8e8..a335222 100644
--- a/Gulps/ViewControllers/DrinkViewController.swift
+++ b/Gulps/ViewControllers/DrinkViewController.swift
@@ -2,8 +2,9 @@ import UIKit
import DPMeterView
import UICountingLabel
import Realm
+import BubbleTransition
-public class DrinkViewController: UIViewController, UIAlertViewDelegate {
+public class DrinkViewController: UIViewController, UIAlertViewDelegate, UIViewControllerTransitioningDelegate {
@IBOutlet public weak var progressMeter: DPMeterView!
@IBOutlet public weak var percentageLabel: UICountingLabel!
@@ -12,9 +13,11 @@ public class DrinkViewController: UIViewController, UIAlertViewDelegate {
@IBOutlet public weak var largeButton: UIButton!
@IBOutlet public weak var minusButton: UIButton!
@IBOutlet public var entryHandler: EntryHandler!
+ @IBOutlet weak var starButton: UIButton!
public var userDefaults = NSUserDefaults.groupUserDefaults()
var expanded = false
var realmToken: RLMNotificationToken?
+ let transition = BubbleTransition()
public override func viewDidLoad() {
super.viewDidLoad()
@@ -42,6 +45,8 @@ public class DrinkViewController: UIViewController, UIAlertViewDelegate {
public override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
updateUI()
+
+// animateStarButton()
}
public override func viewDidAppear(animated: Bool) {
@@ -60,6 +65,13 @@ public class DrinkViewController: UIViewController, UIAlertViewDelegate {
}
}
+ override public func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+ if let controller = segue.destinationViewController as? UIViewController {
+ controller.transitioningDelegate = self
+ controller.modalPresentationStyle = .Custom
+ }
+ }
+
@IBAction func addButtonAction(sender: UIButton) {
if (expanded) {
contractAddButton()
@@ -88,4 +100,21 @@ public class DrinkViewController: UIViewController, UIAlertViewDelegate {
entryHandler.removeLastGulp()
}
}
+
+ // MARK: UIViewControllerTransitioningDelegate
+
+ public func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
+ transition.transitionMode = .Present
+ let center = CGPoint(x: starButton.center.x, y: starButton.center.y + 64)
+ transition.startingPoint = center
+ transition.bubbleColor = UIColor(red: 245.0/255.0, green: 192.0/255.0, blue: 24.0/255.0, alpha: 1)
+ return transition
+ }
+
+ public func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
+ transition.transitionMode = .Dismiss
+ transition.startingPoint = starButton.center
+ transition.bubbleColor = UIColor(red: 245.0/255.0, green: 192.0/255.0, blue: 24.0/255.0, alpha: 1)
+ return transition
+ }
}
diff --git a/Gulps/ViewControllers/Support/DrinkViewController+Animations.swift b/Gulps/ViewControllers/Support/DrinkViewController+Animations.swift
index a4b5834..25f5b5c 100644
--- a/Gulps/ViewControllers/Support/DrinkViewController+Animations.swift
+++ b/Gulps/ViewControllers/Support/DrinkViewController+Animations.swift
@@ -5,6 +5,30 @@ extension DrinkViewController {
func initAnimation() {
smallButton.alpha = 0
largeButton.alpha = 0
+ starButton.transform = CGAffineTransformMakeScale(0.0001, 0.0001)
+ }
+
+ func animateStarButton() {
+ let rotate = POPSpringAnimation(propertyNamed: kPOPLayerRotation)
+ rotate.toValue = 2 * M_PI - M_PI_4 / 2
+ rotate.springBounciness = 5
+ rotate.removedOnCompletion = true
+
+ let scale = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)
+ scale.toValue = NSValue(CGPoint: CGPointMake(0.8, 0.8))
+ scale.removedOnCompletion = true
+ scale.completionBlock = {(_,_) in
+ let sway = POPBasicAnimation(propertyNamed: kPOPLayerRotation)
+ sway.fromValue = -M_PI_4 / 2
+ sway.toValue = M_PI_4 / 2
+ sway.duration = 0.75
+ sway.repeatForever = true
+ sway.autoreverses = true
+ self.starButton.layer.pop_addAnimation(sway, forKey: "sway")
+ }
+
+ starButton.pop_addAnimation(scale, forKey: "scale")
+ starButton.layer.pop_addAnimation(rotate, forKey: "rotate")
}
func expandAddButton() {
@@ -94,7 +118,7 @@ extension DrinkViewController {
scaleMinus.fromValue = NSValue(CGPoint: CGPointMake(0, 0))
scaleMinus.toValue = NSValue(CGPoint: CGPointMake(1, 1))
scaleMinus.removedOnCompletion = true
-
+
addButton.layer.pop_addAnimation(rotate, forKey: "rotate")
addButton.pop_addAnimation(scale, forKey: "scale")
addButton.pop_addAnimation(color, forKey: "color")
diff --git a/Podfile b/Podfile
index 7ff18dd..be405e9 100644
--- a/Podfile
+++ b/Podfile
@@ -10,6 +10,7 @@ def common_pods
pod 'UICountingLabel', '~> 1.2'
pod 'JTCalendar', git: 'https://github.com/andreamazz/JTCalendar', branch: 'develop'
pod 'DPMeterView', git: 'https://github.com/andreamazz/DPMeterView'
+ pod 'BubbleTransition'
# pod 'BEMSimpleLineGraph'
end
diff --git a/assets/gulps.sketch b/assets/gulps.sketch
index ad83013..6a2df28 100644
Binary files a/assets/gulps.sketch and b/assets/gulps.sketch differ