Skip to content

Commit

Permalink
Resolve modal presentation and transition on showModal (#6019)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd authored Mar 10, 2020
1 parent 40251c3 commit 931167e
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 93 deletions.
3 changes: 0 additions & 3 deletions lib/ios/RNNBasePresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#import "RNNReactComponentRegistry.h"
#import "UIViewController+LayoutProtocol.h"
#import "DotIndicatorOptions.h"
#import "RCTConvert+Modal.h"

@implementation RNNBasePresenter

Expand Down Expand Up @@ -40,8 +39,6 @@ - (void)componentDidDisappear {
- (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
UIViewController* viewController = self.boundViewController;
RNNNavigationOptions *withDefault = [initialOptions withDefault:[self defaultOptions]];
[viewController setModalPresentationStyle:[RCTConvert UIModalPresentationStyle:[withDefault.modalPresentationStyle getWithDefaultValue:@"default"]]];
[viewController setModalTransitionStyle:[RCTConvert UIModalTransitionStyle:[withDefault.modalTransitionStyle getWithDefaultValue:@"coverVertical"]]];

if (@available(iOS 13.0, *)) {
viewController.modalInPresentation = ![withDefault.modal.swipeToDismiss getWithDefaultValue:YES];
Expand Down
9 changes: 0 additions & 9 deletions lib/ios/RNNComponentPresenter.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#import "RNNComponentPresenter.h"
#import "UIViewController+RNNOptions.h"
#import "UITabBarController+RNNOptions.h"
#import "RCTConvert+Modal.h"
#import "RNNTitleViewHelper.h"
#import "UIViewController+LayoutProtocol.h"
#import "RNNReactTitleView.h"
Expand Down Expand Up @@ -100,14 +99,6 @@ - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigat
[viewController setBackgroundImage:options.backgroundImage.get];
}

if (options.modalPresentationStyle.hasValue) {
[viewController setModalPresentationStyle:[RCTConvert UIModalPresentationStyle:options.modalPresentationStyle.get]];
}

if (options.modalTransitionStyle.hasValue) {
[viewController setModalTransitionStyle:[RCTConvert UIModalTransitionStyle:options.modalTransitionStyle.get]];
}

if (options.topBar.searchBar.hasValue) {
BOOL hideNavBarOnFocusSearchBar = YES;
if (options.topBar.hideNavBarOnFocusSearchBar.hasValue) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ios/RNNComponentViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#import "RNNNavigationOptions.h"
#import "RNNUIBarButtonItem.h"
#import "RNNLayoutInfo.h"
#import "RNNLayoutProtocol.h"
#import "UIViewController+LayoutProtocol.h"
#import "RNNComponentPresenter.h"

typedef void (^PreviewCallback)(UIViewController *vc);
Expand Down
1 change: 0 additions & 1 deletion lib/ios/RNNComponentViewController.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#import "RNNComponentViewController.h"
#import "UIViewController+LayoutProtocol.h"

@implementation RNNComponentViewController

Expand Down
10 changes: 10 additions & 0 deletions lib/ios/RNNConvert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>
#import <React/RCTConvert.h>

@interface RNNConvert : NSObject

+ (UIModalPresentationStyle)UIModalPresentationStyle:(id)json;

+ (UIModalTransitionStyle)UIModalTransitionStyle:(id)json;

@end
14 changes: 4 additions & 10 deletions lib/ios/RCTConvert+Modal.h → lib/ios/RNNConvert.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#import <React/RCTConvert.h>
#import "RNNConvert.h"

@interface RCTConvert (Modal)

+ (UIModalPresentationStyle)defaultModalPresentationStyle;

@end

@implementation RCTConvert (Modal)
@implementation RNNConvert

+ (UIModalPresentationStyle)defaultModalPresentationStyle {
if (@available(iOS 13.0, *)) {
Expand All @@ -33,7 +27,7 @@ RCT_ENUM_CONVERTER(UIModalPresentationStyle,
@"overCurrentContext": @(UIModalPresentationOverCurrentContext),
@"popover": @(UIModalPresentationPopover),
@"none": @(UIModalPresentationNone),
@"default": @([RCTConvert defaultModalPresentationStyle])
@"default": @([RNNConvert defaultModalPresentationStyle])
}), UIModalPresentationFullScreen, integerValue)
@end

@end
4 changes: 4 additions & 0 deletions lib/ios/RNNModalManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import "UIViewController+LayoutProtocol.h"
#import "ModalTransitionDelegate.h"
#import "ModalDismissTransitionDelegate.h"
#import "RNNConvert.h"

@interface RNNModalManager ()
@property (nonatomic, strong) ModalTransitionDelegate* modalTransitionDelegate;
Expand Down Expand Up @@ -36,6 +37,9 @@ - (void)showModal:(UIViewController<RNNLayoutProtocol> *)viewController animated

UIViewController* topVC = [self topPresentedVC];

viewController.modalPresentationStyle = [RNNConvert UIModalPresentationStyle:[viewController.resolveOptionsWithDefault.modalPresentationStyle getWithDefaultValue:@"default"]];
viewController.modalTransitionStyle = [RNNConvert UIModalTransitionStyle:[viewController.resolveOptionsWithDefault.modalTransitionStyle getWithDefaultValue:@"coverVertical"]];

if (viewController.presentationController) {
viewController.presentationController.delegate = self;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ios/RNNNavigationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ extern const NSInteger BLUR_TOPBAR_TAG;

- (instancetype)initEmptyOptions;

+ (instancetype)emptyOptions;

- (RNNNavigationOptions *)withDefault:(RNNNavigationOptions *)defaultOptions;

- (RNNNavigationOptions *)copy;
Expand Down
4 changes: 4 additions & 0 deletions lib/ios/RNNNavigationOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
return self;
}

+ (instancetype)emptyOptions {
return [[RNNNavigationOptions alloc] initEmptyOptions];
}

- (instancetype)initEmptyOptions {
self = [self initWithDict:@{}];
return self;
Expand Down
1 change: 0 additions & 1 deletion lib/ios/RNNSplitViewControllerPresenter.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#import "RNNSplitViewControllerPresenter.h"
#import "UISplitViewController+RNNOptions.h"
#import "RCTConvert+Modal.h"
#import "RNNSplitViewController.h"

@implementation RNNSplitViewControllerPresenter
Expand Down
4 changes: 0 additions & 4 deletions lib/ios/RNNStackController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ - (UIStatusBarStyle)preferredStatusBarStyle {
return [_presenter getStatusBarStyle:self.resolveOptions];
}

- (UIModalPresentationStyle)modalPresentationStyle {
return self.getCurrentChild.modalPresentationStyle;
}

- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
[self prepareForPop];
return [super popViewControllerAnimated:animated];
Expand Down
13 changes: 8 additions & 5 deletions lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
505EDD34214E7B7B0071C7DE /* RNNLeafProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 505EDD33214E7A6A0071C7DE /* RNNLeafProtocol.h */; };
505EDD3C214FA8000071C7DE /* RNNComponentPresenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 505EDD3A214FA8000071C7DE /* RNNComponentPresenter.h */; };
505EDD3D214FA8000071C7DE /* RNNComponentPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 505EDD3B214FA8000071C7DE /* RNNComponentPresenter.m */; };
505EDD4A214FDA800071C7DE /* RCTConvert+Modal.h in Headers */ = {isa = PBXBuildFile; fileRef = 505EDD48214FDA800071C7DE /* RCTConvert+Modal.h */; };
5060DE73219DAD7E00D0C052 /* ReactNativeNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BA500731E2544B9001B9E1B /* ReactNativeNavigation.h */; };
5060DE74219DAD8300D0C052 /* RNNBridgeManagerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 502CB43920CBCA140019B2FE /* RNNBridgeManagerDelegate.h */; };
5061B6C723D48449008B9827 /* VerticalRotationTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 5061B6C523D48449008B9827 /* VerticalRotationTransition.h */; };
Expand Down Expand Up @@ -270,6 +269,8 @@
509416A823A11C630036092C /* EnumParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 509416A623A11C630036092C /* EnumParser.m */; };
509416AB23A11CB20036092C /* NullEnum.h in Headers */ = {isa = PBXBuildFile; fileRef = 509416A923A11CB20036092C /* NullEnum.h */; };
509416AC23A11CB20036092C /* NullEnum.m in Sources */ = {isa = PBXBuildFile; fileRef = 509416AA23A11CB20036092C /* NullEnum.m */; };
5095BB722416A3B900C4CD41 /* RNNConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5095BB702416A3B900C4CD41 /* RNNConvert.h */; };
5095BB732416A3B900C4CD41 /* RNNConvert.m in Sources */ = {isa = PBXBuildFile; fileRef = 5095BB712416A3B900C4CD41 /* RNNConvert.m */; };
509670A023D4A81E002224F9 /* BaseAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = 5096709E23D4A81E002224F9 /* BaseAnimator.h */; };
509670A123D4A81E002224F9 /* BaseAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = 5096709F23D4A81E002224F9 /* BaseAnimator.m */; };
50967F5B232FC2C200BEEA92 /* RNNFontAttributesCreatorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 50967F5A232FC2C200BEEA92 /* RNNFontAttributesCreatorTest.m */; };
Expand Down Expand Up @@ -704,7 +705,6 @@
505EDD3A214FA8000071C7DE /* RNNComponentPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNComponentPresenter.h; sourceTree = "<group>"; };
505EDD3B214FA8000071C7DE /* RNNComponentPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNComponentPresenter.m; sourceTree = "<group>"; };
505EDD47214FC4A60071C7DE /* RNNLayoutProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNLayoutProtocol.h; sourceTree = "<group>"; };
505EDD48214FDA800071C7DE /* RCTConvert+Modal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTConvert+Modal.h"; sourceTree = "<group>"; };
5061B6C523D48449008B9827 /* VerticalRotationTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VerticalRotationTransition.h; sourceTree = "<group>"; };
5061B6C623D48449008B9827 /* VerticalRotationTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VerticalRotationTransition.m; sourceTree = "<group>"; };
506317A8220B547400B26FC3 /* UIImage+insets.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+insets.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -753,6 +753,8 @@
509416A623A11C630036092C /* EnumParser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EnumParser.m; sourceTree = "<group>"; };
509416A923A11CB20036092C /* NullEnum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NullEnum.h; sourceTree = "<group>"; };
509416AA23A11CB20036092C /* NullEnum.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NullEnum.m; sourceTree = "<group>"; };
5095BB702416A3B900C4CD41 /* RNNConvert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNConvert.h; sourceTree = "<group>"; };
5095BB712416A3B900C4CD41 /* RNNConvert.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNConvert.m; sourceTree = "<group>"; };
5096709923D49B35002224F9 /* DisplayLinkAnimatorDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayLinkAnimatorDelegate.h; sourceTree = "<group>"; };
5096709E23D4A81E002224F9 /* BaseAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseAnimator.h; sourceTree = "<group>"; };
5096709F23D4A81E002224F9 /* BaseAnimator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseAnimator.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1007,12 +1009,13 @@
5038A373216CDDB6009280BC /* UIViewController+SideMenuController.m */,
5038A3BF216E1E66009280BC /* RNNFontAttributesCreator.h */,
5038A3C0216E1E66009280BC /* RNNFontAttributesCreator.m */,
505EDD48214FDA800071C7DE /* RCTConvert+Modal.h */,
50DA74CF232F80FE004A00C1 /* RCTConvert+UIFontWeight.h */,
50E02BD521A6E54B00A43942 /* RCTConvert+SideMenuOpenGestureMode.h */,
7365070F21E4B16F004E020F /* RCTConvert+UIBarButtonSystemItem.h */,
7365071021E4B16F004E020F /* RCTConvert+UIBarButtonSystemItem.m */,
5030B62823D5C9AF008F1642 /* RCTConvert+Interpolation.h */,
5095BB702416A3B900C4CD41 /* RNNConvert.h */,
5095BB712416A3B900C4CD41 /* RNNConvert.m */,
5038A3BB216E1490009280BC /* RNNTabBarItemCreator.h */,
5038A3BC216E1490009280BC /* RNNTabBarItemCreator.m */,
5022EDBF24053C9F00852BA6 /* TabBarItemAppearanceCreator.h */,
Expand Down Expand Up @@ -1671,7 +1674,6 @@
files = (
5060DE74219DAD8300D0C052 /* RNNBridgeManagerDelegate.h in Headers */,
5060DE73219DAD7E00D0C052 /* ReactNativeNavigation.h in Headers */,
261F0E6A1E6F028A00989DE2 /* RNNNavigationStackManager.h in Headers */,
5022EDBD2405237100852BA6 /* BottomTabPresenterCreator.h in Headers */,
507ACB1523F44E5200829911 /* RNNComponentRootView.h in Headers */,
5061B6C723D48449008B9827 /* VerticalRotationTransition.h in Headers */,
Expand Down Expand Up @@ -1849,7 +1851,6 @@
507F43F81FF525B500D9425B /* RNNSegmentedControl.h in Headers */,
50175CD1207A2AA1004FE91B /* RNNComponentOptions.h in Headers */,
5038A3B1216DF41B009280BC /* UIViewController+RNNOptions.h in Headers */,
505EDD4A214FDA800071C7DE /* RCTConvert+Modal.h in Headers */,
5049595A216F6B46006D2B81 /* NullDictionary.h in Headers */,
50BCB27123F1650800D6C8E5 /* SharedElementAnimator.h in Headers */,
50BCB27D23F2A1EE00D6C8E5 /* FloatTransition.h in Headers */,
Expand All @@ -1863,6 +1864,7 @@
30987680135A8C78E62D5B8E /* DotIndicatorOptions.h in Headers */,
30987CA5048A48D6CE76B06C /* DotIndicatorParser.h in Headers */,
3098730BC3B4DE41104D9CC4 /* RNNDotIndicatorPresenter.h in Headers */,
5095BB722416A3B900C4CD41 /* RNNConvert.h in Headers */,
50D3A36E23B8D6C600717F95 /* SharedElementTransitionsCreator.h in Headers */,
309877F473AECC05FB3B9362 /* UITabBarController+RNNUtils.h in Headers */,
3098702E6833E5CC16D91CE3 /* NoColor.h in Headers */,
Expand Down Expand Up @@ -2171,6 +2173,7 @@
7B4928091E70415400555040 /* RNNCommandsHandler.m in Sources */,
50887C1620ECC5C200D06111 /* RNNButtonOptions.m in Sources */,
50EA541B23AEE1C6006F881A /* AnimatedReactView.m in Sources */,
5095BB732416A3B900C4CD41 /* RNNConvert.m in Sources */,
7BC9346E1E26886E00EFA125 /* RNNControllerFactory.m in Sources */,
507F43F91FF525B500D9425B /* RNNSegmentedControl.m in Sources */,
5038A3B2216DF41B009280BC /* UIViewController+RNNOptions.m in Sources */,
Expand Down
87 changes: 30 additions & 57 deletions playground/ios/NavigationTests/RNNComponentPresenterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#import "RNNComponentViewController.h"
#import "UIViewController+LayoutProtocol.h"
#import "RNNTitleViewHelper.h"
#import "RCTConvert+Modal.h"

@interface RNNComponentPresenterTest : XCTestCase

Expand Down Expand Up @@ -58,12 +57,12 @@ - (void)testApplyOptions_backButtonVisibleDefaultTrue {
XCTAssertFalse(self.boundViewController.navigationItem.hidesBackButton);
}

//- (void)testApplyOptions_drawBehindTabBarTrueWhenVisibleFalse {
// self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
// [[(id) self.boundViewController expect] setDrawBehindTabBar:YES];
// [self.uut applyOptionsOnInit:self.options];
// [(id)self.boundViewController verify];
//}
- (void)testApplyOptions_drawBehindTabBarTrueWhenVisibleFalse {
self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
[[(id) self.boundViewController expect] setDrawBehindTabBar:YES];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
}

- (void)testApplyOptions_setOverlayTouchOutsideIfHasValue {
self.options.overlay.interceptTouchOutside = [[Bool alloc] initWithBOOL:YES];
Expand All @@ -78,63 +77,37 @@ - (void)testBindViewControllerShouldCreateNavigationButtonsCreator {
XCTAssertNotNil(presenter.navigationButtons);
}

- (void)testApplyOptionsOnInit_shouldSetModalPresentationStyleWithDefault {
[(UIViewController *) [(id) self.boundViewController expect] setModalPresentationStyle:[RCTConvert defaultModalPresentationStyle]];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
}
-(void)testApplyOptionsOnInit_TopBarDrawUnder_true {
self.options.topBar.drawBehind = [[Bool alloc] initWithValue:@(1)];

- (void)testApplyOptionsOnInit_shouldSetModalTransitionStyleWithDefault {
[(UIViewController *) [(id) self.boundViewController expect] setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
[[(id) self.boundViewController expect] setDrawBehindTopBar:YES];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
}

- (void)testApplyOptionsOnInit_shouldSetModalPresentationStyleWithValue {
self.options.modalPresentationStyle = [[Text alloc] initWithValue:@"overCurrentContext"];
[(UIViewController *) [(id) self.boundViewController expect] setModalPresentationStyle:UIModalPresentationOverCurrentContext];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
-(void)testApplyOptionsOnInit_TopBarDrawUnder_false {
self.options.topBar.drawBehind = [[Bool alloc] initWithValue:@(0)];

[[(id) self.boundViewController expect] setDrawBehindTopBar:NO];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
}

- (void)testApplyOptionsOnInit_shouldSetModalTransitionStyleWithValue {
self.options.modalTransitionStyle = [[Text alloc] initWithValue:@"crossDissolve"];
[(UIViewController *) [(id) self.boundViewController expect] setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
-(void)testApplyOptionsOnInit_BottomTabsDrawUnder_true {
self.options.bottomTabs.drawBehind = [[Bool alloc] initWithValue:@(1)];

[[(id) self.boundViewController expect] setDrawBehindTabBar:YES];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
}

//-(void)testApplyOptionsOnInit_TopBarDrawUnder_true {
// self.options.topBar.drawBehind = [[Bool alloc] initWithValue:@(1)];
//
// [[(id) self.boundViewController expect] setDrawBehindTopBar:YES];
// [self.uut applyOptionsOnInit:self.options];
// [(id)self.boundViewController verify];
//}
//
//-(void)testApplyOptionsOnInit_TopBarDrawUnder_false {
// self.options.topBar.drawBehind = [[Bool alloc] initWithValue:@(0)];
//
// [[(id) self.boundViewController expect] setDrawBehindTopBar:NO];
// [self.uut applyOptionsOnInit:self.options];
// [(id)self.boundViewController verify];
//}
//
//-(void)testApplyOptionsOnInit_BottomTabsDrawUnder_true {
// self.options.bottomTabs.drawBehind = [[Bool alloc] initWithValue:@(1)];
//
// [[(id) self.boundViewController expect] setDrawBehindTabBar:YES];
// [self.uut applyOptionsOnInit:self.options];
// [(id)self.boundViewController verify];
//}
//
//-(void)testApplyOptionsOnInit_BottomTabsDrawUnder_false {
// self.options.bottomTabs.drawBehind = [[Bool alloc] initWithValue:@(0)];
//
// [[(id) self.boundViewController expect] setDrawBehindTabBar:NO];
// [self.uut applyOptionsOnInit:self.options];
// [(id)self.boundViewController verify];
//}
-(void)testApplyOptionsOnInit_BottomTabsDrawUnder_false {
self.options.bottomTabs.drawBehind = [[Bool alloc] initWithValue:@(0)];

[[(id) self.boundViewController expect] setDrawBehindTabBar:NO];
[self.uut applyOptionsOnInit:self.options];
[(id)self.boundViewController verify];
}

- (void)testReactViewShouldBeReleasedOnDealloc {
RNNComponentViewController* bindViewController = [RNNComponentViewController new];
Expand Down
26 changes: 26 additions & 0 deletions playground/ios/NavigationTests/RNNModalManagerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,32 @@ - (void)testPresentationControllerDidDismiss_ShouldInvokeDelegateDismissedModalW
[mockDelegate verify];
}

- (void)testApplyOptionsOnInit_shouldShowModalWithDefaultPresentationStyle {
_vc1.options = [RNNNavigationOptions emptyOptions];
[_modalManager showModal:_vc1 animated:NO completion:nil];
XCTAssertEqual(_vc1.modalPresentationStyle, UIModalPresentationPageSheet);
}

- (void)testApplyOptionsOnInit_shouldShowModalWithDefaultTransitionStyle {
_vc1.options = [RNNNavigationOptions emptyOptions];
[_modalManager showModal:_vc1 animated:NO completion:nil];
XCTAssertEqual(_vc1.modalTransitionStyle, UIModalTransitionStyleCoverVertical);
}

- (void)testApplyOptionsOnInit_shouldShowModalWithPresentationStyle {
_vc1.options = [RNNNavigationOptions emptyOptions];
_vc1.options.modalPresentationStyle = [Text withValue:@"overCurrentContext"];
[_modalManager showModal:_vc1 animated:NO completion:nil];
XCTAssertEqual(_vc1.modalPresentationStyle, UIModalPresentationOverCurrentContext);
}

- (void)testApplyOptionsOnInit_shouldShowModalWithTransitionStyle {
_vc1.options = [RNNNavigationOptions emptyOptions];
_vc1.options.modalTransitionStyle = [Text withValue:@"crossDissolve"];
[_modalManager showModal:_vc1 animated:NO completion:nil];
XCTAssertEqual(_vc1.modalTransitionStyle, UIModalTransitionStyleCrossDissolve);
}

#pragma mark RNNModalManagerDelegate

- (void)dismissedMultipleModals:(NSArray *)viewControllers {
Expand Down
1 change: 0 additions & 1 deletion playground/ios/NavigationTests/RNNTabBarControllerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#import <ReactNativeNavigation/RNNComponentViewController.h>
#import "RNNStackController.h"
#import <OCMock/OCMock.h>
#import "RCTConvert+Modal.h"
#import <ReactNativeNavigation/BottomTabPresenterCreator.h>
#import "RNNBottomTabsController+Helpers.h"

Expand Down
Loading

0 comments on commit 931167e

Please sign in to comment.