Browse Source

Revert "Now allowing the custom nav bar to take up the whole space on iOS" (#2404)

* Revert "Improve getCurrentlyVisibleScreenId on iOS with drawers. (#2052)"

This reverts commit 2c30a52bb9.

* Revert "introducing navbar shadow on iOS (#2339)"

This reverts commit 8fd496e0c9.

* Revert "This fixes an issue with a custom title-view (which has a title and a subtitle) appearing at the left side of the nav-bar instead of the center during a transition animation: when a screen with this title-view is being pushed or when you pop back to it. (#2384)"

This reverts commit 3f7f6c2612.

* Revert "Now allowing the custom nav bar to take up the whole space on iOS (#2306)"

This reverts commit 74a02ccfc5.
Guy Carmeli 6 years ago
parent
commit
1399c7b486
No account linked to committer's email address
3 changed files with 3 additions and 68 deletions
  1. 1
    1
      ios/RCCCustomTitleView.h
  2. 0
    54
      ios/RCCCustomTitleView.m
  3. 2
    13
      ios/RCCViewController.m

+ 1
- 1
ios/RCCCustomTitleView.h View File

@@ -11,5 +11,5 @@
11 11
 @interface RCCCustomTitleView : UIView
12 12
 
13 13
 -(instancetype)initWithFrame:(CGRect)frame subView:(UIView*)subView alignment:(NSString*)alignment;
14
-- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator;
14
+
15 15
 @end

+ 0
- 54
ios/RCCCustomTitleView.m View File

@@ -11,14 +11,12 @@
11 11
 @interface RCCCustomTitleView ()
12 12
 @property (nonatomic, strong) UIView *subView;
13 13
 @property (nonatomic, strong) NSString *subViewAlign;
14
-@property float initialWidth;
15 14
 @end
16 15
 
17 16
 @implementation RCCCustomTitleView
18 17
 
19 18
 
20 19
 -(instancetype)initWithFrame:(CGRect)frame subView:(UIView*)subView alignment:(NSString*)alignment {
21
-    _initialWidth = frame.size.width;
22 20
     self = [super initWithFrame:frame];
23 21
     
24 22
     if (self) {
@@ -54,56 +52,4 @@
54 52
     }
55 53
 }
56 54
 
57
-- (void)setFrame:(CGRect) frame {
58
-
59
-    float referenceWidth = [self statusBarWidth];
60
-    if (referenceWidth == 0) {
61
-        referenceWidth = _initialWidth;
62
-    }
63
-    float newNavBarWidth = frame.size.width;
64
-    BOOL frameNeedsToBeCorrected = newNavBarWidth < referenceWidth || CGRectEqualToRect(self.frame, CGRectZero);
65
-
66
-    if (frameNeedsToBeCorrected) {
67
-        // first we need to find out the total point diff of the status bar and the nav bar
68
-        float navBarHorizontalMargin = referenceWidth - newNavBarWidth;
69
-        
70
-        CGRect correctedFrame = frame;
71
-
72
-        // then we need to place the nav bar half times the horizontal margin to the left
73
-        correctedFrame.origin.x = -(navBarHorizontalMargin / 2);
74
-        
75
-        // and finally set the width so that it's equal to the status bar width
76
-        correctedFrame.size.width = referenceWidth;
77
-        
78
-        [super setFrame:correctedFrame];
79
-    } else if (frame.size.height != self.frame.size.height) { // otherwise
80
-        // if only the height has changed
81
-        CGRect newHeightFrame = self.frame;
82
-        // make sure we update just the height
83
-        newHeightFrame.size.height = frame.size.height;
84
-        [super setFrame:newHeightFrame];
85
-    }
86
-    
87
-    // keep a ref to the last frame, so that we avoid setting the frame twice for no reason
88
-//    _lastFrame = frame;
89
-}
90
-
91
-
92
-- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
93
-    // whenever the orientation changes this runs
94
-    // and sets the nav bar item width to the new size width
95
-    CGRect newFrame = self.frame;
96
-
97
-    if (newFrame.size.width < size.width) {
98
-        newFrame.size.width = size.width;
99
-        newFrame.origin.x = 0;
100
-    }
101
-    [super setFrame:newFrame];
102
-}
103
-
104
--(float) statusBarWidth {
105
-    CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
106
-    return MAX(statusBarSize.width, statusBarSize.height);
107
-}
108
-
109 55
 @end

+ 2
- 13
ios/RCCViewController.m View File

@@ -656,30 +656,19 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
656 656
       NSDictionary *initialProps = self.navigatorStyle[@"navBarCustomViewInitialProps"];
657 657
       RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:navBarCustomView initialProperties:initialProps];
658 658
       
659
-      RCCCustomTitleView *titleView = [[RCCCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds
660
-                                                                        subView:reactView
661
-                                                                      alignment:self.navigatorStyle[@"navBarComponentAlignment"]];
659
+      RCCCustomTitleView *titleView = [[RCCCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:self.navigatorStyle[@"navBarComponentAlignment"]];
662 660
       titleView.backgroundColor = [UIColor clearColor];
663 661
       reactView.backgroundColor = [UIColor clearColor];
664 662
       
665
-    
666 663
       self.navigationItem.titleView = titleView;
667 664
       
668 665
       self.navigationItem.titleView.backgroundColor = [UIColor clearColor];
669
-      self.navigationItem.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
666
+      self.navigationItem.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
670 667
       self.navigationItem.titleView.clipsToBounds = YES;
671 668
     }
672 669
   }
673 670
 }
674 671
 
675
-- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
676
-  [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
677
-  RCCCustomTitleView* customNavBar = (RCCCustomTitleView*) self.navigationItem.titleView;
678
-  if (customNavBar && [customNavBar isKindOfClass:[RCCCustomTitleView class]]) {
679
-    [customNavBar viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
680
-  }
681
-}
682
-
683 672
 
684 673
 -(void)storeOriginalNavBarImages {
685 674