-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TiMOB-14624] iOS - TransitionAnimation for NavigationWindow and Tab #4791
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
578d583
[TiMOB-14624] iOS - TransitionAnimation for NavigationWindow and Tab
pec1985 202b022
Merge branch 'refs/heads/master' into timob-14624
pec1985 327df9c
[TIMOB-14624] xcodeproj change
pec1985 e4e280d
[TIMOB-14624] Addressed comments in PR
pec1985 856914c
[TIMOB-14624] Fixed memory leak in navigation transition
pec1985 c36f904
[TIMOB-14624] Last comment on PR
pec1985 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,22 @@ -(void)windowClosing:(TiWindowProxy*)window animated:(BOOL)animated | |
|
||
#pragma mark - UINavigationControllerDelegate | ||
|
||
#ifdef USE_TI_UIIOSTRANSITIONANIMATION | ||
- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whole method under ifdef |
||
animationControllerForOperation:(UINavigationControllerOperation)operation | ||
fromViewController:(UIViewController *)fromVC | ||
toViewController:(UIViewController *)toVC | ||
{ | ||
if([toVC isKindOfClass:[TiViewController class]]) { | ||
TiViewController* toViewController = (TiViewController*)toVC; | ||
if([[toViewController proxy] isKindOfClass:[TiWindowProxy class]]) { | ||
TiWindowProxy *windowProxy = (TiWindowProxy*)[toViewController proxy]; | ||
return [windowProxy transitionAnimation]; | ||
} | ||
} | ||
return nil; | ||
} | ||
#endif | ||
|
||
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2009-2013 by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
#ifdef USE_TI_UIIOSTRANSITIONANIMATION | ||
#import "TiProxy.h" | ||
#import "TiAnimation.h" | ||
|
||
@interface TiUIiOSTransitionAnimationProxy : TiProxy<UIViewControllerAnimatedTransitioning, TiAnimationDelegate> | ||
{ | ||
id<UIViewControllerContextTransitioning> _transitionContext; | ||
TiAnimation *_transitionTo; | ||
TiAnimation *_transitionFrom; | ||
BOOL _endedTo; | ||
BOOL _endedFrom; | ||
NSNumber *_duration; | ||
} | ||
|
||
|
||
@end | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
/** | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2009-2013 by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
#ifdef USE_TI_UIIOSTRANSITIONANIMATION | ||
|
||
#import "TiUIiOSTransitionAnimationProxy.h" | ||
#import "TiViewController.h" | ||
#import "TiViewProxy.h" | ||
|
||
|
||
@implementation TiUIiOSTransitionAnimationProxy | ||
|
||
- (id)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
} | ||
return self; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
if(_transitionFrom != nil) { | ||
[self forgetProxy:_transitionFrom]; | ||
RELEASE_TO_NIL(_transitionFrom) | ||
} | ||
if(_transitionTo != nil) { | ||
[self forgetProxy:_transitionTo]; | ||
RELEASE_TO_NIL(_transitionTo) | ||
} | ||
RELEASE_TO_NIL(_duration) | ||
RELEASE_TO_NIL(_transitionContext) | ||
[super dealloc]; | ||
} | ||
|
||
-(id)duration | ||
{ | ||
return _duration; | ||
} | ||
|
||
-(void)setDuration:(id)arg | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ENSURE_SINGLE_ARG missing |
||
ENSURE_SINGLE_ARG(arg, NSNumber) | ||
RELEASE_TO_NIL(_duration) | ||
_duration = [arg retain]; | ||
} | ||
|
||
-(void)setTransitionTo:(id)args | ||
{ | ||
RELEASE_TO_NIL(_transitionTo) | ||
_transitionTo = [TiAnimation animationFromArg:args context:[self executionContext] create:NO]; | ||
if([_transitionTo isTransitionAnimation]) { | ||
DebugLog(@"[ERROR] Transition animations are not supported yet"); | ||
_transitionTo = nil; | ||
return; | ||
} | ||
[_transitionTo setDelegate:self]; | ||
[_transitionTo retain]; | ||
[self rememberProxy:_transitionTo]; | ||
} | ||
|
||
-(void)setTransitionFrom:(id)args | ||
{ | ||
RELEASE_TO_NIL(_transitionFrom) | ||
_transitionFrom = [TiAnimation animationFromArg:args context:[self executionContext] create:NO]; | ||
if([_transitionFrom isTransitionAnimation]) { | ||
DebugLog(@"[ERROR] Transition animations are not supported yet"); | ||
_transitionFrom = nil; | ||
return; | ||
} | ||
[_transitionFrom setDelegate:self]; | ||
[_transitionFrom retain]; | ||
[self rememberProxy:_transitionFrom]; | ||
} | ||
|
||
-(TiAnimation*)transitionTo | ||
{ | ||
return _transitionTo; | ||
} | ||
|
||
-(TiAnimation*)transitionFrom | ||
{ | ||
return _transitionFrom; | ||
} | ||
|
||
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext | ||
{ | ||
|
||
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; | ||
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; | ||
|
||
TiViewProxy *fromProxy = nil; | ||
TiViewProxy *toProxy = nil; | ||
if([fromViewController isKindOfClass:[TiViewController class]]) { | ||
|
||
fromProxy = [(TiViewController*)fromViewController proxy]; | ||
} | ||
if([toViewController isKindOfClass:[TiViewController class]]) { | ||
|
||
toProxy = [(TiViewController*)toViewController proxy]; | ||
} | ||
|
||
if([self _hasListeners:@"start"]) | ||
{ | ||
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; | ||
if(toProxy != nil) { | ||
[dict setObject:toProxy forKey:@"toWindow"]; | ||
} | ||
if(fromProxy != nil) { | ||
[dict setObject:fromProxy forKey:@"fromWindow"]; | ||
} | ||
[self fireEvent:@"start" withObject:dict propagate:NO reportSuccess:NO errorCode:0 message:nil]; | ||
} | ||
|
||
_endedFrom = (_transitionFrom == nil) || (fromProxy == nil) ; | ||
_endedTo = (_transitionTo == nil) || (toProxy == nil); | ||
|
||
_transitionContext = [transitionContext retain]; | ||
|
||
[fromProxy setParentVisible:YES]; | ||
[toProxy setParentVisible:YES]; | ||
|
||
UIView *container = [transitionContext containerView]; | ||
[container setUserInteractionEnabled:NO]; | ||
|
||
[container addSubview:[fromViewController view]]; | ||
[container addSubview:[toViewController view]]; | ||
|
||
if(_transitionFrom != nil && fromProxy != nil) { | ||
[fromProxy animate: _transitionFrom]; | ||
} | ||
if (_transitionTo != nil && toProxy != nil) { | ||
[toProxy animate: _transitionTo]; | ||
} | ||
|
||
if(_endedFrom && _endedTo) | ||
{ | ||
[_transitionContext completeTransition:YES]; | ||
} | ||
} | ||
|
||
-(void)animationDidComplete:(TiAnimation *)animation; | ||
{ | ||
if(animation == _transitionFrom) { | ||
_endedFrom = YES; | ||
} | ||
if(animation == _transitionTo) { | ||
_endedTo = YES; | ||
} | ||
if(_endedTo && _endedFrom) { | ||
[_transitionContext completeTransition:YES]; | ||
} | ||
} | ||
|
||
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext | ||
{ | ||
if(_transitionTo == nil && _transitionFrom == nil) { | ||
return 0; | ||
} | ||
if(_duration == nil) { | ||
return MAX( | ||
[TiUtils floatValue:[_transitionTo duration] def:0], | ||
[TiUtils floatValue:[_transitionFrom duration] def:0] | ||
) / 1000; | ||
} | ||
return [TiUtils floatValue:_duration def:0] / 1000; | ||
} | ||
|
||
- (void)animationEnded:(BOOL) transitionCompleted; | ||
{ | ||
if([self _hasListeners:@"end"]) { | ||
|
||
UIViewController *fromViewController = [_transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; | ||
UIViewController *toViewController = [_transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; | ||
|
||
TiViewProxy *fromProxy = nil; | ||
TiViewProxy *toProxy = nil; | ||
|
||
if([fromViewController isKindOfClass:[TiViewController class]]) { | ||
fromProxy = [(TiViewController*)fromViewController proxy]; | ||
} | ||
if([toViewController isKindOfClass:[TiViewController class]]) { | ||
toProxy = [(TiViewController*)toViewController proxy]; | ||
} | ||
|
||
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; | ||
if(toProxy != nil) { | ||
[dict setObject:toProxy forKey:@"toWindow"]; | ||
} | ||
if(fromProxy != nil) { | ||
[dict setObject:fromProxy forKey:@"fromWindow"]; | ||
} | ||
[self fireEvent:@"end" withObject:dict propagate:NO reportSuccess:NO errorCode:0 message:nil]; | ||
} | ||
RELEASE_TO_NIL(_transitionContext) | ||
} | ||
|
||
@end | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole method can be under the ifdef. If they never used a transition animation this is not required.