|
@@ -5,7 +5,11 @@
|
5
|
5
|
#import "RNNCustomTitleView.h"
|
6
|
6
|
#import "RNNPushAnimation.h"
|
7
|
7
|
|
8
|
|
-@interface RNNRootViewController()
|
|
8
|
+@interface RNNRootViewController() {
|
|
9
|
+ UIView* _customTitleView;
|
|
10
|
+ UIView* _customTopBar;
|
|
11
|
+ UIView* _customTopBarBackground;
|
|
12
|
+}
|
9
|
13
|
@property (nonatomic, strong) NSString* componentName;
|
10
|
14
|
@property (nonatomic) BOOL _statusBarHidden;
|
11
|
15
|
@property (nonatomic) BOOL isExternalComponent;
|
|
@@ -48,10 +52,8 @@
|
48
|
52
|
|
49
|
53
|
-(void)viewWillAppear:(BOOL)animated{
|
50
|
54
|
[super viewWillAppear:animated];
|
51
|
|
- if (!self._optionsApplied) {
|
52
|
|
- [self.options applyOn:self];
|
53
|
|
- }
|
54
|
|
- self._optionsApplied = true;
|
|
55
|
+ [self.options applyOn:self];
|
|
56
|
+ [self optionsUpdated];
|
55
|
57
|
}
|
56
|
58
|
|
57
|
59
|
-(void)viewDidAppear:(BOOL)animated {
|
|
@@ -83,41 +85,47 @@
|
83
|
85
|
}
|
84
|
86
|
|
85
|
87
|
- (void)setCustomNavigationTitleView {
|
86
|
|
- if (self.options.topBar.title.component.name) {
|
87
|
|
- RCTRootView *reactView = (RCTRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.title.component];
|
88
|
|
-
|
89
|
|
- RNNCustomTitleView *titleView = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:self.options.topBar.title.component.alignment];
|
90
|
|
- reactView.backgroundColor = UIColor.clearColor;
|
91
|
|
- titleView.backgroundColor = UIColor.clearColor;
|
92
|
|
- self.navigationItem.titleView = titleView;
|
93
|
|
- } if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]]) {
|
94
|
|
- self.navigationItem.title = nil;
|
|
88
|
+ if (!_customTitleView) {
|
|
89
|
+ if (self.options.topBar.title.component.name) {
|
|
90
|
+ RCTRootView *reactView = (RCTRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.title.component];
|
|
91
|
+
|
|
92
|
+ _customTitleView = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:self.options.topBar.title.component.alignment];
|
|
93
|
+ reactView.backgroundColor = UIColor.clearColor;
|
|
94
|
+ _customTitleView.backgroundColor = UIColor.clearColor;
|
|
95
|
+ self.navigationItem.titleView = _customTitleView;
|
|
96
|
+ } if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
|
|
97
|
+ self.navigationItem.title = nil;
|
|
98
|
+ }
|
95
|
99
|
}
|
96
|
100
|
}
|
97
|
101
|
|
98
|
102
|
- (void)setCustomNavigationBarView {
|
99
|
|
- if (self.options.topBar.component.name) {
|
100
|
|
- RCTRootView *reactView = (RCTRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.component];
|
101
|
|
-
|
102
|
|
- RNNCustomTitleView *titleView = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
|
103
|
|
- reactView.backgroundColor = UIColor.clearColor;
|
104
|
|
- titleView.backgroundColor = UIColor.clearColor;
|
105
|
|
- [self.navigationController.navigationBar addSubview:titleView];
|
106
|
|
- } else if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]]) {
|
107
|
|
- [[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
|
|
103
|
+ if (!_customTopBar) {
|
|
104
|
+ if (self.options.topBar.component.name) {
|
|
105
|
+ RCTRootView *reactView = (RCTRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.component];
|
|
106
|
+
|
|
107
|
+ _customTopBar = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
|
|
108
|
+ reactView.backgroundColor = UIColor.clearColor;
|
|
109
|
+ _customTopBar.backgroundColor = UIColor.clearColor;
|
|
110
|
+ [self.navigationController.navigationBar addSubview:_customTopBar];
|
|
111
|
+ } else if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
|
|
112
|
+ [[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
|
|
113
|
+ }
|
108
|
114
|
}
|
109
|
115
|
}
|
110
|
116
|
|
111
|
117
|
- (void)setCustomNavigationComponentBackground {
|
112
|
|
- if (self.options.topBar.background.component.name) {
|
113
|
|
- RCTRootView *reactView = (RCTRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.background.component];
|
114
|
|
-
|
115
|
|
- RNNCustomTitleView *titleView = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
|
116
|
|
- [self.navigationController.navigationBar insertSubview:titleView atIndex:1];
|
117
|
|
- self.navigationController.navigationBar.clipsToBounds = YES;
|
118
|
|
- } else if ([[self.navigationController.navigationBar.subviews objectAtIndex:1] isKindOfClass:[RNNCustomTitleView class]]) {
|
119
|
|
- [[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
|
120
|
|
- self.navigationController.navigationBar.clipsToBounds = NO;
|
|
118
|
+ if (!_customTopBarBackground) {
|
|
119
|
+ if (self.options.topBar.background.component.name) {
|
|
120
|
+ RCTRootView *reactView = (RCTRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.background.component];
|
|
121
|
+
|
|
122
|
+ _customTopBarBackground = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
|
|
123
|
+ [self.navigationController.navigationBar insertSubview:_customTopBarBackground atIndex:1];
|
|
124
|
+ self.navigationController.navigationBar.clipsToBounds = YES;
|
|
125
|
+ } else if ([[self.navigationController.navigationBar.subviews objectAtIndex:1] isKindOfClass:[RNNCustomTitleView class]]) {
|
|
126
|
+ [[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
|
|
127
|
+ self.navigationController.navigationBar.clipsToBounds = NO;
|
|
128
|
+ }
|
121
|
129
|
}
|
122
|
130
|
}
|
123
|
131
|
|
|
@@ -125,10 +133,6 @@
|
125
|
133
|
return self.options.customTransition.animations != nil;
|
126
|
134
|
}
|
127
|
135
|
|
128
|
|
-- (BOOL)isAnimated {
|
129
|
|
- return self.options.animated ? [self.options.animated boolValue] : YES;
|
130
|
|
-}
|
131
|
|
-
|
132
|
136
|
- (BOOL)isCustomViewController {
|
133
|
137
|
return self.isExternalComponent;
|
134
|
138
|
}
|
|
@@ -176,9 +180,9 @@
|
176
|
180
|
{
|
177
|
181
|
if (self.animator) {
|
178
|
182
|
return self.animator;
|
179
|
|
- } else if (operation == UINavigationControllerOperationPush && self.options.animations.push) {
|
|
183
|
+ } else if (operation == UINavigationControllerOperationPush && self.options.animations.push.hasCustomAnimation) {
|
180
|
184
|
return [[RNNPushAnimation alloc] initWithScreenTransition:self.options.animations.push];
|
181
|
|
- } else if (operation == UINavigationControllerOperationPop && self.options.animations.pop) {
|
|
185
|
+ } else if (operation == UINavigationControllerOperationPop && self.options.animations.pop.hasCustomAnimation) {
|
182
|
186
|
return [[RNNPushAnimation alloc] initWithScreenTransition:self.options.animations.pop];
|
183
|
187
|
} else {
|
184
|
188
|
return nil;
|