|
@@ -12,42 +12,41 @@
|
12
|
12
|
}
|
13
|
13
|
|
14
|
14
|
- (void)applyOnNavigationController:(UINavigationController *)navigationController {
|
15
|
|
- if (self.showTitle && ![self.showTitle boolValue]) {
|
16
|
|
- self.title = @"";
|
17
|
|
- }
|
18
|
|
-
|
19
|
|
- if (self.icon) {
|
20
|
|
- UIImage *image = self.tintedIcon;
|
21
|
|
- [navigationController.navigationBar setBackIndicatorImage:[UIImage new]];
|
|
15
|
+ UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
|
|
16
|
+ UIImage* tintedIcon = self.tintedIconIfAvailable;
|
|
17
|
+ if (tintedIcon) {
|
|
18
|
+ backItem.image = tintedIcon;
|
|
19
|
+ [navigationController.navigationBar setBackIndicatorImage:[UIImage new]];
|
22
|
20
|
[navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage new]];
|
23
|
|
-
|
24
|
|
- UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:nil action:nil];
|
25
|
|
- [self setBackItem:backItem onNavigationController:navigationController];
|
26
|
|
- } else if (self.title) {
|
27
|
|
- UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:self.title
|
28
|
|
- style:UIBarButtonItemStylePlain
|
29
|
|
- target:nil
|
30
|
|
- action:nil];
|
31
|
|
-
|
32
|
|
- [self setBackItem:backItem onNavigationController:navigationController];
|
33
|
|
-
|
34
|
21
|
}
|
|
22
|
+
|
|
23
|
+ if (self.color) {
|
|
24
|
+ backItem.tintColor = [RCTConvert UIColor:self.color];
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ if (self.showTitle && ![self.showTitle boolValue]) {
|
|
28
|
+ self.title = @"";
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+ [self setBackItem:backItem onNavigationController:navigationController];
|
35
|
32
|
}
|
36
|
33
|
|
37
|
34
|
- (void)setBackItem:(UIBarButtonItem *)backItem onNavigationController:(UINavigationController *)navigationController {
|
38
|
|
- if (navigationController.viewControllers.count >= 2) {
|
39
|
|
- UIViewController* lastViewControllerInStack = navigationController.viewControllers[navigationController.viewControllers.count - 2];
|
40
|
|
- lastViewControllerInStack.navigationItem.backBarButtonItem = backItem;
|
41
|
|
- }
|
|
35
|
+ NSArray *viewControllers = navigationController.viewControllers;
|
|
36
|
+ UIViewController *lastViewControllerInStack = [viewControllers lastObject];
|
|
37
|
+ backItem.title = self.title ? self.title : lastViewControllerInStack.navigationItem.title;
|
|
38
|
+ lastViewControllerInStack.navigationItem.backBarButtonItem = backItem;
|
42
|
39
|
}
|
43
|
40
|
|
44
|
|
-- (UIImage *)tintedIcon {
|
45
|
|
- UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
|
46
|
|
- if (self.color) {
|
47
|
|
- return [[image withTintColor:[RCTConvert UIColor:self.color]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
41
|
+- (UIImage *)tintedIconIfAvailable {
|
|
42
|
+ if (self.icon) {
|
|
43
|
+ UIImage *image = [RCTConvert UIImage:self.icon];
|
|
44
|
+ return self.color
|
|
45
|
+ ? [[image withTintColor:[RCTConvert UIColor:self.color]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
|
|
46
|
+ : image;
|
48
|
47
|
}
|
49
|
|
-
|
50
|
|
- return image;
|
|
48
|
+
|
|
49
|
+ return nil;
|
51
|
50
|
}
|
52
|
51
|
|
53
|
52
|
@end
|