Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
Add rating controller transition
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamazz committed May 29, 2015
1 parent 532dd90 commit 9cd5feb
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 2 deletions.
35 changes: 35 additions & 0 deletions Gulps/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,23 @@
<action selector="removeGulpAction" destination="9pv-A4-QxB" eventType="touchUpInside" id="dHe-Ob-mdh"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xap-Vb-CbA">
<rect key="frame" x="10" y="10" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="7dc-b1-iEo"/>
<constraint firstAttribute="width" constant="50" id="lRF-8H-e5f"/>
</constraints>
<state key="normal" image="star">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<segue destination="cZe-iA-KWC" kind="modal" id="aQp-BJ-jkw"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="xap-Vb-CbA" firstAttribute="leading" secondItem="tsR-hK-woN" secondAttribute="leading" constant="10" id="0Kf-6v-f86"/>
<constraint firstItem="fW6-sm-t8g" firstAttribute="top" relation="greaterThanOrEqual" secondItem="mEa-Xq-QB6" secondAttribute="bottom" id="4AF-N9-UE2"/>
<constraint firstItem="mEa-Xq-QB6" firstAttribute="leading" secondItem="tsR-hK-woN" secondAttribute="leadingMargin" id="5Kw-Si-2x9"/>
<constraint firstItem="4ug-Mw-9AY" firstAttribute="top" secondItem="fW6-sm-t8g" secondAttribute="bottom" priority="999" constant="30" id="6mW-Ks-Okm"/>
Expand All @@ -138,6 +152,7 @@
<constraint firstAttribute="centerX" secondItem="fW6-sm-t8g" secondAttribute="centerX" id="eai-hx-KLM"/>
<constraint firstItem="mEa-Xq-QB6" firstAttribute="trailing" secondItem="tsR-hK-woN" secondAttribute="trailingMargin" id="j6h-Zi-1LS"/>
<constraint firstAttribute="centerX" secondItem="mEa-Xq-QB6" secondAttribute="centerX" id="oP9-VY-fG7"/>
<constraint firstItem="xap-Vb-CbA" firstAttribute="top" secondItem="Ia1-K6-d13" secondAttribute="bottom" constant="10" id="pAa-mt-Iaf"/>
<constraint firstItem="uvx-n6-xp2" firstAttribute="top" secondItem="Ia1-K6-d13" secondAttribute="bottom" constant="8" id="x61-hZ-WvW"/>
<constraint firstItem="fW6-sm-t8g" firstAttribute="centerY" secondItem="v5a-2l-qvB" secondAttribute="centerY" id="zwb-N5-8xQ"/>
</constraints>
Expand All @@ -151,13 +166,32 @@
<outlet property="percentageLabel" destination="mEa-Xq-QB6" id="VWN-Gf-0ip"/>
<outlet property="progressMeter" destination="mQX-uO-zkr" id="wZK-do-o20"/>
<outlet property="smallButton" destination="rSl-zs-C7Z" id="Eb6-qX-fT4"/>
<outlet property="starButton" destination="xap-Vb-CbA" id="RjA-tl-1Yo"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="W5J-7L-Pyd" sceneMemberID="firstResponder"/>
<customObject id="YJs-c5-Aop" customClass="EntryHandler" customModule="Gulps"/>
</objects>
<point key="canvasLocation" x="833" y="-656"/>
</scene>
<!--View Controller-->
<scene sceneID="SYy-UA-vxC">
<objects>
<viewController id="cZe-iA-KWC" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="02q-er-mJO"/>
<viewControllerLayoutGuide type="bottom" id="xIr-rX-acu"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Z7d-Wg-Hbc">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.96078431372549022" green="0.75294117647058822" blue="0.094117647058823528" alpha="1" colorSpace="calibratedRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="JK4-jm-Ngh" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1257" y="-656"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="yl2-sM-qoP">
<objects>
Expand Down Expand Up @@ -652,6 +686,7 @@
<image name="plus-icon" width="40" height="40"/>
<image name="settings-icon" width="30" height="30"/>
<image name="small-icon" width="40" height="40"/>
<image name="star" width="50" height="50"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
Expand Down
12 changes: 12 additions & 0 deletions Gulps/Images.xcassets/star.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "star.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Gulps/Images.xcassets/star.imageset/star.pdf
Binary file not shown.
31 changes: 30 additions & 1 deletion Gulps/ViewControllers/DrinkViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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()
Expand Down Expand Up @@ -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) {
Expand All @@ -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()
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file modified assets/gulps.sketch
Binary file not shown.

0 comments on commit 9cd5feb

Please sign in to comment.