Browse Source

Fix topBar title alignment on iOS (#5602)

Fix topBar title alignment
Yogev Ben David 5 years ago
parent
commit
094b9a7ef1
3 changed files with 8 additions and 18 deletions
  1. 5
    16
      lib/ios/RNNComponentPresenter.m
  2. 1
    1
      lib/ios/RNNStackPresenter.m
  3. 2
    1
      lib/ios/RNNTitleViewHelper.m

+ 5
- 16
lib/ios/RNNComponentPresenter.m View File

46
 	[viewController setStatusBarStyle:[withDefault.statusBar.style getWithDefaultValue:@"default"] animated:[withDefault.statusBar.animate getWithDefaultValue:YES]];
46
 	[viewController setStatusBarStyle:[withDefault.statusBar.style getWithDefaultValue:@"default"] animated:[withDefault.statusBar.animate getWithDefaultValue:YES]];
47
 	[viewController setBackButtonVisible:[withDefault.topBar.backButton.visible getWithDefaultValue:YES]];
47
 	[viewController setBackButtonVisible:[withDefault.topBar.backButton.visible getWithDefaultValue:YES]];
48
 	[viewController setInterceptTouchOutside:[withDefault.overlay.interceptTouchOutside getWithDefaultValue:YES]];
48
 	[viewController setInterceptTouchOutside:[withDefault.overlay.interceptTouchOutside getWithDefaultValue:YES]];
49
-	
49
+
50
 	if (withDefault.layout.backgroundColor.hasValue) {
50
 	if (withDefault.layout.backgroundColor.hasValue) {
51
 		[viewController setBackgroundColor:withDefault.layout.backgroundColor.get];
51
 		[viewController setBackgroundColor:withDefault.layout.backgroundColor.get];
52
 	}
52
 	}
53
-	
53
+
54
 	if (withDefault.topBar.searchBar.hasValue) {
54
 	if (withDefault.topBar.searchBar.hasValue) {
55
 		BOOL hideNavBarOnFocusSearchBar = YES;
55
 		BOOL hideNavBarOnFocusSearchBar = YES;
56
 		if (withDefault.topBar.hideNavBarOnFocusSearchBar.hasValue) {
56
 		if (withDefault.topBar.hideNavBarOnFocusSearchBar.hasValue) {
58
 		}
58
 		}
59
 		[viewController setSearchBarWithPlaceholder:[withDefault.topBar.searchBarPlaceholder getWithDefaultValue:@""] hideNavBarOnFocusSearchBar:hideNavBarOnFocusSearchBar];
59
 		[viewController setSearchBarWithPlaceholder:[withDefault.topBar.searchBarPlaceholder getWithDefaultValue:@""] hideNavBarOnFocusSearchBar:hideNavBarOnFocusSearchBar];
60
 	}
60
 	}
61
-	
61
+
62
 	[self setTitleViewWithSubtitle:withDefault];
62
 	[self setTitleViewWithSubtitle:withDefault];
63
 }
63
 }
64
 
64
 
153
 		rootView.passThroughTouches = !options.overlay.interceptTouchOutside.get;
153
 		rootView.passThroughTouches = !options.overlay.interceptTouchOutside.get;
154
 	}
154
 	}
155
 
155
 
156
-	[self setTitleViewWithSubtitle:withDefault];
157
-
158
 	if (options.topBar.title.component.name.hasValue) {
156
 	if (options.topBar.title.component.name.hasValue) {
159
 		[self setCustomNavigationTitleView:options perform:nil];
157
 		[self setCustomNavigationTitleView:options perform:nil];
160
 	} else {
158
 	} else {
162
 		_customTitleView = nil;
160
 		_customTitleView = nil;
163
 	}
161
 	}
164
 
162
 
163
+	[self setTitleViewWithSubtitle:withDefault];
164
+	
165
 	if (options.topBar.backButton.hasValue) {
165
 	if (options.topBar.backButton.hasValue) {
166
 		UIViewController *lastViewControllerInStack = viewController.navigationController.viewControllers.count > 1 ? viewController.navigationController.viewControllers[viewController.navigationController.viewControllers.count - 2] : viewController.navigationController.topViewController;
166
 		UIViewController *lastViewControllerInStack = viewController.navigationController.viewControllers.count > 1 ? viewController.navigationController.viewControllers[viewController.navigationController.viewControllers.count - 2] : viewController.navigationController.topViewController;
167
 	    RNNNavigationOptions * resolvedOptions	= (RNNNavigationOptions *) [[currentOptions overrideOptions:options] withDefault:[self defaultOptions]];
167
 	    RNNNavigationOptions * resolvedOptions	= (RNNNavigationOptions *) [[currentOptions overrideOptions:options] withDefault:[self defaultOptions]];
208
 			[_titleViewHelper setSubtitleOptions:options.topBar.subtitle];
208
 			[_titleViewHelper setSubtitleOptions:options.topBar.subtitle];
209
 		}
209
 		}
210
 
210
 
211
-		[_titleViewHelper setup];
212
-	} else {
213
-		_titleViewHelper = [[RNNTitleViewHelper alloc] initWithTitleViewOptions:options.topBar.title subTitleOptions:options.topBar.subtitle viewController:self.boundViewController];
214
-		
215
-		if (options.topBar.title.text.hasValue) {
216
-			[_titleViewHelper setTitleOptions:options.topBar.title];
217
-		}
218
-		if (options.topBar.subtitle.text.hasValue) {
219
-			[_titleViewHelper setSubtitleOptions:options.topBar.subtitle];
220
-		}
221
-		
222
 		[_titleViewHelper setup];
211
 		[_titleViewHelper setup];
223
 	}
212
 	}
224
 }
213
 }

+ 1
- 1
lib/ios/RNNStackPresenter.m View File

57
 	RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
57
 	RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
58
 	RNNStackController* navigationController = self.boundViewController;
58
 	RNNStackController* navigationController = self.boundViewController;
59
 	[navigationController setTopBarBackgroundColor:[withDefault.topBar.background.color getWithDefaultValue:nil]];
59
 	[navigationController setTopBarBackgroundColor:[withDefault.topBar.background.color getWithDefaultValue:nil]];
60
-	[navigationController setNavigationBarFontFamily:[withDefault.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[withDefault.topBar.title.fontSize getWithDefaultValue:nil] fontWeight:[withDefault.topBar.title.fontWeight getWithDefaultValue:nil] color:[withDefault.topBar.title.color getWithDefaultValue:[UIColor blackColor]]];
60
+	[navigationController setNavigationBarFontFamily:[withDefault.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[withDefault.topBar.title.fontSize getWithDefaultValue:nil] fontWeight:[withDefault.topBar.title.fontWeight getWithDefaultValue:nil] color:[withDefault.topBar.title.color getWithDefaultValue:nil]];
61
 	[navigationController setNavigationBarLargeTitleVisible:[withDefault.topBar.largeTitle.visible getWithDefaultValue:NO]];
61
 	[navigationController setNavigationBarLargeTitleVisible:[withDefault.topBar.largeTitle.visible getWithDefaultValue:NO]];
62
 }
62
 }
63
 
63
 

+ 2
- 1
lib/ios/RNNTitleViewHelper.m View File

143
 	CGRect labelframe = titleLabel.frame;
143
 	CGRect labelframe = titleLabel.frame;
144
 	labelframe.size = labelSize;
144
 	labelframe.size = labelSize;
145
 	titleLabel.frame = labelframe;
145
 	titleLabel.frame = labelframe;
146
+	[titleLabel sizeToFit];
146
 	
147
 	
147
 	if (!self.subtitle) {
148
 	if (!self.subtitle) {
148
 		titleLabel.center = self.titleView.center;
149
 		titleLabel.center = self.titleView.center;
153
 		titleLabel.textColor = color;
154
 		titleLabel.textColor = color;
154
 	}
155
 	}
155
 	
156
 	
156
-	[titleLabel sizeToFit];
157
+	
157
 	[self.titleView addSubview:titleLabel];
158
 	[self.titleView addSubview:titleLabel];
158
 	
159
 	
159
 	return titleLabel;
160
 	return titleLabel;