123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #import "RNNBasePresenter.h"
- #import "UIViewController+RNNOptions.h"
- #import "RNNTabBarItemCreator.h"
- #import "RNNReactComponentRegistry.h"
- #import "UIViewController+LayoutProtocol.h"
- #import "DotIndicatorOptions.h"
-
- @implementation RNNBasePresenter
-
- - (instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions {
- self = [super init];
- _defaultOptions = defaultOptions;
- return self;
- }
-
- - (instancetype)initWithComponentRegistry:(RNNReactComponentRegistry *)componentRegistry defaultOptions:(RNNNavigationOptions *)defaultOptions {
- self = [self initWithDefaultOptions:defaultOptions];
- _componentRegistry = componentRegistry;
- return self;
- }
-
- - (void)bindViewController:(UIViewController *)boundViewController {
- self.boundComponentId = boundViewController.layoutInfo.componentId;
- _boundViewController = boundViewController;
- }
-
- - (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions {
- _defaultOptions = defaultOptions;
- }
-
- - (void)componentDidAppear {
-
- }
-
- - (void)componentDidDisappear {
-
- }
-
- - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
- UIViewController* viewController = self.boundViewController;
- RNNNavigationOptions *withDefault = [initialOptions withDefault:[self defaultOptions]];
-
- if (@available(iOS 13.0, *)) {
- viewController.modalInPresentation = ![withDefault.modal.swipeToDismiss getWithDefaultValue:YES];
- }
-
- UIApplication.sharedApplication.delegate.window.backgroundColor = [withDefault.window.backgroundColor getWithDefaultValue:nil];
- }
-
- - (void)applyOptionsOnViewDidLayoutSubviews:(RNNNavigationOptions *)options {
-
- }
-
- - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
-
- }
-
- - (void)applyOptions:(RNNNavigationOptions *)options {
-
- }
-
- - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
- RNNNavigationOptions* withDefault = (RNNNavigationOptions *) [[resolvedOptions withDefault:_defaultOptions] overrideOptions:options];
-
- if (options.window.backgroundColor.hasValue) {
- UIApplication.sharedApplication.delegate.window.backgroundColor = withDefault.window.backgroundColor.get;
- }
- }
-
- - (void)renderComponents:(RNNNavigationOptions *)options perform:(RNNReactViewReadyCompletionBlock)readyBlock {
- if (readyBlock) {
- readyBlock();
- readyBlock = nil;
- }
- }
-
- - (void)viewDidLayoutSubviews {
-
- }
-
- - (UIStatusBarStyle)getStatusBarStyle:(RNNNavigationOptions *)resolvedOptions {
- RNNNavigationOptions *withDefault = [resolvedOptions withDefault:[self defaultOptions]];
- NSString* statusBarStyle = [withDefault.statusBar.style getWithDefaultValue:@"default"];
- if ([statusBarStyle isEqualToString:@"light"]) {
- return UIStatusBarStyleLightContent;
- } else if (@available(iOS 13.0, *)) {
- if ([statusBarStyle isEqualToString:@"dark"]) {
- return UIStatusBarStyleDarkContent;
- } else {
- return UIStatusBarStyleDefault;
- }
- } else {
- return UIStatusBarStyleDefault;
- }
- }
-
- - (UINavigationItem *)currentNavigationItem {
- return self.boundViewController.getCurrentChild.navigationItem;
- }
-
- - (UIInterfaceOrientationMask)getOrientation:(RNNNavigationOptions *)options {
- return [options withDefault:[self defaultOptions]].layout.supportedOrientations;
- }
-
- - (BOOL)statusBarVisibile:(UINavigationController *)stack resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
- RNNNavigationOptions *withDefault = [resolvedOptions withDefault:self.defaultOptions];
- if (withDefault.statusBar.visible.hasValue) {
- return ![withDefault.statusBar.visible get];
- } else if ([withDefault.statusBar.hideWithTopBar getWithDefaultValue:NO]) {
- return stack.isNavigationBarHidden;
- }
- return NO;
- }
-
-
- @end
|