File tree 4 files changed +36
-1
lines changed
4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 8
8
*/
9
9
10
10
#import < UIKit/UIKit.h>
11
-
11
+ # import " RCTWrapperViewController.h "
12
12
#import " RCTComponent.h"
13
13
14
14
@interface RCTNavItem : UIView
15
15
16
16
@property (nonatomic , copy ) NSString *title;
17
17
@property (nonatomic , strong ) UIImage *titleImage;
18
+ @property (nonatomic , weak ) RCTWrapperViewController *delegate;
18
19
@property (nonatomic , strong ) UIImage *leftButtonIcon;
19
20
@property (nonatomic , copy ) NSString *leftButtonTitle;
20
21
@property (nonatomic , assign ) UIBarButtonSystemItem leftButtonSystemIcon;
Original file line number Diff line number Diff line change 11
11
12
12
@implementation RCTNavItem
13
13
14
+ @synthesize delegate = _delegate;
14
15
@synthesize backButtonItem = _backButtonItem;
15
16
@synthesize leftButtonItem = _leftButtonItem;
16
17
@synthesize rightButtonItem = _rightButtonItem;
@@ -33,6 +34,22 @@ -(instancetype)init
33
34
return self;
34
35
}
35
36
37
+ - (void )setTitle : (NSString *)title
38
+ {
39
+ if (title != _title) {
40
+ _title = title;
41
+ [self .delegate titleDidChange: title];
42
+ }
43
+ }
44
+
45
+ - (void )setBarTintColor : (UIColor *)barTintColor
46
+ {
47
+ if (barTintColor != _barTintColor) {
48
+ _barTintColor = barTintColor;
49
+ [self .delegate barTintColorDidChange: barTintColor];
50
+ }
51
+ }
52
+
36
53
- (void )setBackButtonTitle : (NSString *)backButtonTitle
37
54
{
38
55
_backButtonTitle = backButtonTitle;
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ didMoveToNavigationController:(UINavigationController *)navigationController;
26
26
- (instancetype )initWithContentView : (UIView *)contentView NS_DESIGNATED_INITIALIZER;
27
27
- (instancetype )initWithNavItem : (RCTNavItem *)navItem ;
28
28
29
+ - (void )titleDidChange : (NSString *)title ;
30
+ - (void )barTintColorDidChange : (UIColor *)barTintColor ;
31
+
29
32
@property (nonatomic , weak ) id <RCTWrapperViewControllerNavigationListener> navigationListener;
30
33
@property (nonatomic , strong ) RCTNavItem *navItem;
31
34
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ - (instancetype)initWithNavItem:(RCTNavItem *)navItem
45
45
{
46
46
if ((self = [self initWithContentView: navItem])) {
47
47
_navItem = navItem;
48
+ _navItem.delegate = self;
48
49
}
49
50
return self;
50
51
}
@@ -60,6 +61,19 @@ - (void)viewWillLayoutSubviews
60
61
_currentBottomLayoutGuide = self.bottomLayoutGuide ;
61
62
}
62
63
64
+
65
+ - (void )titleDidChange : (NSString *)title
66
+ {
67
+ UINavigationItem *item = self.navigationItem ;
68
+ item.title = title;
69
+ }
70
+
71
+ - (void )barTintColorDidChange : (UIColor *)barTintColor
72
+ {
73
+ UINavigationBar *bar = self.navigationController .navigationBar ;
74
+ bar.barTintColor = barTintColor;
75
+ }
76
+
63
77
static BOOL RCTFindScrollViewAndRefreshContentInsetInView (UIView *view)
64
78
{
65
79
if ([view conformsToProtocol: @protocol (RCTAutoInsetsProtocol)]) {
You can’t perform that action at this time.
0 commit comments