react-native-navigation 8.8.3-snapshot.2536 → 8.8.3-snapshot.2549

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
1
1
  #import "RNNReactTitleView.h"
2
2
 
3
+ static const CGFloat kTitleViewDefaultHeight = 44.0;
4
+
3
5
  @implementation RNNReactTitleView {
4
6
  BOOL _fillParent;
5
7
  CGFloat _expectedHeight;
@@ -11,19 +13,30 @@
11
13
 
12
14
  - (CGSize)intrinsicContentSize {
13
15
  if (_fillParent) {
14
- return CGSizeMake(UILayoutFittingExpandedSize.width, _expectedHeight > 0 ? _expectedHeight : 44);
15
- } else {
16
- return [super intrinsicContentSize];
16
+ return CGSizeMake(UILayoutFittingExpandedSize.width,
17
+ _expectedHeight > 0 ? _expectedHeight : kTitleViewDefaultHeight);
17
18
  }
19
+ return [super intrinsicContentSize];
20
+ }
21
+
22
+ - (CGSize)sizeThatFits:(CGSize)size {
23
+ if (_fillParent) {
24
+ return size;
25
+ }
26
+ return [super sizeThatFits:size];
18
27
  }
19
28
 
20
29
  - (void)setAlignment:(NSString *)alignment inFrame:(CGRect)frame {
21
30
  if ([alignment isEqualToString:@"fill"]) {
22
31
  _fillParent = YES;
23
- _expectedHeight = frame.size.height;
24
- self.translatesAutoresizingMaskIntoConstraints = NO;
32
+ _expectedHeight = frame.size.height > 0 ? frame.size.height : kTitleViewDefaultHeight;
33
+ self.frame = frame;
34
+ self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin |
35
+ UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
25
36
  self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
26
37
  } else {
38
+ _fillParent = NO;
39
+ self.autoresizingMask = UIViewAutoresizingNone;
27
40
  self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
28
41
  __weak RNNReactView *weakSelf = self;
29
42
  [self setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicSize) {
@@ -32,6 +45,14 @@
32
45
  }
33
46
  }
34
47
 
48
+ - (void)layoutSubviews {
49
+ [super layoutSubviews];
50
+ if (_fillParent && self.bounds.size.height > 0 && _expectedHeight != self.bounds.size.height) {
51
+ _expectedHeight = self.bounds.size.height;
52
+ [self invalidateIntrinsicContentSize];
53
+ }
54
+ }
55
+
35
56
  - (void)setRootViewDidChangeIntrinsicSize:(void (^)(CGSize))rootViewDidChangeIntrinsicSize {
36
57
  _rootViewDidChangeIntrinsicSize = rootViewDidChangeIntrinsicSize;
37
58
  self.delegate = self;
@@ -83,12 +83,26 @@
83
83
  reactViewReadyBlock:readyBlock];
84
84
  _customTitleView.backgroundColor = UIColor.clearColor;
85
85
  NSString *alignment = [options.title.component.alignment withDefault:@""];
86
- [_customTitleView setAlignment:alignment
87
- inFrame:viewController.navigationController.navigationBar.frame];
86
+ UINavigationBar *navigationBar = viewController.navigationController.navigationBar;
87
+ CGRect barBounds = navigationBar.bounds;
88
+ [_customTitleView setAlignment:alignment inFrame:barBounds];
88
89
  [_customTitleView layoutIfNeeded];
89
90
 
90
91
  viewController.navigationItem.titleView = nil;
91
92
  viewController.navigationItem.titleView = _customTitleView;
93
+
94
+ __weak RNNReactTitleView *weakTitleView = _customTitleView;
95
+ __weak UIViewController *weakViewController = viewController;
96
+ dispatch_async(dispatch_get_main_queue(), ^{
97
+ UINavigationController *navigationController = weakViewController.navigationController;
98
+ if (!navigationController || !weakTitleView) {
99
+ return;
100
+ }
101
+ [weakTitleView setAlignment:alignment inFrame:navigationController.navigationBar.bounds];
102
+ weakViewController.navigationItem.titleView = weakTitleView;
103
+ [weakTitleView setNeedsLayout];
104
+ [weakTitleView layoutIfNeeded];
105
+ });
92
106
  [_customTitleView componentWillAppear];
93
107
  [_customTitleView componentDidAppear];
94
108
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "8.8.3-snapshot.2536",
3
+ "version": "8.8.3-snapshot.2549",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,