Skip to content

Commit

Permalink
Fix modal animations (#7130)
Browse files Browse the repository at this point in the history
Co-authored-by: Guy Carmeli <[email protected]>
  • Loading branch information
yogevbd and guyca authored May 25, 2021
1 parent a475b2d commit 2f34c9a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions lib/ios/RNNCommandsHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ - (void)showModal:(NSDictionary *)layout
[newVc setReactViewReadyCallback:^{
[self->_modalManager
showModal:weakNewVC
animated:[weakNewVC.resolveOptionsWithDefault.animations.showModal.enable
animated:[weakNewVC.resolveOptionsWithDefault.animations.showModal.enter.enable
withDefault:YES]
completion:^(NSString *componentId) {
[self->_layoutManager removePendingViewController:weakNewVC];
Expand Down Expand Up @@ -409,13 +409,13 @@ - (void)dismissAllModals:(NSDictionary *)mergeOptions
RNNAssertMainQueue();

RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
[_modalManager dismissAllModalsAnimated:[options.animations.dismissModal.enable withDefault:YES]
completion:^{
[self->_eventEmitter
sendOnNavigationCommandCompletion:dismissAllModals
commandId:commandId];
completion();
}];
[_modalManager
dismissAllModalsAnimated:[options.animations.dismissModal.exit.enable withDefault:YES]
completion:^{
[self->_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals
commandId:commandId];
completion();
}];
}

- (void)showOverlay:(NSDictionary *)layout
Expand Down
4 changes: 2 additions & 2 deletions lib/ios/RNNModalManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ - (void)removePendingNextModalIfOnTop:(RNNTransitionCompletionBlock)completion {
if (modalToDismiss == topPresentedVC ||
[[topPresentedVC childViewControllers] containsObject:modalToDismiss]) {
[modalToDismiss
dismissViewControllerAnimated:[optionsWithDefault.animations.dismissModal.enable
dismissViewControllerAnimated:[optionsWithDefault.animations.dismissModal.exit.enable
withDefault:YES]
completion:^{
[self->_pendingModalIdsToDismiss removeObject:modalToDismiss];
Expand All @@ -172,7 +172,7 @@ - (void)removePendingNextModalIfOnTop:(RNNTransitionCompletionBlock)completion {
} else {
[modalToDismiss.view removeFromSuperview];
modalToDismiss.view = nil;
modalToDismiss.getCurrentChild.resolveOptions.animations.dismissModal.enable =
modalToDismiss.getCurrentChild.resolveOptions.animations.dismissModal.exit.enable =
[[Bool alloc] initWithBOOL:NO];
[self dismissedModal:modalToDismiss];

Expand Down
1 change: 0 additions & 1 deletion lib/ios/RNNScreenTransitionsCreator.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#import "RNNScreenTransitionsCreator.h"
#import "DisplayLinkAnimatorDelegate.h"
#import "ElementTransitionsCreator.h"
#import "SharedElementAnimator.h"

@implementation RNNScreenTransitionsCreator

Expand Down
3 changes: 2 additions & 1 deletion lib/ios/TransitionOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ - (void)mergeOptions:(TransitionOptions *)options {
- (BOOL)hasAnimation {
return self.x.hasAnimation || self.y.hasAnimation || self.alpha.hasAnimation ||
self.translationX.hasAnimation || self.translationY.hasAnimation ||
self.rotationX.hasAnimation || self.rotationY.hasAnimation;
self.rotationX.hasAnimation || self.rotationY.hasAnimation ||
self.waitForRender.hasValue || self.enable.hasValue;
}

- (NSTimeInterval)maxDuration {
Expand Down
1 change: 0 additions & 1 deletion lib/ios/ViewAnimationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
@property(nonatomic, strong) NSArray<ElementTransitionOptions *> *elementTransitions;
@property(nonatomic, strong) NSArray<SharedElementTransitionOptions *> *sharedElementTransitions;
@property(nonatomic, strong) Bool *waitForRender;
@property(nonatomic, strong) Bool *enable;

- (BOOL)shouldWaitForRender;
- (NSTimeInterval)maxDuration;
Expand Down
3 changes: 2 additions & 1 deletion lib/ios/ViewAnimationOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
self.elementTransitions = [OptionsArrayParser parse:dict
key:@"elementTransitions"
ofClass:ElementTransitionOptions.class];
self.enable = [BoolParser parse:dict key:@"enable"];
self.waitForRender = [BoolParser parse:dict key:@"waitForRender"];

return self;
Expand All @@ -24,6 +23,8 @@ - (void)mergeOptions:(ViewAnimationOptions *)options {
self.sharedElementTransitions = options.sharedElementTransitions;
if (options.elementTransitions)
self.elementTransitions = options.elementTransitions;
if (options.waitForRender)
self.waitForRender = options.waitForRender;
}

- (BOOL)hasAnimation {
Expand Down
4 changes: 2 additions & 2 deletions playground/ios/NavigationTests/RNNCommandsHandlerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ - (void)testMergeOptions_shouldResolveTreeOptions {
- (void)testShowModal_shouldShowAnimated {
[self.uut setReadyToReceiveCommands:true];
self.vc1.options = [RNNNavigationOptions emptyOptions];
self.vc1.options.animations.showModal.enable = [[Bool alloc] initWithBOOL:YES];
self.vc1.options.animations.showModal.enter.enable = [[Bool alloc] initWithBOOL:YES];

id mockedVC = [OCMockObject partialMockForObject:self.vc1];
OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(mockedVC);
Expand Down Expand Up @@ -785,7 +785,7 @@ - (void)testDismissModal_shouldMergeOptions {

[[self.modalManager expect]
dismissModal:[OCMArg checkWithBlock:^BOOL(UIViewController *modalToDismiss) {
return modalToDismiss.options.animations.dismissModal.enable.get == NO;
return modalToDismiss.options.animations.dismissModal.exit.enable.get == NO;
}]
completion:OCMArg.any];

Expand Down

0 comments on commit 2f34c9a

Please sign in to comment.