Skip to content

Commit

Permalink
Working on the sample
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamazz committed Apr 16, 2014
1 parent c052994 commit 06aad96
Show file tree
Hide file tree
Showing 23 changed files with 223 additions and 49 deletions.
65 changes: 33 additions & 32 deletions AMWaveTransition/AMWaveTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,38 +101,39 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
}

// Animates the cells of the starting view controller
[[fromVC visibleCells] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) {
NSTimeInterval delay = ((float)idx / (float)[[fromVC visibleCells] count]) * MAX_DELAY;
void (^animation)() = ^{
[obj setTransform:CGAffineTransformMakeTranslation(-delta, 0)];
[obj setAlpha:0];
};
void (^completion)(BOOL) = ^(BOOL finished){
[obj setTransform:CGAffineTransformIdentity];
};
if (self.transitionType == AMWaveTransitionTypeSubtle) {
[UIView animateWithDuration:DURATION delay:delay options:UIViewAnimationOptionCurveEaseIn animations:animation completion:completion];
} else {
[UIView animateWithDuration:DURATION delay:delay usingSpringWithDamping:0.75 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseIn animations:animation completion:completion];
}
}];


[[toVC visibleCells] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) {
NSTimeInterval delay = ((float)idx / (float)[[fromVC visibleCells] count]) * MAX_DELAY;
[obj setTransform:CGAffineTransformMakeTranslation(delta, 0)];
void (^animation)() = ^{
[obj setTransform:CGAffineTransformIdentity];
[obj setAlpha:1];

};
if (self.transitionType == AMWaveTransitionTypeSubtle) {
[UIView animateWithDuration:DURATION delay:delay options:UIViewAnimationOptionCurveEaseIn animations:animation completion:nil];
} else {
[UIView animateWithDuration:DURATION delay:delay usingSpringWithDamping:0.75 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseIn animations:animation completion:nil];
}
}];

if ([fromVC respondsToSelector:@selector(visibleCells)]) {
[[fromVC visibleCells] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) {
NSTimeInterval delay = ((float)idx / (float)[[fromVC visibleCells] count]) * MAX_DELAY;
void (^animation)() = ^{
[obj setTransform:CGAffineTransformMakeTranslation(-delta, 0)];
[obj setAlpha:0];
};
void (^completion)(BOOL) = ^(BOOL finished){
[obj setTransform:CGAffineTransformIdentity];
};
if (self.transitionType == AMWaveTransitionTypeSubtle) {
[UIView animateWithDuration:DURATION delay:delay options:UIViewAnimationOptionCurveEaseIn animations:animation completion:completion];
} else {
[UIView animateWithDuration:DURATION delay:delay usingSpringWithDamping:0.75 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseIn animations:animation completion:completion];
}
}];
}

if ([toVC respondsToSelector:@selector(visibleCells)]) {
[[toVC visibleCells] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) {
NSTimeInterval delay = ((float)idx / (float)[[fromVC visibleCells] count]) * MAX_DELAY;
[obj setTransform:CGAffineTransformMakeTranslation(delta, 0)];
void (^animation)() = ^{
[obj setTransform:CGAffineTransformIdentity];
[obj setAlpha:1];
};
if (self.transitionType == AMWaveTransitionTypeSubtle) {
[UIView animateWithDuration:DURATION delay:delay options:UIViewAnimationOptionCurveEaseIn animations:animation completion:nil];
} else {
[UIView animateWithDuration:DURATION delay:delay usingSpringWithDamping:0.75 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseIn animations:animation completion:nil];
}
}];
}
}];
}

Expand Down
25 changes: 16 additions & 9 deletions Demo/Demo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
Expand All @@ -17,25 +16,29 @@
<rect key="frame" x="0.0" y="64" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="aQ9-9T-aYe">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="84" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="aQ9-9T-aYe">
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="FfK-C6-aR0" style="IBUITableViewCellStyleDefault" id="cff-IQ-tMW">
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="FfK-C6-aR0" imageView="XHB-Rt-Pqb" rowHeight="84" style="IBUITableViewCellStyleDefault" id="cff-IQ-tMW">
<rect key="frame" x="0.0" y="22" width="320" height="84"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="cff-IQ-tMW" id="2md-yu-DyY">
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="287" height="83"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="FfK-C6-aR0">
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
<rect key="frame" x="82" y="0.0" width="203" height="83"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<fontDescription key="fontDescription" name="GillSans-Light" family="Gill Sans" pointSize="24"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="camera" id="XHB-Rt-Pqb">
<rect key="frame" x="15" y="21" width="52" height="40"/>
<autoresizingMask key="autoresizingMask"/>
</imageView>
</subviews>
</tableViewCellContentView>
<connections>
Expand All @@ -62,8 +65,9 @@
<outlet property="tableView" destination="aQ9-9T-aYe" id="i7x-D2-yFZ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="636" y="138"/>
<point key="canvasLocation" x="641" y="138"/>
</scene>
<!--Second View Controller-->
<scene sceneID="PAj-cu-1wY">
Expand Down Expand Up @@ -143,6 +147,9 @@
<point key="canvasLocation" x="217" y="138"/>
</scene>
</scenes>
<resources>
<image name="camera" width="52" height="40"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
Expand Down
2 changes: 0 additions & 2 deletions Demo/Demo/Demo-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/background.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "background.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/beaker.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "beaker.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/camera.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "camera.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/clock.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "clock.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/heart.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "heart.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/map.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "map.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Demo/Demo/Images.xcassets/map.imageset/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/navbar.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "navbar.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/paperclip.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "paperclip.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Demo/Demo/Images.xcassets/pencil.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "pencil.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions Demo/Demo/SecondViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ - (void)viewDidLoad
{
[super viewDidLoad];

[self.navigationController.view setBackgroundColor:[UIColor whiteColor]];

[self.view setBackgroundColor:[UIColor clearColor]];
[self.tableView setBackgroundColor:[UIColor clearColor]];
}
Expand Down
25 changes: 21 additions & 4 deletions Demo/Demo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@interface ViewController () <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) NSArray *data;

@end

Expand All @@ -21,10 +22,22 @@ - (void)viewDidLoad
{
[super viewDidLoad];

[self.navigationController.view setBackgroundColor:[UIColor whiteColor]];

[self.navigationController.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]]];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar"] forBarMetrics:UIBarMetricsDefault];
[self.view setBackgroundColor:[UIColor clearColor]];
[self.tableView setBackgroundColor:[UIColor clearColor]];
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

[self setTitle:@"Demo"];
self.data =
@[
@{@"text": @"Stylized organs", @"icon": @"heart"},
@{@"text": @"Food pictures", @"icon": @"camera"},
@{@"text": @"Straight line maker", @"icon": @"pencil"},
@{@"text": @"Let's cook", @"icon": @"beaker"},
@{@"text": @"Beer map", @"icon": @"map"},
@{@"text": @"Clippy is back", @"icon": @"paperclip"}
];
}

- (void)viewDidAppear:(BOOL)animated
Expand All @@ -35,15 +48,19 @@ - (void)viewDidAppear:(BOOL)animated

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 20;
return [self.data count];
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.textLabel.text = @"Cell content is here";

NSDictionary* dict = self.data[indexPath.row];

cell.textLabel.text = dict[@"text"];
[cell setBackgroundColor:[UIColor clearColor]];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[cell.imageView setImage:[UIImage imageNamed:dict[@"icon"]]];
return cell;
}

Expand Down

0 comments on commit 06aad96

Please sign in to comment.