Browse Source

Added backButton.color support

yogevbd 6 years ago
parent
commit
98ff69ec56

+ 1
- 0
lib/ios/RNNBackButtonOptions.h View File

7
 @property (nonatomic, strong) NSString* title;
7
 @property (nonatomic, strong) NSString* title;
8
 @property (nonatomic, strong) NSString* transition;
8
 @property (nonatomic, strong) NSString* transition;
9
 @property (nonatomic, strong) NSNumber* showTitle;
9
 @property (nonatomic, strong) NSNumber* showTitle;
10
+@property (nonatomic, strong) NSNumber* color;
10
 
11
 
11
 @end
12
 @end

+ 22
- 11
lib/ios/RNNBackButtonOptions.m View File

1
 #import "RNNBackButtonOptions.h"
1
 #import "RNNBackButtonOptions.h"
2
+#import "UIImage+tint.h"
2
 
3
 
3
 @implementation RNNBackButtonOptions
4
 @implementation RNNBackButtonOptions
4
 
5
 
5
 - (void)applyOn:(UIViewController *)viewController {
6
 - (void)applyOn:(UIViewController *)viewController {
6
 	if (self.icon) {
7
 	if (self.icon) {
7
-		UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
8
-		[viewController.navigationController.navigationBar setBackIndicatorImage:image];
9
-		[viewController.navigationController.navigationBar setBackIndicatorTransitionMaskImage:image];
8
+		UIImage *image = self.tintedIcon;
9
+		[viewController.navigationController.navigationBar setBackIndicatorImage:[UIImage new]];
10
+		[viewController.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage new]];
11
+		
12
+		UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:nil action:nil];
13
+		viewController.navigationItem.backBarButtonItem = backItem;
14
+	} else if (self.title) {
15
+		UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:self.title
16
+																	 style:UIBarButtonItemStylePlain
17
+																	target:nil
18
+																	action:nil];
19
+		
20
+		viewController.navigationItem.backBarButtonItem = backItem;
10
 	}
21
 	}
11
 	
22
 	
12
 	if (self.visible) {
23
 	if (self.visible) {
16
 	if (self.showTitle && ![self.showTitle boolValue]) {
27
 	if (self.showTitle && ![self.showTitle boolValue]) {
17
 		self.title = @"";
28
 		self.title = @"";
18
 	}
29
 	}
19
-	
20
-	if (self.title) {
21
-		UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:self.title
22
-																	 style:UIBarButtonItemStylePlain
23
-																	target:nil
24
-																	action:nil];
25
-		
26
-		viewController.navigationItem.backBarButtonItem = backItem;
30
+}
31
+
32
+- (UIImage *)tintedIcon {
33
+	UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
34
+	if (self.color) {
35
+		return [[image withTintColor:[RCTConvert UIColor:self.color]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
27
 	}
36
 	}
37
+	
38
+	return image;
28
 }
39
 }
29
 
40
 
30
 @end
41
 @end

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

10
 	}
10
 	}
11
 	
11
 	
12
 	NSDictionary* fontAttributes = [self fontAttributes];
12
 	NSDictionary* fontAttributes = [self fontAttributes];
13
-	
13
+
14
 	if (fontAttributes.allKeys.count > 0) {
14
 	if (fontAttributes.allKeys.count > 0) {
15
 		viewController.navigationController.navigationBar.titleTextAttributes = fontAttributes;
15
 		viewController.navigationController.navigationBar.titleTextAttributes = fontAttributes;
16
 	}
16
 	}
31
 			if (self.fontSize) {
31
 			if (self.fontSize) {
32
 				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.fontFamily size:[self.fontSize floatValue]];
32
 				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.fontFamily size:[self.fontSize floatValue]];
33
 			} else {
33
 			} else {
34
-				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.fontFamily size:20];
34
+				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.fontFamily size:17];
35
 			}
35
 			}
36
 		} else if (self.fontSize) {
36
 		} else if (self.fontSize) {
37
 			navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:[self.fontSize floatValue]];
37
 			navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:[self.fontSize floatValue]];

+ 0
- 7
lib/ios/RNNTopBarOptions.m View File

64
 		viewController.navigationController.hidesBarsOnSwipe = NO;
64
 		viewController.navigationController.hidesBarsOnSwipe = NO;
65
 	}
65
 	}
66
 	
66
 	
67
-	if (self.buttonColor) {
68
-		UIColor* buttonColor = [RCTConvert UIColor:self.buttonColor];
69
-		viewController.navigationController.navigationBar.tintColor = buttonColor;
70
-	} else {
71
-		viewController.navigationController.navigationBar.tintColor = nil;
72
-	}
73
-	
74
 	if ([self.blur boolValue]) {
67
 	if ([self.blur boolValue]) {
75
 		if (![viewController.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]) {
68
 		if (![viewController.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]) {
76
 			
69