yogevbd 6 years ago
parent
commit
1a9815c45b

+ 1
- 1
lib/ios/RNNBottomTabsOptions.h View File

@@ -6,7 +6,7 @@
6 6
 @property (nonatomic, strong) NSNumber* animateHide;
7 7
 @property (nonatomic, strong) NSNumber* currentTabIndex;
8 8
 @property (nonatomic, strong) NSString* testID;
9
-@property (nonatomic, strong) NSNumber* drawUnder;
9
+@property (nonatomic, strong) NSNumber* drawBehind;
10 10
 @property (nonatomic, strong) NSString* currentTabId;
11 11
 
12 12
 @property (nonatomic, strong) NSNumber* translucent;

+ 2
- 2
lib/ios/RNNBottomTabsOptions.m View File

@@ -21,8 +21,8 @@ extern const NSInteger BLUR_TOPBAR_TAG;
21 21
 		viewController.tabBarController.tabBar.accessibilityIdentifier = self.testID;
22 22
 	}
23 23
 	
24
-	if (self.drawUnder) {
25
-		if ([self.drawUnder boolValue]) {
24
+	if (self.drawBehind) {
25
+		if ([self.drawBehind boolValue]) {
26 26
 			viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
27 27
 		} else {
28 28
 			viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;

+ 3
- 5
lib/ios/RNNNavigationButtons.m View File

@@ -86,11 +86,9 @@
86 86
 	barButtonItem.target = self;
87 87
 	barButtonItem.action = @selector(onButtonPress:);
88 88
 	
89
-	NSNumber *disabled = dictionary[@"disabled"];
90
-	BOOL disabledBool = disabled ? [disabled boolValue] : NO;
91
-	if (disabledBool) {
92
-		[barButtonItem setEnabled:NO];
93
-	}
89
+	NSNumber *enabled = dictionary[@"enabled"];
90
+	BOOL enabledBool = enabled ? [enabled boolValue] : YES;
91
+	[barButtonItem setEnabled:enabledBool];
94 92
 	
95 93
 	NSNumber *disableIconTintString = dictionary[@"disableIconTint"];
96 94
 	BOOL disableIconTint = disableIconTintString ? [disableIconTintString boolValue] : NO;

+ 7
- 1
lib/ios/RNNOptions.m View File

@@ -16,8 +16,14 @@
16 16
 
17 17
 -(void)mergeWith:(NSDictionary *)otherOptions {
18 18
 	for (id key in otherOptions) {
19
-		[self setValue:[otherOptions objectForKey:key] forKey:key];
19
+		if ([self hasProperty:key]) {
20
+			[self setValue:[otherOptions objectForKey:key] forKey:key];
21
+		}
20 22
 	}
21 23
 }
22 24
 
25
+-(BOOL)hasProperty:(NSString*)propName {
26
+	return [self respondsToSelector:NSSelectorFromString(propName)];
27
+}
28
+
23 29
 @end

+ 1
- 1
lib/ios/RNNTopBarOptions.h View File

@@ -13,7 +13,7 @@
13 13
 @property (nonatomic, strong) NSNumber* buttonColor;
14 14
 @property (nonatomic, strong) NSNumber* translucent;
15 15
 @property (nonatomic, strong) NSNumber* transparent;
16
-@property (nonatomic, strong) NSNumber* drawUnder;
16
+@property (nonatomic, strong) NSNumber* drawBehind;
17 17
 @property (nonatomic, strong) NSNumber* textFontSize;
18 18
 @property (nonatomic, strong) NSNumber* noBorder;
19 19
 @property (nonatomic, strong) NSNumber* blur;

+ 2
- 2
lib/ios/RNNTopBarOptions.m View File

@@ -130,8 +130,8 @@ extern const NSInteger BLUR_TOPBAR_TAG;
130 130
 		viewController.navigationController.navigationBar.translucent = [self.translucent boolValue];
131 131
 	}
132 132
 	
133
-	if (self.drawUnder) {
134
-		if ([self.drawUnder boolValue]) {
133
+	if (self.drawBehind) {
134
+		if ([self.drawBehind boolValue]) {
135 135
 			viewController.edgesForExtendedLayout |= UIRectEdgeTop;
136 136
 		} else {
137 137
 			viewController.edgesForExtendedLayout &= ~UIRectEdgeTop;

+ 5
- 8
lib/ios/ReactNativeNavigationTests/RNNNavigationOptionsTest.m View File

@@ -11,29 +11,26 @@
11 11
     [super setUp];
12 12
 }
13 13
 
14
--(void)testInitCreatesInstanceType{
14
+- (void)testInitCreatesInstanceType {
15 15
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{}];
16 16
 	XCTAssertTrue([options isKindOfClass:[RNNNavigationOptions class]]);
17 17
 }
18
--(void)testAddsStyleFromDictionaryWithInit{
18
+- (void)testAddsStyleFromDictionaryWithInit {
19 19
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"backgroundColor" : @(0xff0000ff)}}];
20 20
 	XCTAssertTrue(options.topBar.backgroundColor);
21 21
 }
22
--(void)testThrowsWhenStyleDoesNotExist{
23
-	XCTAssertThrows([[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"someColor" : @(0xff0000ff)}}]);
24
-}
25 22
 
26
--(void)testChangeRNNNavigationOptionsDynamically{
23
+- (void)testChangeRNNNavigationOptionsDynamically {
27 24
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"backgroundColor" : @(0xff0000ff)}}];
28 25
 	NSDictionary* dynamicOptions = @{@"topBar": @{@"textColor" : @(0xffff00ff), @"title" : @"hello"}};
29 26
 	[options mergeWith:dynamicOptions];
30 27
 	XCTAssertTrue([options.topBar.title isEqual:@"hello"]);
31 28
 }
32 29
 
33
--(void)testChangeRNNNavigationOptionsWithInvalidProperties{
30
+- (void)testChangeRNNNavigationOptionsWithInvalidProperties {
34 31
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"backgroundColor" : @(0xff0000ff)}}];
35 32
 	NSDictionary* dynamicOptions = @{@"topBar": @{@"titleeeee" : @"hello"}};
36
-	XCTAssertThrows([options mergeWith:dynamicOptions]);
33
+	XCTAssertNoThrow([options mergeWith:dynamicOptions]);
37 34
 }
38 35
 
39 36
 @end

+ 6
- 6
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m View File

@@ -385,7 +385,7 @@
385 385
 -(void)testRightButtonsWithTitle_withStyle {
386 386
 	NSNumber* inputColor = @(0xFFFF0000);
387 387
 	
388
-	self.options.topBar.rightButtons = @[@{@"id": @"testId", @"title": @"test", @"disabled": @true, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
388
+	self.options.topBar.rightButtons = @[@{@"id": @"testId", @"title": @"test", @"enabled": @false, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
389 389
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
390 390
 	[self.uut viewWillAppear:false];
391 391
 	
@@ -416,7 +416,7 @@
416 416
 -(void)testLeftButtonsWithTitle_withStyle {
417 417
 	NSNumber* inputColor = @(0xFFFF0000);
418 418
 	
419
-	self.options.topBar.leftButtons = @[@{@"id": @"testId", @"title": @"test", @"disabled": @true, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
419
+	self.options.topBar.leftButtons = @[@{@"id": @"testId", @"title": @"test", @"enabled": @false, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
420 420
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
421 421
 	[self.uut viewWillAppear:false];
422 422
 	
@@ -545,7 +545,7 @@
545 545
 }
546 546
 
547 547
 -(void)testTopBarDrawUnder_true {
548
-	self.options.topBar.drawUnder = @(1);
548
+	self.options.topBar.drawBehind = @(1);
549 549
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
550 550
 	[self.uut viewWillAppear:false];
551 551
 	
@@ -553,7 +553,7 @@
553 553
 }
554 554
 
555 555
 -(void)testTopBarDrawUnder_false {
556
-	self.options.topBar.drawUnder = @(0);
556
+	self.options.topBar.drawBehind = @(0);
557 557
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
558 558
 	[self.uut viewWillAppear:false];
559 559
 	
@@ -561,7 +561,7 @@
561 561
 }
562 562
 
563 563
 -(void)testBottomTabsDrawUnder_true {
564
-	self.options.bottomTabs.drawUnder = @(1);
564
+	self.options.bottomTabs.drawBehind = @(1);
565 565
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
566 566
 	[self.uut viewWillAppear:false];
567 567
 	
@@ -569,7 +569,7 @@
569 569
 }
570 570
 
571 571
 -(void)testBottomTabsDrawUnder_false {
572
-	self.options.bottomTabs.drawUnder = @(0);
572
+	self.options.bottomTabs.drawBehind = @(0);
573 573
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
574 574
 	[self.uut viewWillAppear:false];
575 575
 	

+ 1
- 5
playground/src/screens/ScrollViewScreen.js View File

@@ -11,11 +11,7 @@ class ScrollViewScreen extends Component {
11 11
     return {
12 12
       topBar: {
13 13
         title: 'Collapse',
14
-        ...Platform.select({
15
-          android: {
16
-            drawBehind: true
17
-          }
18
-        }),
14
+        drawBehind: true,
19 15
         textColor: 'black',
20 16
         textFontSize: 16
21 17
       }