瀏覽代碼

background options refactor

yogevbd 6 年之前
父節點
當前提交
284582b971

+ 8
- 0
lib/ios/RNNBackgrounOptions.h 查看文件

@@ -0,0 +1,8 @@
1
+#import "RNNOptions.h"
2
+
3
+@interface RNNBackgrounOptions : RNNOptions
4
+
5
+@property (nonatomic, strong) NSNumber* color;
6
+@property (nonatomic, strong) NSString* component;
7
+
8
+@end

+ 14
- 0
lib/ios/RNNBackgrounOptions.m 查看文件

@@ -0,0 +1,14 @@
1
+#import "RNNBackgrounOptions.h"
2
+
3
+@implementation RNNBackgrounOptions
4
+
5
+- (void)applyOn:(UIViewController *)viewController {
6
+	if (self.color) {
7
+		UIColor* backgroundColor = [RCTConvert UIColor:self.color];
8
+		viewController.navigationController.navigationBar.barTintColor = backgroundColor;
9
+	} else {
10
+		viewController.navigationController.navigationBar.barTintColor = nil;
11
+	}
12
+}
13
+
14
+@end

+ 3
- 2
lib/ios/RNNRootViewController.m 查看文件

@@ -95,11 +95,12 @@
95 95
 }
96 96
 
97 97
 - (void)setCustomNavigationComponentBackground {
98
-	if (self.options.topBar.backgroundComponentName) {
99
-		RCTRootView *reactView = (RCTRootView*)[_creator createRootView:self.options.topBar.backgroundComponentName rootViewId:@"navBarBackground"];
98
+	if (self.options.topBar.background.component) {
99
+		RCTRootView *reactView = (RCTRootView*)[_creator createRootView:self.options.topBar.background.component rootViewId:@"navBarBackground"];
100 100
 
101 101
 		RNNCustomTitleView *titleView = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
102 102
 		[self.navigationController.navigationBar insertSubview:titleView atIndex:1];
103
+		self.navigationController.navigationBar.clipsToBounds = YES;
103 104
 	}
104 105
 }
105 106
 

+ 2
- 2
lib/ios/RNNTopBarOptions.h 查看文件

@@ -1,11 +1,11 @@
1 1
 #import "RNNOptions.h"
2 2
 #import "RNNTitleOptions.h"
3
+#import "RNNBackgrounOptions.h"
3 4
 
4 5
 @interface RNNTopBarOptions : RNNOptions
5 6
 
6 7
 @property (nonatomic, strong) NSArray* leftButtons;
7 8
 @property (nonatomic, strong) NSArray* rightButtons;
8
-@property (nonatomic, strong) NSNumber* backgroundColor;
9 9
 @property (nonatomic, strong) NSNumber* visible;
10 10
 @property (nonatomic, strong) NSNumber* hideOnScroll;
11 11
 @property (nonatomic, strong) NSNumber* buttonColor;
@@ -18,12 +18,12 @@
18 18
 @property (nonatomic, strong) NSNumber* largeTitle;
19 19
 @property (nonatomic, strong) NSString* testID;
20 20
 @property (nonatomic, strong) RNNTitleOptions* title;
21
+@property (nonatomic, strong) RNNBackgrounOptions* background;
21 22
 @property (nonatomic, strong) NSNumber* backButtonImage;
22 23
 @property (nonatomic, strong) NSNumber* backButtonHidden;
23 24
 @property (nonatomic, strong) NSString* backButtonTitle;
24 25
 @property (nonatomic, strong) NSNumber* hideBackButtonTitle;
25 26
 
26 27
 @property (nonatomic, strong) NSString* componentName;
27
-@property (nonatomic, strong) NSString* backgroundComponentName;
28 28
 
29 29
 @end

+ 4
- 8
lib/ios/RNNTopBarOptions.m 查看文件

@@ -16,19 +16,15 @@ extern const NSInteger BLUR_TOPBAR_TAG;
16 16
 - (instancetype)initWithDict:(NSDictionary *)dict {
17 17
 	self = [super initWithDict:dict];
18 18
 	self.title = [RNNTitleOptions new];
19
-
19
+	self.background = [RNNBackgrounOptions new];
20
+	
20 21
 	return self;
21 22
 }
22 23
 
23 24
 - (void)applyOn:(UIViewController*)viewController {
24 25
 	[self.title applyOn:viewController];
25
-	if (self.backgroundColor) {
26
-		UIColor* backgroundColor = [RCTConvert UIColor:self.backgroundColor];
27
-		viewController.navigationController.navigationBar.barTintColor = backgroundColor;
28
-	} else {
29
-		viewController.navigationController.navigationBar.barTintColor = nil;
30
-	}
31
-
26
+	[self.background applyOn:viewController];
27
+	
32 28
 	if (@available(iOS 11.0, *)) {
33 29
 		if (self.largeTitle){
34 30
 			if ([self.largeTitle boolValue]) {

+ 8
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj 查看文件

@@ -98,6 +98,8 @@
98 98
 		50CB3B6A1FDE911400AA153B /* RNNSideMenuOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50CB3B681FDE911400AA153B /* RNNSideMenuOptions.m */; };
99 99
 		50D031342005149000386B3D /* RNNOverlayManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 50D031322005149000386B3D /* RNNOverlayManager.h */; };
100 100
 		50D031352005149000386B3D /* RNNOverlayManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 50D031332005149000386B3D /* RNNOverlayManager.m */; };
101
+		50EB4ED72068EBE000D6ED34 /* RNNBackgrounOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50EB4ED52068EBE000D6ED34 /* RNNBackgrounOptions.h */; };
102
+		50EB4ED82068EBE000D6ED34 /* RNNBackgrounOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50EB4ED62068EBE000D6ED34 /* RNNBackgrounOptions.m */; };
101 103
 		50EB93421FE14A3E00BD8EEE /* RNNBottomTabOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50EB93401FE14A3E00BD8EEE /* RNNBottomTabOptions.m */; };
102 104
 		50F5DFC11F407A8C001A00BC /* RNNTabBarController.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F5DFBF1F407A8C001A00BC /* RNNTabBarController.h */; };
103 105
 		50F5DFC21F407A8C001A00BC /* RNNTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 50F5DFC01F407A8C001A00BC /* RNNTabBarController.m */; };
@@ -283,6 +285,8 @@
283 285
 		50CB3B681FDE911400AA153B /* RNNSideMenuOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuOptions.m; sourceTree = "<group>"; };
284 286
 		50D031322005149000386B3D /* RNNOverlayManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNOverlayManager.h; sourceTree = "<group>"; };
285 287
 		50D031332005149000386B3D /* RNNOverlayManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayManager.m; sourceTree = "<group>"; };
288
+		50EB4ED52068EBE000D6ED34 /* RNNBackgrounOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNBackgrounOptions.h; sourceTree = "<group>"; };
289
+		50EB4ED62068EBE000D6ED34 /* RNNBackgrounOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNBackgrounOptions.m; sourceTree = "<group>"; };
286 290
 		50EB933F1FE14A3E00BD8EEE /* RNNBottomTabOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNBottomTabOptions.h; sourceTree = "<group>"; };
287 291
 		50EB93401FE14A3E00BD8EEE /* RNNBottomTabOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNBottomTabOptions.m; sourceTree = "<group>"; };
288 292
 		50F5DFBF1F407A8C001A00BC /* RNNTabBarController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTabBarController.h; sourceTree = "<group>"; };
@@ -483,6 +487,8 @@
483 487
 				A7626BFC1FC2FB2C00492FB8 /* RNNTopBarOptions.m */,
484 488
 				50570B242061473D006A1B5C /* RNNTitleOptions.h */,
485 489
 				50570B252061473D006A1B5C /* RNNTitleOptions.m */,
490
+				50EB4ED52068EBE000D6ED34 /* RNNBackgrounOptions.h */,
491
+				50EB4ED62068EBE000D6ED34 /* RNNBackgrounOptions.m */,
486 492
 				A7626BFF1FC578AB00492FB8 /* RNNBottomTabsOptions.h */,
487 493
 				A7626C001FC5796200492FB8 /* RNNBottomTabsOptions.m */,
488 494
 				50EB933F1FE14A3E00BD8EEE /* RNNBottomTabOptions.h */,
@@ -707,6 +713,7 @@
707 713
 			buildActionMask = 2147483647;
708 714
 			files = (
709 715
 				261F0E6A1E6F028A00989DE2 /* RNNNavigationStackManager.h in Headers */,
716
+				50EB4ED72068EBE000D6ED34 /* RNNBackgrounOptions.h in Headers */,
710 717
 				504AFE761FFFF1E00076E904 /* RNNNavigationOptions.h in Headers */,
711 718
 				504AFE771FFFF1E20076E904 /* RNNTopBarOptions.h in Headers */,
712 719
 				26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
@@ -921,6 +928,7 @@
921 928
 				2DCD9196200014A900EDC75D /* RNNBridgeManager.m in Sources */,
922 929
 				263905C11E4C6F440023D7D3 /* SidebarAirbnbAnimation.m in Sources */,
923 930
 				263905D71E4C94970023D7D3 /* RNNSideMenuController.m in Sources */,
931
+				50EB4ED82068EBE000D6ED34 /* RNNBackgrounOptions.m in Sources */,
924 932
 				507F43CA1FF4F9CC00D9425B /* RNNTopTabOptions.m in Sources */,
925 933
 				26916C991E4B9E7700D13680 /* RNNReactRootViewCreator.m in Sources */,
926 934
 				214545251F4DC125006E8DA1 /* RNNUIBarButtonItem.m in Sources */,

+ 0
- 2
playground/src/screens/CustomRoundedButton.js 查看文件

@@ -34,8 +34,6 @@ module.exports = CustomRoundedButton;
34 34
 const styles = StyleSheet.create({
35 35
   container: {
36 36
     flex: 1,
37
-    width: 48,
38
-    height: 48,
39 37
     backgroundColor: 'transparent',
40 38
     flexDirection: 'column',
41 39
     justifyContent: 'center',