From 69ca772fed455d0a19c5725bd0a784587dabeb19 Mon Sep 17 00:00:00 2001 From: Veronique Nguyen Date: Fri, 11 Aug 2023 16:33:51 +0000 Subject: [PATCH] [iOS] Scrolling between the initial and expand states is jumpy Issue for the payments bottom sheet was caused by recalculating the initial height every time -viewIsAppearing is called. Keeping track of the value and reusing it fixed this issue. Bug: 1469913 Change-Id: I64941cc7dc80473c3dd8414e0aa091be5f50037b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4771062 Reviewed-by: Tommy Martino Commit-Queue: Veronique Nguyen Code-Coverage: findit-for-me@appspot.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#1182618} --- ...ayments_suggestion_bottom_sheet_view_controller.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ios/chrome/browser/ui/autofill/bottom_sheet/payments_suggestion_bottom_sheet_view_controller.mm b/ios/chrome/browser/ui/autofill/bottom_sheet/payments_suggestion_bottom_sheet_view_controller.mm index 8e7ea258a419ab..ebba9b33421e63 100644 --- a/ios/chrome/browser/ui/autofill/bottom_sheet/payments_suggestion_bottom_sheet_view_controller.mm +++ b/ios/chrome/browser/ui/autofill/bottom_sheet/payments_suggestion_bottom_sheet_view_controller.mm @@ -74,6 +74,9 @@ @interface PaymentsSuggestionBottomSheetViewController () < // YES if the expanded bottom sheet size takes the whole screen. @property(nonatomic, assign) BOOL expandSizeTooLarge; +// Keep track of the minimized state height. +@property(nonatomic, assign) absl::optional minimizedStateHeight; + @end @implementation PaymentsSuggestionBottomSheetViewController @@ -133,6 +136,7 @@ - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { if (self.traitCollection.preferredContentSizeCategory != previousTraitCollection.preferredContentSizeCategory) { + self.minimizedStateHeight = absl::nullopt; [self updateHeight]; } } @@ -152,6 +156,13 @@ - (void)viewDidDisappear:(BOOL)animated { [self.handler viewDidDisappear:animated]; } +- (CGFloat)initialHeight { + if (!self.minimizedStateHeight.has_value()) { + self.minimizedStateHeight = [super initialHeight]; + } + return self.minimizedStateHeight.value(); +} + #pragma mark - PaymentsSuggestionBottomSheetConsumer - (void)setCreditCardData: