diff --git a/docs/docs/layout-types.md b/docs/docs/layout-types.md index 0591102d28f..406fac744ad 100644 --- a/docs/docs/layout-types.md +++ b/docs/docs/layout-types.md @@ -200,10 +200,12 @@ const splitView = { // All layout types accepted supported by device, eg. `stack` }, options: { - displayMode: 'auto', // Master view display mode: `auto`, `visible`, `hidden` and `overlay` - primaryEdge: 'leading', // Master view side: `leading` or `trailing` - minWidth: 150, // Minimum width of master view - maxWidth: 300, // Maximum width of master view + splitView: { + displayMode: 'auto', // Master view display mode: `auto`, `visible`, `hidden` and `overlay` + primaryEdge: 'leading', // Master view side: `leading` or `trailing` + minWidth: 150, // Minimum width of master view + maxWidth: 300, // Maximum width of master view + }, }, } ``` diff --git a/lib/ios/RNNNavigationOptions.h b/lib/ios/RNNNavigationOptions.h index b02043835c8..c7e371460aa 100644 --- a/lib/ios/RNNNavigationOptions.h +++ b/lib/ios/RNNNavigationOptions.h @@ -10,6 +10,7 @@ #import "RNNStatusBarOptions.h" #import "RNNPreviewOptions.h" #import "RNNLayoutOptions.h" +#import "RNNSplitViewOptions.h" extern const NSInteger BLUR_TOPBAR_TAG; extern const NSInteger TOP_BAR_TRANSPARENT_TAG; @@ -28,6 +29,7 @@ extern const NSInteger TOP_BAR_TRANSPARENT_TAG; @property (nonatomic, strong) RNNStatusBarOptions* statusBar; @property (nonatomic, strong) RNNPreviewOptions* preview; @property (nonatomic, strong) RNNLayoutOptions* layout; +@property (nonatomic, strong) RNNSplitViewOptions* splitView; @property (nonatomic, strong) Bool* popGesture; @property (nonatomic, strong) Image* backgroundImage; diff --git a/lib/ios/RNNNavigationOptions.m b/lib/ios/RNNNavigationOptions.m index a75cf590e98..e8c77516da6 100644 --- a/lib/ios/RNNNavigationOptions.m +++ b/lib/ios/RNNNavigationOptions.m @@ -7,6 +7,7 @@ #import "RNNRootViewController.h" #import "RNNSplitViewController.h" #import "RNNNavigationButtons.h" +#import "RNNSplitViewOptions.h" #import "UIViewController+RNNOptions.h" #import "UINavigationController+RNNOptions.h" @@ -21,6 +22,7 @@ - (instancetype)initWithDict:(NSDictionary *)dict { self.topTabs = [[RNNTopTabsOptions alloc] initWithDict:dict[@"topTabs"]]; self.topTab = [[RNNTopTabOptions alloc] initWithDict:dict[@"topTab"]]; self.sideMenu = [[RNNSideMenuOptions alloc] initWithDict:dict[@"sideMenu"]]; + self.splitView = [[RNNSplitViewOptions alloc] initWithDict:dict[@"splitView"]]; self.overlay = [[RNNOverlayOptions alloc] initWithDict:dict[@"overlay"]]; self.customTransition = [[RNNAnimationOptions alloc] initWithDict:dict[@"customTransition"]]; self.animations = [[RNNTransitionsOptions alloc] initWithDict:dict[@"animations"]]; diff --git a/lib/ios/RNNSplitViewController.m b/lib/ios/RNNSplitViewController.m index 05edec699d7..034b9f18884 100644 --- a/lib/ios/RNNSplitViewController.m +++ b/lib/ios/RNNSplitViewController.m @@ -19,6 +19,12 @@ - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControll return self; } +- (void)willMoveToParentViewController:(UIViewController *)parent { + if (parent) { + [_presenter applyOptionsOnWillMoveToParentViewController:self.resolveOptions]; + } +} + - (void)onChildWillAppear { [_presenter applyOptions:self.resolveOptions]; [((UIViewController *)self.parentViewController) onChildWillAppear]; diff --git a/lib/ios/RNNSplitViewOptions.m b/lib/ios/RNNSplitViewOptions.m index 04ba8da85cd..acd2999bcd1 100644 --- a/lib/ios/RNNSplitViewOptions.m +++ b/lib/ios/RNNSplitViewOptions.m @@ -3,6 +3,19 @@ @implementation RNNSplitViewOptions +- (instancetype)initWithDict:(NSDictionary *)dict { + self = [super init]; + + self.displayMode = dict[@"displayMode"]; + self.primaryEdge = dict[@"primaryEdge"]; + NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; + f.numberStyle = NSNumberFormatterDecimalStyle; + self.minWidth = [f numberFromString:dict[@"minWidth"]]; + self.maxWidth = [f numberFromString:dict[@"maxWidth"]]; + + return self; +} + -(void)applyOn:(UIViewController *)viewController { UISplitViewController *svc = (UISplitViewController*) viewController; diff --git a/lib/src/commands/LayoutTreeParser.test.ts b/lib/src/commands/LayoutTreeParser.test.ts index cfa742ab150..9aa34440791 100644 --- a/lib/src/commands/LayoutTreeParser.test.ts +++ b/lib/src/commands/LayoutTreeParser.test.ts @@ -1,8 +1,8 @@ import * as _ from 'lodash'; import { LayoutTreeParser } from './LayoutTreeParser'; import { LayoutType } from './LayoutType'; +import { Options } from '../interfaces/Options'; import { Layout } from '../interfaces/Layout'; -import { OptionsSplitView } from '../interfaces/Options'; import { UniqueIdProvider } from '../adapters/UniqueIdProvider'; import { mock, instance, when, anything } from 'ts-mockito'; @@ -185,7 +185,7 @@ const passProps = { fnProp: () => 'Hello from a function' }; -const options = { +const options: Options = { topBar: { title: { text: 'Hello1' @@ -193,11 +193,18 @@ const options = { } }; -const optionsSplitView: OptionsSplitView = { - displayMode: 'auto', - primaryEdge: 'leading', - minWidth: 150, - maxWidth: 300 +const optionsSplitView: Options = { + topBar: { + title: { + text: 'Hello1', + } + }, + splitView: { + displayMode: 'auto', + primaryEdge: 'leading', + minWidth: 150, + maxWidth: 300 + } }; const singleComponent = { diff --git a/lib/src/interfaces/Layout.ts b/lib/src/interfaces/Layout.ts index fee00e6d70c..a3e345ae4f3 100644 --- a/lib/src/interfaces/Layout.ts +++ b/lib/src/interfaces/Layout.ts @@ -1,4 +1,4 @@ -import { Options, OptionsSplitView } from './Options'; +import { Options } from './Options'; export interface LayoutComponent

{ /** @@ -110,7 +110,7 @@ export interface LayoutSplitView { /** * Configure split view */ - options?: OptionsSplitView; + options?: Options; } export interface TopTabs { diff --git a/lib/src/interfaces/Options.ts b/lib/src/interfaces/Options.ts index df9dba6a27e..e55bb7d4021 100644 --- a/lib/src/interfaces/Options.ts +++ b/lib/src/interfaces/Options.ts @@ -820,6 +820,10 @@ export interface Options { * Configure the side menu */ sideMenu?: OptionsSideMenu; + /** + * Configure the splitView controller + */ + splitView?: OptionsSplitView; /** * Configure the overlay */