-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Model splitView after the other presenter options (#4647)
Seems like RNNSplitViewOptions wasn't updated to use the presenters, so the options were going nowhere.
- Loading branch information
Showing
11 changed files
with
145 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
#import "RNNLayoutNode.h" | ||
#import "RNNRootViewCreator.h" | ||
#import "RNNEventEmitter.h" | ||
#import "RNNNavigationOptions.h" | ||
#import "RNNSplitViewOptions.h" | ||
#import "RNNAnimator.h" | ||
#import "RNNTopTabsViewController.h" | ||
#import "RNNParentProtocol.h" | ||
#import "RNNSplitViewControllerPresenter.h" | ||
#import "UISplitViewController+RNNOptions.h" | ||
|
||
@interface RNNSplitViewController : UISplitViewController <RNNParentProtocol> | ||
|
||
@property (nonatomic, strong) RNNNavigationOptions* options; | ||
@property (nonatomic, strong) RNNNavigationOptions* defaultOptions; | ||
@property (nonatomic, retain) RNNLayoutInfo* layoutInfo; | ||
@property (nonatomic, retain) RNNViewControllerPresenter* presenter; | ||
@property (nonatomic, retain) RNNSplitViewControllerPresenter* presenter; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#import "RNNViewControllerPresenter.h" | ||
|
||
@interface RNNSplitViewControllerPresenter : RNNViewControllerPresenter | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#import "RNNSplitViewControllerPresenter.h" | ||
#import "UISplitViewController+RNNOptions.h" | ||
#import "RCTConvert+Modal.h" | ||
#import "RNNSplitViewController.h" | ||
|
||
@implementation RNNSplitViewControllerPresenter | ||
|
||
- (void)bindViewController:(UISplitViewController *)bindedViewController viewCreator:(id<RNNRootViewCreator>)creator { | ||
self.bindedViewController = bindedViewController; | ||
} | ||
|
||
- (void)applyOptions:(RNNNavigationOptions *)options { | ||
[super applyOptions:options]; | ||
|
||
UISplitViewController* splitViewController = self.bindedViewController; | ||
[splitViewController rnn_setDisplayMode:options.splitView.displayMode]; | ||
[splitViewController rnn_setPrimaryEdge:options.splitView.primaryEdge]; | ||
[splitViewController rnn_setMinWidth:options.splitView.minWidth]; | ||
[splitViewController rnn_setMaxWidth:options.splitView.maxWidth]; | ||
} | ||
|
||
|
||
- (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions { | ||
[super applyOptionsOnInit:initialOptions]; | ||
|
||
UISplitViewController* splitViewController = self.bindedViewController; | ||
[splitViewController rnn_setDisplayMode:initialOptions.splitView.displayMode]; | ||
[splitViewController rnn_setPrimaryEdge:initialOptions.splitView.primaryEdge]; | ||
[splitViewController rnn_setMinWidth:initialOptions.splitView.minWidth]; | ||
[splitViewController rnn_setMaxWidth:initialOptions.splitView.maxWidth]; | ||
} | ||
|
||
- (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions { | ||
[super mergeOptions:newOptions currentOptions:currentOptions defaultOptions:defaultOptions]; | ||
|
||
UISplitViewController* splitViewController = self.bindedViewController; | ||
|
||
if (newOptions.splitView.displayMode) { | ||
[splitViewController rnn_setDisplayMode:newOptions.splitView.displayMode]; | ||
} | ||
if (newOptions.splitView.primaryEdge) { | ||
[splitViewController rnn_setPrimaryEdge:newOptions.splitView.primaryEdge]; | ||
} | ||
if (newOptions.splitView.minWidth) { | ||
[splitViewController rnn_setMinWidth:newOptions.splitView.minWidth]; | ||
} | ||
if (newOptions.splitView.maxWidth) { | ||
[splitViewController rnn_setMaxWidth:newOptions.splitView.maxWidth]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import <UIKit/UIKit.h> | ||
#import "Number.h" | ||
|
||
@interface UISplitViewController (RNNOptions) | ||
|
||
- (void)rnn_setDisplayMode:(NSString *)displayMode; | ||
|
||
- (void)rnn_setPrimaryEdge:(NSString *)primaryEdge; | ||
|
||
- (void)rnn_setMinWidth:(Number *)minWidth; | ||
|
||
- (void)rnn_setMaxWidth:(Number *)maxWidth; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#import "UISplitViewController+RNNOptions.h" | ||
#import "RNNSplitViewController.h" | ||
|
||
@implementation UISplitViewController (RNNOptions) | ||
|
||
- (void)rnn_setDisplayMode:(NSString *)displayMode { | ||
if ([displayMode isEqualToString:@"visible"]) { | ||
self.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible; | ||
} else if ([displayMode isEqualToString:@"hidden"]) { | ||
self.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden; | ||
} else if ([displayMode isEqualToString:@"overlay"]) { | ||
self.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryOverlay; | ||
} else { | ||
self.preferredDisplayMode = UISplitViewControllerDisplayModeAutomatic; | ||
} | ||
} | ||
|
||
- (void)rnn_setPrimaryEdge:(NSString *)primaryEdge { | ||
if (@available(iOS 11.0, *)) { | ||
if ([primaryEdge isEqualToString:@"trailing"]) { | ||
self.primaryEdge = UISplitViewControllerPrimaryEdgeTrailing; | ||
} else { | ||
self.primaryEdge = UISplitViewControllerPrimaryEdgeLeading; | ||
} | ||
} | ||
} | ||
|
||
- (void)rnn_setMinWidth:(Number *)minWidth { | ||
if (minWidth.hasValue) { | ||
[self setMinimumPrimaryColumnWidth:[[minWidth get] doubleValue]]; | ||
} | ||
} | ||
|
||
- (void)rnn_setMaxWidth:(Number *)maxWidth { | ||
if (maxWidth.hasValue) { | ||
[self setMaximumPrimaryColumnWidth:[[maxWidth get] doubleValue]]; | ||
} | ||
} | ||
|
||
@end | ||
|