Skip to content

Commit

Permalink
[Manage People/Links] Rotation UI Bug Fix
Browse files Browse the repository at this point in the history
This change is a slight alteration to the change introduced in cl/347036858 this moves the added code to the bottom of the method so as to not interfere with the recursive call.

BEGIN_PUBLIC
Made a slight change to move adding `presentingViewYOffset' to `_contentHeightSurplus` to the end of the method. This was added in a previous change but didn't take into account the possibility of an infinite recursive loop. This movement should prevent that while also updating `_contentHeightSurplus` to the proper value. This should also fix the bug brought up in b/176122058
END_PUBLIC

PiperOrigin-RevId: 351455638
  • Loading branch information
Nobody authored and material-automation committed Jan 12, 2021
1 parent 11e4afa commit 6b4b029
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Expand Up @@ -15,9 +15,11 @@
#import "MDCBottomDrawerContainerViewController.h"

#import "MDCBottomDrawerHeader.h"
#import "MDCBottomDrawerState.h"
#import "MDCBottomDrawerContainerViewControllerDelegate.h"
#import "MDCBottomDrawerHeaderMask.h"
#import "MDCBottomDrawerShadowedView.h"
#import "MaterialShadowElevations.h"
#import "MaterialShadowLayer.h"
#import "MaterialApplication.h"
#import "MaterialMath.h"
#import "MaterialUIMetrics.h"
Expand Down Expand Up @@ -1099,11 +1101,6 @@ - (void)cacheLayoutCalculationsWithAddedContentHeight:(CGFloat)addedContentHeigh

CGFloat scrollingDistance = _contentHeaderTopInset + totalHeight;
_contentHeightSurplus = scrollingDistance - containerHeight;
// readded `presentingViewYOffset` because offset is cancelled out
// by being included in both the `scrollingDistance` and `containerHeight`.
// Because `containerHeight` is used in independent calculations
// we can't remove the offset from there.
_contentHeightSurplus += self.presentingViewYOffset;
if ([self shouldPresentFullScreen]) {
self.drawerState = MDCBottomDrawerStateFullScreen;
} else if (_contentHeightSurplus <= 0) {
Expand All @@ -1116,6 +1113,13 @@ - (void)cacheLayoutCalculationsWithAddedContentHeight:(CGFloat)addedContentHeigh
CGFloat addedContentheight = _contentHeaderTopInset - _contentHeightSurplus;
[self cacheLayoutCalculationsWithAddedContentHeight:addedContentheight];
}
// Readded `presentingViewYOffset` because offset is cancelled out
// by being included in both the `scrollingDistance` and `containerHeight`.
// Because `containerHeight` is used in independent calculations
// we can't remove the offset from there.
// This y-offset should be readded at the end of this method, this is to prevent it from being
// included in the recursive call in the conditional above.
_contentHeightSurplus += self.presentingViewYOffset;
}

- (CGFloat)transitionPercentageForContentOffset:(CGPoint)contentOffset
Expand Down
Expand Up @@ -294,12 +294,6 @@ - (void)testContentHeightSurplusIsAddingYOffset {
self.navigationDrawer.headerViewController.preferredContentSize = CGSizeMake(100, 200);
self.navigationDrawer.contentViewController.preferredContentSize = CGSizeMake(100, 200);
[self.navigationDrawer.presentationController presentationTransitionWillBegin];
// This will be used to assert the `contentHeightSurplus` The height surplus is calculated by
// adding the content height and the header height. We then add the `presentingViewYOffset`.
// The offset is calculated by subtracting the frame height with the presenting bounds height.
// The presenting view bounds here is 0 and the content and header height get cancelled out in
// the surplus calculation. So the surplus ends up being the frame height
CGFloat frameHeight = CGRectGetHeight(self.navigationDrawer.view.frame);

// When
self.navigationDrawer.maximumDrawerHeight = 0;
Expand All @@ -314,7 +308,7 @@ - (void)testContentHeightSurplusIsAddingYOffset {
XCTAssertEqual(presentationController.bottomDrawerContainerViewController.maximumDrawerHeight,
0);
XCTAssertEqual(presentationController.bottomDrawerContainerViewController.contentHeightSurplus,
frameHeight);
880);
} else {
XCTFail(@"The presentation controller should be class of kind "
@"MDCBottomDrawerPresentationController but is %@",
Expand Down

0 comments on commit 6b4b029

Please sign in to comment.