yogevbd 6 years ago
parent
commit
1a9815c45b

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

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

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

21
 		viewController.tabBarController.tabBar.accessibilityIdentifier = self.testID;
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
 			viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
26
 			viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
27
 		} else {
27
 		} else {
28
 			viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;
28
 			viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;

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

86
 	barButtonItem.target = self;
86
 	barButtonItem.target = self;
87
 	barButtonItem.action = @selector(onButtonPress:);
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
 	NSNumber *disableIconTintString = dictionary[@"disableIconTint"];
93
 	NSNumber *disableIconTintString = dictionary[@"disableIconTint"];
96
 	BOOL disableIconTint = disableIconTintString ? [disableIconTintString boolValue] : NO;
94
 	BOOL disableIconTint = disableIconTintString ? [disableIconTintString boolValue] : NO;

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

16
 
16
 
17
 -(void)mergeWith:(NSDictionary *)otherOptions {
17
 -(void)mergeWith:(NSDictionary *)otherOptions {
18
 	for (id key in otherOptions) {
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
 @end
29
 @end

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

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

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

130
 		viewController.navigationController.navigationBar.translucent = [self.translucent boolValue];
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
 			viewController.edgesForExtendedLayout |= UIRectEdgeTop;
135
 			viewController.edgesForExtendedLayout |= UIRectEdgeTop;
136
 		} else {
136
 		} else {
137
 			viewController.edgesForExtendedLayout &= ~UIRectEdgeTop;
137
 			viewController.edgesForExtendedLayout &= ~UIRectEdgeTop;

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

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

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

385
 -(void)testRightButtonsWithTitle_withStyle {
385
 -(void)testRightButtonsWithTitle_withStyle {
386
 	NSNumber* inputColor = @(0xFFFF0000);
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
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
389
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
390
 	[self.uut viewWillAppear:false];
390
 	[self.uut viewWillAppear:false];
391
 	
391
 	
416
 -(void)testLeftButtonsWithTitle_withStyle {
416
 -(void)testLeftButtonsWithTitle_withStyle {
417
 	NSNumber* inputColor = @(0xFFFF0000);
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
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
420
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
421
 	[self.uut viewWillAppear:false];
421
 	[self.uut viewWillAppear:false];
422
 	
422
 	
545
 }
545
 }
546
 
546
 
547
 -(void)testTopBarDrawUnder_true {
547
 -(void)testTopBarDrawUnder_true {
548
-	self.options.topBar.drawUnder = @(1);
548
+	self.options.topBar.drawBehind = @(1);
549
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
549
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
550
 	[self.uut viewWillAppear:false];
550
 	[self.uut viewWillAppear:false];
551
 	
551
 	
553
 }
553
 }
554
 
554
 
555
 -(void)testTopBarDrawUnder_false {
555
 -(void)testTopBarDrawUnder_false {
556
-	self.options.topBar.drawUnder = @(0);
556
+	self.options.topBar.drawBehind = @(0);
557
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
557
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
558
 	[self.uut viewWillAppear:false];
558
 	[self.uut viewWillAppear:false];
559
 	
559
 	
561
 }
561
 }
562
 
562
 
563
 -(void)testBottomTabsDrawUnder_true {
563
 -(void)testBottomTabsDrawUnder_true {
564
-	self.options.bottomTabs.drawUnder = @(1);
564
+	self.options.bottomTabs.drawBehind = @(1);
565
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
565
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
566
 	[self.uut viewWillAppear:false];
566
 	[self.uut viewWillAppear:false];
567
 	
567
 	
569
 }
569
 }
570
 
570
 
571
 -(void)testBottomTabsDrawUnder_false {
571
 -(void)testBottomTabsDrawUnder_false {
572
-	self.options.bottomTabs.drawUnder = @(0);
572
+	self.options.bottomTabs.drawBehind = @(0);
573
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
573
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
574
 	[self.uut viewWillAppear:false];
574
 	[self.uut viewWillAppear:false];
575
 	
575
 	

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

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