diff --git a/lib/ios/BottomTabsPresenterCreator.h b/lib/ios/BottomTabsPresenterCreator.h index 5479d06b871..c585ad560a5 100644 --- a/lib/ios/BottomTabsPresenterCreator.h +++ b/lib/ios/BottomTabsPresenterCreator.h @@ -3,6 +3,6 @@ @interface BottomTabsPresenterCreator : NSObject -+ (RNNBottomTabsPresenter *)createWithDefaultOptions:(RNNNavigationOptions *)defaultOptions; ++ (BottomTabsBasePresenter *)createWithDefaultOptions:(RNNNavigationOptions *)defaultOptions; @end diff --git a/lib/ios/BottomTabsPresenterCreator.m b/lib/ios/BottomTabsPresenterCreator.m index 9204ebb3a96..9b2df26562c 100644 --- a/lib/ios/BottomTabsPresenterCreator.m +++ b/lib/ios/BottomTabsPresenterCreator.m @@ -3,7 +3,7 @@ @implementation BottomTabsPresenterCreator -+ (RNNBottomTabsPresenter *)createWithDefaultOptions:(RNNNavigationOptions *)defaultOptions { ++ (BottomTabsBasePresenter *)createWithDefaultOptions:(RNNNavigationOptions *)defaultOptions { if (@available(iOS 13.0, *)) { return [[BottomTabsAppearancePresenter alloc] initWithDefaultOptions:defaultOptions]; } else { diff --git a/lib/ios/ElementFrameTransition.h b/lib/ios/ElementFrameTransition.h index aaa41104121..d90d8f9e33f 100644 --- a/lib/ios/ElementFrameTransition.h +++ b/lib/ios/ElementFrameTransition.h @@ -3,8 +3,6 @@ @interface ElementFrameTransition : ElementBaseTransition -- (instancetype)initWithView:(UIView *)view from:(CGRect)from to:(CGRect)to startDelay:(NSTimeInterval)startDelay duration:(NSTimeInterval)duration interpolation:(Text *)interpolation; - @property (nonatomic) CGRect from; @property (nonatomic) CGRect to; diff --git a/lib/ios/RNNBridgeModule.m b/lib/ios/RNNBridgeModule.m index 9c939179649..b39e77a4f12 100644 --- a/lib/ios/RNNBridgeModule.m +++ b/lib/ios/RNNBridgeModule.m @@ -21,7 +21,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(setRoot:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler setRoot:layout commandId:commandId completion:^{ + [self->_commandsHandler setRoot:layout commandId:commandId completion:^{ resolve(layout); }]; }); @@ -29,7 +29,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(mergeOptions:(NSString*)componentId options:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler mergeOptions:componentId options:options completion:^{ + [self->_commandsHandler mergeOptions:componentId options:options completion:^{ resolve(componentId); }]; }); @@ -37,7 +37,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(setDefaultOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler setDefaultOptions:options completion:^{ + [self->_commandsHandler setDefaultOptions:options completion:^{ resolve(nil); }]; }); @@ -45,7 +45,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(push:(NSString*)commandId componentId:(NSString*)componentId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler push:componentId commandId:commandId layout:layout completion:^{ + [self->_commandsHandler push:componentId commandId:commandId layout:layout completion:^{ resolve(componentId); } rejection:reject]; }); @@ -53,7 +53,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(pop:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler pop:componentId commandId:commandId mergeOptions:(NSDictionary*)options completion:^{ + [self->_commandsHandler pop:componentId commandId:commandId mergeOptions:(NSDictionary*)options completion:^{ resolve(componentId); } rejection:reject]; }); @@ -61,7 +61,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(setStackRoot:(NSString*)commandId componentId:(NSString*)componentId children:(NSArray*)children resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler setStackRoot:componentId commandId:commandId children:children completion:^{ + [self->_commandsHandler setStackRoot:componentId commandId:commandId children:children completion:^{ resolve(componentId); } rejection:reject]; }); @@ -69,7 +69,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(popTo:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler popTo:componentId commandId:commandId mergeOptions:options completion:^{ + [self->_commandsHandler popTo:componentId commandId:commandId mergeOptions:options completion:^{ resolve(componentId); } rejection:reject]; }); @@ -77,7 +77,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(popToRoot:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler popToRoot:componentId commandId:commandId mergeOptions:options completion:^{ + [self->_commandsHandler popToRoot:componentId commandId:commandId mergeOptions:options completion:^{ resolve(componentId); } rejection:reject]; }); @@ -85,7 +85,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(showModal:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler showModal:layout commandId:commandId completion:^(NSString *componentId) { + [self->_commandsHandler showModal:layout commandId:commandId completion:^(NSString *componentId) { resolve(componentId); }]; }); @@ -93,7 +93,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(dismissModal:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler dismissModal:componentId commandId:commandId mergeOptions:options completion:^{ + [self->_commandsHandler dismissModal:componentId commandId:commandId mergeOptions:options completion:^{ resolve(componentId); } rejection:reject]; }); @@ -101,7 +101,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(dismissAllModals:(NSString*)commandId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler dismissAllModals:options commandId:commandId completion:^{ + [self->_commandsHandler dismissAllModals:options commandId:commandId completion:^{ resolve(nil); }]; }); @@ -109,7 +109,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(showOverlay:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler showOverlay:layout commandId:commandId completion:^{ + [self->_commandsHandler showOverlay:layout commandId:commandId completion:^{ resolve(layout[@"id"]); }]; }); @@ -117,7 +117,7 @@ -(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler { RCT_EXPORT_METHOD(dismissOverlay:(NSString*)commandId componentId:(NSString*)componentId resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCTExecuteOnMainQueue(^{ - [_commandsHandler dismissOverlay:componentId commandId:commandId completion:^{ + [self->_commandsHandler dismissOverlay:componentId commandId:commandId completion:^{ resolve(@(1)); } rejection:reject]; }); diff --git a/lib/ios/RNNCommandsHandler.m b/lib/ios/RNNCommandsHandler.m index b55b3ede3d8..ae8be5257f3 100644 --- a/lib/ios/RNNCommandsHandler.m +++ b/lib/ios/RNNCommandsHandler.m @@ -74,10 +74,10 @@ - (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion: UIViewController *vc = [_controllerFactory createLayout:layout[@"root"]]; vc.waitForRender = [vc.resolveOptionsWithDefault.animations.setRoot.waitForRender getWithDefaultValue:NO]; - + __weak UIViewController* weakVC = vc; [vc setReactViewReadyCallback:^{ - _mainWindow.rootViewController = vc; - [_eventEmitter sendOnNavigationCommandCompletion:setRoot commandId:commandId params:@{@"layout": layout}]; + self->_mainWindow.rootViewController = weakVC; + [self->_eventEmitter sendOnNavigationCommandCompletion:setRoot commandId:commandId params:@{@"layout": layout}]; completion(); }]; @@ -160,8 +160,9 @@ - (void)push:(NSString*)componentId commandId:(NSString*)commandId layout:(NSDic } } else { newVc.waitForRender = newVc.resolveOptionsWithDefault.animations.push.shouldWaitForRender; + __weak UIViewController* weakNewVC = newVc; [newVc setReactViewReadyCallback:^{ - [fromVC.stack push:newVc onTop:fromVC animated:[newVc.resolveOptionsWithDefault.animations.push.enable getWithDefaultValue:YES] completion:^{ + [fromVC.stack push:weakNewVC onTop:fromVC animated:[weakNewVC.resolveOptionsWithDefault.animations.push.enable getWithDefaultValue:YES] completion:^{ [self->_eventEmitter sendOnNavigationCommandCompletion:push commandId:commandId params:@{@"componentId": componentId}]; completion(); } rejection:rejection]; @@ -202,17 +203,17 @@ - (void)pop:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:( RNNAssertMainQueue(); RNNComponentViewController *vc = (RNNComponentViewController*)[RNNLayoutManager findComponentForId:componentId]; - if (vc) { - RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions]; - [vc overrideOptions:options]; - - [vc.stack pop:vc animated:[vc.resolveOptionsWithDefault.animations.pop.enable getWithDefaultValue:YES] completion:^{ - [self->_eventEmitter sendOnNavigationCommandCompletion:pop commandId:commandId params:@{@"componentId": componentId}]; - completion(); - } rejection:rejection]; - } else { - [RNNErrorHandler reject:rejection withErrorCode:1012 errorDescription:[NSString stringWithFormat:@"Popping component failed - componentId '%@' not found", componentId]]; - } + if (vc) { + RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions]; + [vc overrideOptions:options]; + + [vc.stack pop:vc animated:[vc.resolveOptionsWithDefault.animations.pop.enable getWithDefaultValue:YES] completion:^{ + [self->_eventEmitter sendOnNavigationCommandCompletion:pop commandId:commandId params:@{@"componentId": componentId}]; + completion(); + } rejection:rejection]; + } else { + [RNNErrorHandler reject:rejection withErrorCode:1012 errorDescription:[NSString stringWithFormat:@"Popping component failed - componentId '%@' not found", componentId]]; + } } - (void)popTo:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection { @@ -224,7 +225,7 @@ - (void)popTo:(NSString*)componentId commandId:(NSString*)commandId mergeOptions [vc overrideOptions:options]; [vc.stack popTo:vc animated:[vc.resolveOptionsWithDefault.animations.pop.enable getWithDefaultValue:YES] completion:^(NSArray *poppedViewControllers) { - [_eventEmitter sendOnNavigationCommandCompletion:popTo commandId:commandId params:@{@"componentId": componentId}]; + [self->_eventEmitter sendOnNavigationCommandCompletion:popTo commandId:commandId params:@{@"componentId": componentId}]; completion(); } rejection:rejection]; } @@ -239,7 +240,7 @@ - (void)popToRoot:(NSString*)componentId commandId:(NSString*)commandId mergeOpt [CATransaction begin]; [CATransaction setCompletionBlock:^{ - [_eventEmitter sendOnNavigationCommandCompletion:popToRoot commandId:commandId params:@{@"componentId": componentId}]; + [self->_eventEmitter sendOnNavigationCommandCompletion:popToRoot commandId:commandId params:@{@"componentId": componentId}]; completion(); }]; @@ -257,11 +258,12 @@ - (void)showModal:(NSDictionary*)layout commandId:(NSString *)commandId completi RNNAssertMainQueue(); UIViewController *newVc = [_controllerFactory createLayout:layout]; + __weak UIViewController* weakNewVC = newVc; newVc.waitForRender = [newVc.resolveOptionsWithDefault.animations.showModal.waitForRender getWithDefaultValue:NO]; [newVc setReactViewReadyCallback:^{ - [_modalManager showModal:newVc animated:[newVc.resolveOptionsWithDefault.animations.showModal.enable getWithDefaultValue:YES] completion:^(NSString *componentId) { + [self->_modalManager showModal:weakNewVC animated:[weakNewVC.resolveOptionsWithDefault.animations.showModal.enable getWithDefaultValue:YES] completion:^(NSString *componentId) { [self->_eventEmitter sendOnNavigationCommandCompletion:showModal commandId:commandId params:@{@"layout": layout}]; - completion(newVc.layoutInfo.componentId); + completion(weakNewVC.layoutInfo.componentId); }]; }]; [newVc render]; @@ -297,7 +299,7 @@ - (void)dismissAllModals:(NSDictionary *)mergeOptions commandId:(NSString*)comma [CATransaction begin]; [CATransaction setCompletionBlock:^{ - [_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals commandId:commandId params:@{}]; + [self->_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals commandId:commandId params:@{}]; completion(); }]; RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions]; @@ -311,9 +313,10 @@ - (void)showOverlay:(NSDictionary *)layout commandId:(NSString*)commandId comple RNNAssertMainQueue(); UIViewController* overlayVC = [_controllerFactory createLayout:layout]; + __weak UIViewController* weakOverlayVC = overlayVC; [overlayVC setReactViewReadyCallback:^{UIWindow* overlayWindow = [[RNNOverlayWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - overlayWindow.rootViewController = overlayVC; - if ([overlayVC.resolveOptionsWithDefault.overlay.handleKeyboardEvents getWithDefaultValue:NO]) { + overlayWindow.rootViewController = weakOverlayVC; + if ([weakOverlayVC.resolveOptionsWithDefault.overlay.handleKeyboardEvents getWithDefaultValue:NO]) { [self->_overlayManager showOverlayWindowAsKeyWindow:overlayWindow]; } else { [self->_overlayManager showOverlayWindow:overlayWindow]; diff --git a/lib/ios/RNNControllerFactory.m b/lib/ios/RNNControllerFactory.m index 5db4804781f..e6446b9cd4d 100644 --- a/lib/ios/RNNControllerFactory.m +++ b/lib/ios/RNNControllerFactory.m @@ -150,7 +150,7 @@ - (UIViewController *)createStack:(RNNLayoutNode*)node { - (UIViewController *)createBottomTabs:(RNNLayoutNode*)node { RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] initWithNode:node]; RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:node.data[@"options"]]; - RNNBottomTabsPresenter* presenter = [BottomTabsPresenterCreator createWithDefaultOptions:_defaultOptions]; + BottomTabsBasePresenter* presenter = [BottomTabsPresenterCreator createWithDefaultOptions:_defaultOptions]; NSArray *childViewControllers = [self extractChildrenViewControllersFromNode:node]; BottomTabPresenter* bottomTabPresenter = [BottomTabPresenterCreator createWithDefaultOptions:_defaultOptions]; RNNDotIndicatorPresenter* dotIndicatorPresenter = [[RNNDotIndicatorPresenter alloc] initWithDefaultOptions:_defaultOptions]; diff --git a/lib/ios/RNNModalManager.h b/lib/ios/RNNModalManager.h index 201ad63664b..6cf710d8293 100644 --- a/lib/ios/RNNModalManager.h +++ b/lib/ios/RNNModalManager.h @@ -3,25 +3,25 @@ #import typedef void (^RNNTransitionCompletionBlock)(void); -typedef void (^RNNTransitionWithComponentIdCompletionBlock)(NSString *componentId); -typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, NSError *error); +typedef void (^RNNTransitionWithComponentIdCompletionBlock)(NSString * _Nonnull componentId); +typedef void (^RNNTransitionRejectionBlock)(NSString * _Nonnull code, NSString * _Nonnull message, NSError * _Nullable error); @protocol RNNModalManagerDelegate -- (void)dismissedModal:(UIViewController *)viewController; -- (void)attemptedToDismissModal:(UIViewController *)viewController; -- (void)dismissedMultipleModals:(NSArray *)viewControllers; +- (void)dismissedModal:(UIViewController * _Nonnull)viewController; +- (void)attemptedToDismissModal:(UIViewController * _Nonnull)viewController; +- (void)dismissedMultipleModals:(NSArray * _Nonnull)viewControllers; @end @interface RNNModalManager : NSObject -- (instancetype)initWithBridge:(RCTBridge *)bridge; +- (instancetype _Nullable)initWithBridge:(RCTBridge * _Nonnull)bridge; -@property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id _Nullable delegate; -- (void)showModal:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNTransitionWithComponentIdCompletionBlock)completion; -- (void)dismissModal:(UIViewController *)viewController completion:(RNNTransitionCompletionBlock)completion; +- (void)showModal:(UIViewController * _Nonnull)viewController animated:(BOOL)animated completion:(RNNTransitionWithComponentIdCompletionBlock _Nonnull)completion; +- (void)dismissModal:(UIViewController * _Nonnull)viewController completion:(RNNTransitionCompletionBlock _Nonnull)completion; - (void)dismissAllModalsAnimated:(BOOL)animated completion:(void (^ __nullable)(void))completion; - (void)dismissAllModalsSynchronosly; diff --git a/lib/ios/RNNModalManager.m b/lib/ios/RNNModalManager.m index af84d03b98d..3476295ad87 100644 --- a/lib/ios/RNNModalManager.m +++ b/lib/ios/RNNModalManager.m @@ -106,7 +106,7 @@ - (void)removePendingNextModalIfOnTop:(RNNTransitionCompletionBlock)completion { if (modalToDismiss == topPresentedVC || [[topPresentedVC childViewControllers] containsObject:modalToDismiss]) { [modalToDismiss dismissViewControllerAnimated:[optionsWithDefault.animations.dismissModal.enable getWithDefaultValue:YES] completion:^{ - [_pendingModalIdsToDismiss removeObject:modalToDismiss]; + [self->_pendingModalIdsToDismiss removeObject:modalToDismiss]; if (modalToDismiss.view) { [self dismissedModal:modalToDismiss]; } diff --git a/lib/ios/RNNSideMenuPresenter.m b/lib/ios/RNNSideMenuPresenter.m index 86b6d7950eb..a9b400c8777 100644 --- a/lib/ios/RNNSideMenuPresenter.m +++ b/lib/ios/RNNSideMenuPresenter.m @@ -11,109 +11,110 @@ -(instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions { - (void)applyOptions:(RNNNavigationOptions *)options { [super applyOptions:options]; RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]]; - RNNSideMenuController* sideMenu = self.boundViewController; - [sideMenu side:MMDrawerSideLeft enabled:[withDefault.sideMenu.left.enabled getWithDefaultValue:YES]]; - [sideMenu side:MMDrawerSideRight enabled:[withDefault.sideMenu.right.enabled getWithDefaultValue:YES]]; + [self.sideMenuController side:MMDrawerSideLeft enabled:[withDefault.sideMenu.left.enabled getWithDefaultValue:YES]]; + [self.sideMenuController side:MMDrawerSideRight enabled:[withDefault.sideMenu.right.enabled getWithDefaultValue:YES]]; - [sideMenu setShouldStretchLeftDrawer:[withDefault.sideMenu.left.shouldStretchDrawer getWithDefaultValue:YES]]; - [sideMenu setShouldStretchRightDrawer:[withDefault.sideMenu.right.shouldStretchDrawer getWithDefaultValue:YES]]; + [self.sideMenuController setShouldStretchLeftDrawer:[withDefault.sideMenu.left.shouldStretchDrawer getWithDefaultValue:YES]]; + [self.sideMenuController setShouldStretchRightDrawer:[withDefault.sideMenu.right.shouldStretchDrawer getWithDefaultValue:YES]]; - [sideMenu setAnimationVelocityLeft:[withDefault.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]]; - [sideMenu setAnimationVelocityRight:[withDefault.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]]; + [self.sideMenuController setAnimationVelocityLeft:[withDefault.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]]; + [self.sideMenuController setAnimationVelocityRight:[withDefault.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]]; - [sideMenu setAnimationType:[withDefault.sideMenu.animationType getWithDefaultValue:nil]]; + [self.sideMenuController setAnimationType:[withDefault.sideMenu.animationType getWithDefaultValue:nil]]; if (withDefault.sideMenu.left.width.hasValue) { - [sideMenu side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get]; + [self.sideMenuController side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get]; } if (withDefault.sideMenu.right.width.hasValue) { - [sideMenu side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get]; + [self.sideMenuController side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get]; } if (withDefault.sideMenu.left.visible.hasValue) { - [sideMenu side:MMDrawerSideLeft visible:withDefault.sideMenu.left.visible.get]; + [self.sideMenuController side:MMDrawerSideLeft visible:withDefault.sideMenu.left.visible.get]; [withDefault.sideMenu.left.visible consume]; } if (withDefault.sideMenu.right.visible.hasValue) { - [sideMenu side:MMDrawerSideRight visible:withDefault.sideMenu.right.visible.get]; + [self.sideMenuController side:MMDrawerSideRight visible:withDefault.sideMenu.right.visible.get]; [withDefault.sideMenu.right.visible consume]; } - [sideMenu.view setBackgroundColor:[withDefault.layout.backgroundColor getWithDefaultValue:nil]]; + [self.sideMenuController.view setBackgroundColor:[withDefault.layout.backgroundColor getWithDefaultValue:nil]]; } - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions { [super applyOptionsOnInit:initialOptions]; RNNNavigationOptions *withDefault = [initialOptions withDefault:[self defaultOptions]]; - RNNSideMenuController* sideMenu = self.boundViewController; if (withDefault.sideMenu.left.width.hasValue) { - [sideMenu side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get]; + [self.sideMenuController side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get]; } if (withDefault.sideMenu.right.width.hasValue) { - [sideMenu side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get]; + [self.sideMenuController side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get]; } - [sideMenu setOpenDrawerGestureModeMask:[[withDefault.sideMenu.openGestureMode getWithDefaultValue:@(MMOpenDrawerGestureModeAll)] integerValue]]; + [self.sideMenuController setOpenDrawerGestureModeMask:[[withDefault.sideMenu.openGestureMode getWithDefaultValue:@(MMOpenDrawerGestureModeAll)] integerValue]]; } - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions { [super mergeOptions:options resolvedOptions:currentOptions]; - RNNSideMenuController* sideMenu = self.boundViewController; if (options.sideMenu.left.enabled.hasValue) { - [sideMenu side:MMDrawerSideLeft enabled:options.sideMenu.left.enabled.get]; + [self.sideMenuController side:MMDrawerSideLeft enabled:options.sideMenu.left.enabled.get]; } if (options.sideMenu.right.enabled.hasValue) { - [sideMenu side:MMDrawerSideRight enabled:options.sideMenu.right.enabled.get]; + [self.sideMenuController side:MMDrawerSideRight enabled:options.sideMenu.right.enabled.get]; } if (options.sideMenu.left.visible.hasValue) { - [sideMenu side:MMDrawerSideLeft visible:options.sideMenu.left.visible.get]; + [self.sideMenuController side:MMDrawerSideLeft visible:options.sideMenu.left.visible.get]; [options.sideMenu.left.visible consume]; } if (options.sideMenu.right.visible.hasValue) { - [sideMenu side:MMDrawerSideRight visible:options.sideMenu.right.visible.get]; + [self.sideMenuController side:MMDrawerSideRight visible:options.sideMenu.right.visible.get]; [options.sideMenu.right.visible consume]; } if (options.sideMenu.left.width.hasValue) { - [sideMenu side:MMDrawerSideLeft width:options.sideMenu.left.width.get]; + [self.sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get]; } if (options.sideMenu.right.width.hasValue) { - [sideMenu side:MMDrawerSideRight width:options.sideMenu.right.width.get]; + [self.sideMenuController side:MMDrawerSideRight width:options.sideMenu.right.width.get]; } if (options.sideMenu.left.shouldStretchDrawer.hasValue) { - sideMenu.shouldStretchLeftDrawer = options.sideMenu.left.shouldStretchDrawer.get; + self.sideMenuController.shouldStretchLeftDrawer = options.sideMenu.left.shouldStretchDrawer.get; } if (options.sideMenu.right.shouldStretchDrawer.hasValue) { - sideMenu.shouldStretchRightDrawer = options.sideMenu.right.shouldStretchDrawer.get; + self.sideMenuController.shouldStretchRightDrawer = options.sideMenu.right.shouldStretchDrawer.get; } if (options.sideMenu.left.animationVelocity.hasValue) { - sideMenu.animationVelocityLeft = options.sideMenu.left.animationVelocity.get; + self.sideMenuController.animationVelocityLeft = options.sideMenu.left.animationVelocity.get; } if (options.sideMenu.right.animationVelocity.hasValue) { - sideMenu.animationVelocityRight = options.sideMenu.right.animationVelocity.get; + self.sideMenuController.animationVelocityRight = options.sideMenu.right.animationVelocity.get; } if (options.sideMenu.animationType.hasValue) { - [sideMenu setAnimationType:options.sideMenu.animationType.get]; + [self.sideMenuController setAnimationType:options.sideMenu.animationType.get]; } if (options.layout.backgroundColor.hasValue) { - [sideMenu.view setBackgroundColor:options.layout.backgroundColor.get]; + [self.sideMenuController.view setBackgroundColor:options.layout.backgroundColor.get]; } } +- (RNNSideMenuController *)sideMenuController { + return (RNNSideMenuController *)self.boundViewController; +} + @end diff --git a/lib/ios/RNNSplitViewControllerPresenter.m b/lib/ios/RNNSplitViewControllerPresenter.m index 01b5a662e4d..b9ee9859f04 100644 --- a/lib/ios/RNNSplitViewControllerPresenter.m +++ b/lib/ios/RNNSplitViewControllerPresenter.m @@ -12,41 +12,41 @@ -(instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions { - (void)applyOptions:(RNNNavigationOptions *)options { [super applyOptions:options]; - UISplitViewController* splitViewController = self.boundViewController; - [splitViewController rnn_setDisplayMode:options.splitView.displayMode]; - [splitViewController rnn_setPrimaryEdge:options.splitView.primaryEdge]; - [splitViewController rnn_setMinWidth:options.splitView.minWidth]; - [splitViewController rnn_setMaxWidth:options.splitView.maxWidth]; + [self.splitViewController rnn_setDisplayMode:options.splitView.displayMode]; + [self.splitViewController rnn_setPrimaryEdge:options.splitView.primaryEdge]; + [self.splitViewController rnn_setMinWidth:options.splitView.minWidth]; + [self.splitViewController rnn_setMaxWidth:options.splitView.maxWidth]; } - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions { [super applyOptionsOnInit:initialOptions]; - UISplitViewController* splitViewController = self.boundViewController; - [splitViewController rnn_setDisplayMode:initialOptions.splitView.displayMode]; - [splitViewController rnn_setPrimaryEdge:initialOptions.splitView.primaryEdge]; - [splitViewController rnn_setMinWidth:initialOptions.splitView.minWidth]; - [splitViewController rnn_setMaxWidth:initialOptions.splitView.maxWidth]; + [self.splitViewController rnn_setDisplayMode:initialOptions.splitView.displayMode]; + [self.splitViewController rnn_setPrimaryEdge:initialOptions.splitView.primaryEdge]; + [self.splitViewController rnn_setMinWidth:initialOptions.splitView.minWidth]; + [self.splitViewController rnn_setMaxWidth:initialOptions.splitView.maxWidth]; } - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions { [super mergeOptions:options resolvedOptions:currentOptions]; - - UISplitViewController* splitViewController = self.boundViewController; if (options.splitView.displayMode) { - [splitViewController rnn_setDisplayMode:options.splitView.displayMode]; + [self.splitViewController rnn_setDisplayMode:options.splitView.displayMode]; } if (options.splitView.primaryEdge) { - [splitViewController rnn_setPrimaryEdge:options.splitView.primaryEdge]; + [self.splitViewController rnn_setPrimaryEdge:options.splitView.primaryEdge]; } if (options.splitView.minWidth) { - [splitViewController rnn_setMinWidth:options.splitView.minWidth]; + [self.splitViewController rnn_setMinWidth:options.splitView.minWidth]; } if (options.splitView.maxWidth) { - [splitViewController rnn_setMaxWidth:options.splitView.maxWidth]; + [self.splitViewController rnn_setMaxWidth:options.splitView.maxWidth]; } } +- (UISplitViewController *)splitViewController { + return self.boundViewController; +} + @end diff --git a/lib/ios/RNNStackPresenter.m b/lib/ios/RNNStackPresenter.m index 178316a5cca..b6d424049d7 100644 --- a/lib/ios/RNNStackPresenter.m +++ b/lib/ios/RNNStackPresenter.m @@ -76,8 +76,6 @@ - (void)applyOptionsOnViewDidLayoutSubviews:(RNNNavigationOptions *)options { } - (void)applyOptionsBeforePopping:(RNNNavigationOptions *)options { - RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]]; - RNNStackController* navigationController = self.stackController; [_topBarPresenter applyOptionsBeforePopping:options.topBar]; }