Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseidhof committed May 8, 2014
0 parents commit b7e33bb
Show file tree
Hide file tree
Showing 18 changed files with 903 additions and 0 deletions.
513 changes: 513 additions & 0 deletions InteractiveAnimations.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions InteractiveAnimations.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions InteractiveAnimations/DraggableView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Created by Florian on 21/04/14.
//
// To change the template use AppCode | Preferences | File Templates.
//


#import <Foundation/Foundation.h>


@class DraggableView;


@protocol DraggableViewDelegate

- (void)draggableView:(DraggableView *)view draggingEndedWithVelocity:(CGPoint)velocity;
- (void)draggableViewBeganDragging:(DraggableView *)view;

@end


@interface DraggableView : UIView

@property (nonatomic, weak) id <DraggableViewDelegate> delegate;

@end
42 changes: 42 additions & 0 deletions InteractiveAnimations/DraggableView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// Created by Florian on 21/04/14.
//
// To change the template use AppCode | Preferences | File Templates.
//


#import "DraggableView.h"

@implementation DraggableView

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}

- (void)setup
{
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)];
[self addGestureRecognizer:recognizer];
self.layer.cornerRadius = 6;
}

- (void)didPan:(UIPanGestureRecognizer *)recognizer
{
CGPoint point = [recognizer translationInView:self.superview];
self.center = CGPointMake(self.center.x, self.center.y + point.y);
[recognizer setTranslation:CGPointZero inView:self.superview];
if (recognizer.state == UIGestureRecognizerStateEnded) {
CGPoint velocity = [recognizer velocityInView:self.superview];
velocity.x = 0;
[self.delegate draggableView:self draggingEndedWithVelocity:velocity];
} else if (recognizer.state == UIGestureRecognizerStateBegan) {
[self.delegate draggableViewBeganDragging:self];
}
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"subtype" : "retina4",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
38 changes: 38 additions & 0 deletions InteractiveAnimations/InteractiveAnimations-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.unsignedinteger.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
16 changes: 16 additions & 0 deletions InteractiveAnimations/InteractiveAnimations-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
15 changes: 15 additions & 0 deletions InteractiveAnimations/UINTAppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// UINTAppDelegate.h
// InteractiveAnimations
//
// Created by Chris Eidhof on 02.05.14.
// Copyright (c) 2014 Unsigned Integer. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UINTAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
23 changes: 23 additions & 0 deletions InteractiveAnimations/UINTAppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// UINTAppDelegate.m
// InteractiveAnimations
//
// Created by Chris Eidhof on 02.05.14.
// Copyright (c) 2014 Unsigned Integer. All rights reserved.
//

#import "UINTAppDelegate.h"
#import "UINTViewController.h"

@implementation UINTAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UINTViewController *viewController = [[UINTViewController alloc] init];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
}

@end
18 changes: 18 additions & 0 deletions InteractiveAnimations/UINTViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// UINTViewController.h
// InteractiveAnimations
//
// Created by Chris Eidhof on 02.05.14.
// Copyright (c) 2014 Unsigned Integer. All rights reserved.
//

#import <UIKit/UIKit.h>

@class UINTAnimator;
@class UINTSpringAnimation;
@class POPSpringAnimation;


@interface UINTViewController : UIViewController

@end
86 changes: 86 additions & 0 deletions InteractiveAnimations/UINTViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// UINTViewController.m
// InteractiveAnimations
//
// Created by Chris Eidhof on 02.05.14.
// Copyright (c) 2014 Unsigned Integer. All rights reserved.
//

#import "UINTViewController.h"
#import "DraggableView.h"
#import "POPSpringAnimation.h"


typedef NS_ENUM(NSInteger, PaneState) {
PaneStateOpen,
PaneStateClosed,
};

@interface UINTViewController () <DraggableViewDelegate>

@property (nonatomic) PaneState paneState;
@property (nonatomic, strong) DraggableView *pane;
@property (nonatomic, strong) POPSpringAnimation *animation;
@end

@implementation UINTViewController

- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];

CGSize size = self.view.bounds.size;
self.paneState = PaneStateClosed;
DraggableView *view = [[DraggableView alloc] initWithFrame:CGRectMake(0, size.height * .75, size.width, size.height)];
view.backgroundColor = [UIColor grayColor];
view.delegate = self;
[self.view addSubview:view];
self.pane = view;

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap:)];
[self.view addGestureRecognizer:tapRecognizer];
}

- (CGPoint)targetPoint
{
CGSize size = self.view.bounds.size;
return self.paneState == PaneStateClosed > 0 ? CGPointMake(size.width/2, size.height * 1.25) : CGPointMake(size.width/2, size.height/2 + 50);
}

- (void)animatePaneWithInitialVelocity:(CGPoint)initialVelocity
{
[self.pane pop_removeAllAnimations];
POPSpringAnimation *animation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
animation.velocity = [NSValue valueWithCGPoint:initialVelocity];
animation.toValue = [NSValue valueWithCGPoint:self.targetPoint];
animation.springSpeed = 15;
animation.springBounciness = 6;
[self.pane pop_addAnimation:animation forKey:@"animation"];
self.animation = animation;
}


#pragma mark DraggableViewDelegate

- (void)draggableView:(DraggableView *)view draggingEndedWithVelocity:(CGPoint)velocity
{
self.paneState = velocity.y >= 0 ? PaneStateClosed : PaneStateOpen;
[self animatePaneWithInitialVelocity:velocity];
}

- (void)draggableViewBeganDragging:(DraggableView *)view
{
[view.layer pop_removeAllAnimations];
}


#pragma mark Actions

- (void)didTap:(UITapGestureRecognizer *)tapRecognizer
{
self.paneState = self.paneState == PaneStateOpen ? PaneStateClosed : PaneStateOpen;
[self animatePaneWithInitialVelocity:[self.animation.velocity CGPointValue]];
}

@end
2 changes: 2 additions & 0 deletions InteractiveAnimations/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

18 changes: 18 additions & 0 deletions InteractiveAnimations/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// main.m
// InteractiveAnimations
//
// Created by Chris Eidhof on 02.05.14.
// Copyright (c) 2014 Unsigned Integer. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "UINTAppDelegate.h"

int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([UINTAppDelegate class]));
}
}
22 changes: 22 additions & 0 deletions InteractiveAnimationsTests/InteractiveAnimationsTests-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.unsignedinteger.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Loading

0 comments on commit b7e33bb

Please sign in to comment.