From b5061b2be665b9ac14ef635cb9e7cb194b0335e4 Mon Sep 17 00:00:00 2001 From: sparga Date: Thu, 6 Feb 2014 18:46:36 +0100 Subject: [PATCH 01/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84e4292..f04c563 100644 --- a/README.md +++ b/README.md @@ -124,4 +124,4 @@ Contributions for bug fixing or improvements are welcomed. Feel free to submit a ## Licence MaryPopin is available under the MIT license. See the LICENSE file for more info. -[![Analytics](https://ga-beacon.appspot.com/UA-44164731-2/mary-popin/readme?pixel)](https://github.com/igrigorik/ga-beacon) +[![Analytics](https://ga-beacon.appspot.com/UA-44164731-1/mary-popin/readme?pixel)](https://github.com/igrigorik/ga-beacon) From 6eda94393a1e028dd0f2a1519a2619195160afb6 Mon Sep 17 00:00:00 2001 From: sparga Date: Fri, 21 Feb 2014 14:57:18 +0100 Subject: [PATCH 02/17] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f04c563..2b410df 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,11 @@ By default, popin is centered in the parent controller view. But you can provide ``` ### Sample project -The sample project show how to present and dismiss a popin with different transition styles. +The sample project show how to present and dismiss a popin with different transition styles. + +If you are using CocoaPods in version 0.29 or better, you can quickly run the demo project with the following command line : + + pod try MaryPopin ## Requirements MaryPopin requires Xcode 5 as it uses (optionaly) UIKit Dynamics and motion effects. You can use iOS 5 as a target deployment version. Note that some transition styles are not supported under iOS 7 and will be replaced by the default transition style. From be60c87d75c33800db4d64d35a39fbb4ecce66b5 Mon Sep 17 00:00:00 2001 From: sparga Date: Sun, 16 Mar 2014 15:51:58 +0100 Subject: [PATCH 03/17] Fixed warning in Xcode 5.1 --- MaryPopinDemo/MaryPopinDemo.xcodeproj/project.pbxproj | 4 +--- MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPad.storyboard | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/MaryPopinDemo/MaryPopinDemo.xcodeproj/project.pbxproj b/MaryPopinDemo/MaryPopinDemo.xcodeproj/project.pbxproj index 38e94ae..64d1579 100644 --- a/MaryPopinDemo/MaryPopinDemo.xcodeproj/project.pbxproj +++ b/MaryPopinDemo/MaryPopinDemo.xcodeproj/project.pbxproj @@ -193,7 +193,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = BKT; - LastUpgradeCheck = 0500; + LastUpgradeCheck = 0510; ORGANIZATIONNAME = Backelite; }; buildConfigurationList = 2BDC27CB185F0DE900627E9A /* Build configuration list for PBXProject "MaryPopinDemo" */; @@ -281,7 +281,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -320,7 +319,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; diff --git a/MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPad.storyboard b/MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPad.storyboard index e94ab97..2546465 100644 --- a/MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPad.storyboard +++ b/MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPad.storyboard @@ -1,8 +1,8 @@ - + - + @@ -54,7 +54,7 @@ - + @@ -112,4 +112,4 @@ - \ No newline at end of file + From c4f5fc562b118171770930e6dc904260a14c7404 Mon Sep 17 00:00:00 2001 From: sparga Date: Sun, 16 Mar 2014 15:54:21 +0100 Subject: [PATCH 04/17] Fixed a crash when launching app on 7.1 simulator --- MaryPopinDemo/MaryPopinDemo/MaryPopinDemo-Info.plist | 2 -- 1 file changed, 2 deletions(-) diff --git a/MaryPopinDemo/MaryPopinDemo/MaryPopinDemo-Info.plist b/MaryPopinDemo/MaryPopinDemo/MaryPopinDemo-Info.plist index 548a71e..e739c98 100644 --- a/MaryPopinDemo/MaryPopinDemo/MaryPopinDemo-Info.plist +++ b/MaryPopinDemo/MaryPopinDemo/MaryPopinDemo-Info.plist @@ -28,8 +28,6 @@ Main_iPhone UIMainStoryboardFile~ipad Main_iPad - UIMainStoryboardFile~iphone - Main UIRequiredDeviceCapabilities armv7 From d249b80b78149837d10dbe26405639ed3751fbf1 Mon Sep 17 00:00:00 2001 From: sparga Date: Sun, 16 Mar 2014 16:09:04 +0100 Subject: [PATCH 05/17] Updated pod spec to v 1.2.1 --- MaryPopin.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MaryPopin.podspec b/MaryPopin.podspec index e335658..6924b97 100644 --- a/MaryPopin.podspec +++ b/MaryPopin.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MaryPopin" - s.version = "1.2" + s.version = "1.2.1" s.summary = "Category to display modal-like view controllers with more options" s.description = <<-DESC @@ -17,7 +17,7 @@ Pod::Spec.new do |s| s.platform = :ios, '5.0' - s.source = { :git => "https://github.com/Backelite/MaryPopin.git", :tag => "1.2" } + s.source = { :git => "https://github.com/Backelite/MaryPopin.git", :tag => "1.2.1" } s.source_files = 'MaryPopin/**/*.{h,m}' From 382cbd2fccf8bcd1b4161a3fea7354bb29c603ad Mon Sep 17 00:00:00 2001 From: Joao Nunes Date: Thu, 3 Apr 2014 11:51:38 +0300 Subject: [PATCH 06/17] Added basic custom animations Added an iPhone example --- MaryPopin/UIViewController+MaryPopin.h | 41 ++++++++++++- MaryPopin/UIViewController+MaryPopin.m | 57 ++++++++++++++++++- .../MaryPopinDemo/BKTViewController.m | 20 +++++++ .../en.lproj/Main_iPhone.storyboard | 27 +++++++-- 4 files changed, 138 insertions(+), 7 deletions(-) diff --git a/MaryPopin/UIViewController+MaryPopin.h b/MaryPopin/UIViewController+MaryPopin.h index 42b0e36..e68c1de 100644 --- a/MaryPopin/UIViewController+MaryPopin.h +++ b/MaryPopin/UIViewController+MaryPopin.h @@ -52,7 +52,11 @@ typedef NS_ENUM(NSInteger, BKTPopinTransitionStyle) { * When the view controller is presented, its view has a undefined behavior. */ //UIDynamics transition styles - BKTPopinTransitionStyleSnap + BKTPopinTransitionStyleSnap, + /** + * When the view controller is presented, its view has a custom animation. + */ + BKTPopinTransitionStyleCustom }; /** @@ -245,4 +249,39 @@ typedef NS_OPTIONS(NSUInteger, BKTPopinOption) { */ - (void)setPopinOptions:(BKTPopinOption)popinOptions; + +/** + * The popinCustumInAnimation let's you pass an costum animation. Default value is nil. + * + * @return The Block animation. + * @see -setPopinCustomInAnimation: + * @since v1.0 + */ +- (void (^)(UIViewController * popInController,CGRect initialFrame,CGRect finalFrame))popinCustomInAnimation; + +/** + * The popinCostumAnimation let's you pass an custom in animation. The popInController frame must be the finalFrame in the end of the animation. + * + * @param customInAnimation The Block with animation. + * @since v1.0 + */ +- (void)setPopinCustomInAnimation:(void (^)(UIViewController * popInController,CGRect initialFrame,CGRect finalFrame))customInAnimation; + +/** + * The popinCustomOutAnimation let's you pass an costum animation. Default value is nil. + * + * @return The Block animation. + * @see -setPopinCustomOutAnimation: + * @since v1.0 + */ +- (void (^)(UIViewController * popInController,CGRect initialFrame,CGRect finalFrame))popinCustomOutAnimation; + +/** + * The popinCostumAnimation let's you pass an custom out animation. The popInController frame must be the finalFrame in the end of the animation. + * + * @param customOutAnimation The Block with animation. + * @since v1.0 + */ +- (void)setPopinCustomOutAnimation:(void (^)(UIViewController * popInController,CGRect initialFrame,CGRect finalFrame))customOutAnimation; + @end diff --git a/MaryPopin/UIViewController+MaryPopin.m b/MaryPopin/UIViewController+MaryPopin.m index 5fad207..ed664ea 100644 --- a/MaryPopin/UIViewController+MaryPopin.m +++ b/MaryPopin/UIViewController+MaryPopin.m @@ -407,6 +407,27 @@ - (void)setPopinOptions:(BKTPopinOption)popinOptions objc_setAssociatedObject(self, @selector(popinOptions), [NSNumber numberWithInt:popinOptions], OBJC_ASSOCIATION_RETAIN_NONATOMIC); } +- (void (^)(UIViewController * popInController,CGRect initialFrame,CGRect finalFrame))popinCustomInAnimation +{ + return objc_getAssociatedObject(self, _cmd); +} + +- (void)setPopinCustomInAnimation:(void (^)(UIViewController * popInController,CGRect initialFrame,CGRect finalFrame))popinCustomInAnimation +{ + objc_setAssociatedObject(self, @selector(popinCustomInAnimation), popinCustomInAnimation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + + +- (void (^)(UIViewController * popInController,CGRect initialFrame,CGRect finalFrame))popinCustomOutAnimation +{ + return objc_getAssociatedObject(self, _cmd); +} + +- (void)setPopinCustomOutAnimation:(void (^)(UIViewController * popInController,CGRect initialFrame,CGRect finalFrame))popinCustomOutAnimation +{ + objc_setAssociatedObject(self, @selector(popinCustomOutAnimation), popinCustomOutAnimation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + - (UIView *)dimmingView { return objc_getAssociatedObject(self, _cmd); @@ -442,6 +463,9 @@ - (void)setAnimator:(UIDynamicAnimator *)animator case BKTPopinTransitionStyleSpringyZoom: case BKTPopinTransitionStyleZoom: return [self zoomInAnimationForPopinController:popinController toPosition:finalFrame]; + case BKTPopinTransitionStyleCustom: + if ([popinController popinCustomInAnimation]) + return [self customInAnimationForPopinController:popinController toPosition:finalFrame withDirection:direction]; default: return [self alphaInAnimationForPopinController:popinController toPosition:finalFrame]; } @@ -460,6 +484,9 @@ - (void)setAnimator:(UIDynamicAnimator *)animator case BKTPopinTransitionStyleSpringyZoom: case BKTPopinTransitionStyleZoom: return [self zoomOutAnimationForPopinController:popinController]; + case BKTPopinTransitionStyleCustom: + if ([popinController popinCustomOutAnimation]) + return [self customOutAnimationForPopinController:popinController withDirection:direction]; default: return [self alphaOutAnimationForPopinController:popinController]; } @@ -586,11 +613,39 @@ - (void)setAnimator:(UIDynamicAnimator *)animator return NULL; } + +- (void (^)(void))customInAnimationForPopinController:(UIViewController *)popinController toPosition:(CGRect)finalFrame withDirection:(BKTPopinTransitionDirection)direction +{ + CGRect initialFrame = [self animationFrameForPopinController:popinController margin:0.0f]; + popinController.view.frame = initialFrame; + + void (^animation)(void) = ^{ + + popinController.popinCustomInAnimation(popinController,initialFrame,finalFrame); + + }; + + return animation; +} +- (void (^)(void))customOutAnimationForPopinController:(UIViewController *)popinController withDirection:(BKTPopinTransitionDirection)direction +{ + CGRect initialFrame = popinController.view.frame; + CGRect finalFrame = [self animationFrameForPopinController:popinController margin:0.0f]; + + //Change properties values + void (^animation)(void) = ^{ + + popinController.popinCustomOutAnimation(popinController,initialFrame,finalFrame); + + }; + return animation; +} + #pragma mark - Dynamic transition helper methods - (BOOL)popinTransitionUsesDynamics { - return self.popinTransitionStyle >= BKTPopinTransitionStyleSnap && [self popinCanUseDynamics]; + return self.popinTransitionStyle == BKTPopinTransitionStyleSnap && [self popinCanUseDynamics]; } - (BOOL)popinCanUseDynamics diff --git a/MaryPopinDemo/MaryPopinDemo/BKTViewController.m b/MaryPopinDemo/MaryPopinDemo/BKTViewController.m index 4b7dfd9..03d6917 100644 --- a/MaryPopinDemo/MaryPopinDemo/BKTViewController.m +++ b/MaryPopinDemo/MaryPopinDemo/BKTViewController.m @@ -56,6 +56,26 @@ - (IBAction)presentPopinPressed:(id)sender { } else { [popin setPopinOptions:BKTPopinDisableAutoDismiss]; } + + if (popin.popinTransitionStyle == BKTPopinTransitionStyleCustom) + { + [popin setPopinCustomInAnimation:^(UIViewController *popInController, CGRect initialFrame, CGRect finalFrame) { + + /* + CGFloat y = self.view.center.y; + CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.y"]; + animation.values = @[@(y), @(y + 20), @(y - 10), @(y)]; + animation.keyTimes = @[@(0), @(0.5), @(0.75), @(1)]; + animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; + animation.duration = 0.4; + [popInController.view.layer addAnimation:animation forKey:@"dropdown"]; + */ + + popInController.view.frame = finalFrame; + + }]; + } + [popin setPopinTransitionDirection:BKTPopinTransitionDirectionTop]; [self.navigationController presentPopinController:popin animated:YES completion:^{ NSLog(@"Popin presented !"); diff --git a/MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPhone.storyboard b/MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPhone.storyboard index 141a19f..adec3da 100644 --- a/MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPhone.storyboard +++ b/MaryPopinDemo/MaryPopinDemo/en.lproj/Main_iPhone.storyboard @@ -1,8 +1,8 @@ - + - + @@ -14,7 +14,7 @@