Ver código fonte

fixes react component as titleView

yogevbd 6 anos atrás
pai
commit
28322c71ce
2 arquivos alterados com 8 adições e 4 exclusões
  1. 2
    2
      lib/ios/RNNReactRootView.m
  2. 6
    2
      lib/ios/RNNRootViewController.m

+ 2
- 2
lib/ios/RNNReactRootView.m Ver arquivo

15
 
15
 
16
 - (void)setAlignment:(NSString *)alignment {
16
 - (void)setAlignment:(NSString *)alignment {
17
 	if ([alignment isEqualToString:@"fill"]) {
17
 	if ([alignment isEqualToString:@"fill"]) {
18
-		self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
19
-	} else {
20
 		self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
18
 		self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
19
+	} else {
20
+		self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
21
 	}
21
 	}
22
 }
22
 }
23
 
23
 

+ 6
- 2
lib/ios/RNNRootViewController.m Ver arquivo

139
 	if (!_customTitleView) {
139
 	if (!_customTitleView) {
140
 		if (self.options.topBar.title.component.name) {
140
 		if (self.options.topBar.title.component.name) {
141
 			_customTitleView = (RNNReactRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.title.component];
141
 			_customTitleView = (RNNReactRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.title.component];
142
-			_customTitleView.backgroundColor = UIColor.clearColor;
142
+			_customTitleView.backgroundColor = UIColor.redColor;
143
 			[_customTitleView setAlignment:self.options.topBar.title.component.alignment];
143
 			[_customTitleView setAlignment:self.options.topBar.title.component.alignment];
144
 			BOOL isCenter = [self.options.topBar.title.component.alignment isEqualToString:@"center"];
144
 			BOOL isCenter = [self.options.topBar.title.component.alignment isEqualToString:@"center"];
145
 			__weak RNNReactRootView *weakTitleView = _customTitleView;
145
 			__weak RNNReactRootView *weakTitleView = _customTitleView;
146
+			CGRect frame = self.navigationController.navigationBar.frame;
147
+			[_customTitleView setFrame:frame];
146
 			[_customTitleView setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicContentSize) {
148
 			[_customTitleView setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicContentSize) {
147
 				if (isCenter) {
149
 				if (isCenter) {
148
 					[weakTitleView setFrame:CGRectMake(0, 0, intrinsicContentSize.width, intrinsicContentSize.height)];
150
 					[weakTitleView setFrame:CGRectMake(0, 0, intrinsicContentSize.width, intrinsicContentSize.height)];
151
+				} else {
152
+					[weakTitleView setFrame:frame];
149
 				}
153
 				}
150
 			}];
154
 			}];
151
-			[_customTitleView setFrame:self.navigationController.navigationBar.frame];
155
+			
152
 			self.navigationItem.titleView = _customTitleView;
156
 			self.navigationItem.titleView = _customTitleView;
153
 		}
157
 		}
154
 	} else if (_customTitleView && _customTitleView.superview == nil) {
158
 	} else if (_customTitleView && _customTitleView.superview == nil) {