|
@@ -3,6 +3,13 @@
|
3
|
3
|
#import "RNNUIBarButtonItem.h"
|
4
|
4
|
#import "RCTConvert+UIBarButtonSystemItem.h"
|
5
|
5
|
|
|
6
|
+@interface RNNUIBarButtonItem ()
|
|
7
|
+
|
|
8
|
+@property (nonatomic, strong) NSLayoutConstraint *widthConstraint;
|
|
9
|
+@property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
|
|
10
|
+
|
|
11
|
+@end
|
|
12
|
+
|
6
|
13
|
@implementation RNNUIBarButtonItem
|
7
|
14
|
|
8
|
15
|
-(instancetype)init:(NSString*)buttonId withIcon:(UIImage*)iconImage {
|
|
@@ -26,11 +33,26 @@
|
26
|
33
|
reactView.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
|
27
|
34
|
reactView.delegate = self;
|
28
|
35
|
reactView.backgroundColor = [UIColor clearColor];
|
|
36
|
+ self.widthConstraint = [NSLayoutConstraint constraintWithItem:reactView
|
|
37
|
+ attribute:NSLayoutAttributeWidth
|
|
38
|
+ relatedBy:NSLayoutRelationEqual
|
|
39
|
+ toItem:nil
|
|
40
|
+ attribute:NSLayoutAttributeNotAnAttribute
|
|
41
|
+ multiplier:1.0
|
|
42
|
+ constant:1.0];
|
|
43
|
+ self.heightConstraint = [NSLayoutConstraint constraintWithItem:reactView
|
|
44
|
+ attribute:NSLayoutAttributeHeight
|
|
45
|
+ relatedBy:NSLayoutRelationEqual
|
|
46
|
+ toItem:nil
|
|
47
|
+ attribute:NSLayoutAttributeNotAnAttribute
|
|
48
|
+ multiplier:1.0
|
|
49
|
+ constant:1.0];
|
|
50
|
+ [NSLayoutConstraint activateConstraints:@[self.widthConstraint, self.heightConstraint]];
|
29
|
51
|
self.buttonId = buttonId;
|
30
|
52
|
return self;
|
31
|
53
|
}
|
32
|
|
-
|
33
|
|
--(instancetype)init:(NSString*)buttonId withSystemItem:(NSString *)systemItemName {
|
|
54
|
+
|
|
55
|
+- (instancetype)init:(NSString*)buttonId withSystemItem:(NSString *)systemItemName {
|
34
|
56
|
UIBarButtonSystemItem systemItem = [RCTConvert UIBarButtonSystemItem:systemItemName];
|
35
|
57
|
self = [super initWithBarButtonSystemItem:systemItem target:nil action:nil];
|
36
|
58
|
self.buttonId = buttonId;
|
|
@@ -38,9 +60,10 @@
|
38
|
60
|
}
|
39
|
61
|
|
40
|
62
|
- (void)rootViewDidChangeIntrinsicSize:(RCTRootView *)rootView {
|
41
|
|
- CGSize size = rootView.intrinsicContentSize;
|
42
|
|
- rootView.frame = CGRectMake(0, 0, size.width, size.height);
|
43
|
|
- self.width = size.width;
|
|
63
|
+ self.widthConstraint.constant = rootView.intrinsicContentSize.width;
|
|
64
|
+ self.heightConstraint.constant = rootView.intrinsicContentSize.height;
|
|
65
|
+ [rootView setNeedsUpdateConstraints];
|
|
66
|
+ [rootView updateConstraintsIfNeeded];
|
44
|
67
|
}
|
45
|
68
|
|
46
|
69
|
- (void)onButtonPressed {
|