Skip to content

Commit

Permalink
Fix bounce when expanding sheet on ios (#5627)
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok authored Oct 6, 2024
1 parent 0ebf636 commit 686dfa5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions modules/bottom-sheet/ios/SheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate {
}
}
}
private var prevLayoutDetentIdentifier: UISheetPresentationController.Detent.Identifier?

// MARK: - Lifecycle

Expand Down Expand Up @@ -143,11 +144,13 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate {
}

func updateLayout() {
if let contentHeight = self.innerView?.subviews.first?.frame.size.height {
if self.prevLayoutDetentIdentifier == self.selectedDetentIdentifier,
let contentHeight = self.innerView?.subviews.first?.frame.size.height {
self.sheetVc?.updateDetents(contentHeight: self.clampHeight(contentHeight),
preventExpansion: self.preventExpansion)
preventExpansion: self.preventExpansion)
self.selectedDetentIdentifier = self.sheetVc?.getCurrentDetentIdentifier()
}
self.prevLayoutDetentIdentifier = self.selectedDetentIdentifier
}

func dismiss() {
Expand Down
2 changes: 1 addition & 1 deletion modules/bottom-sheet/ios/SheetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class SheetViewController: UIViewController {
}
}
}

func getCurrentDetentIdentifier() -> UISheetPresentationController.Detent.Identifier? {
guard let sheet = self.sheetPresentationController else {
return nil
Expand Down

0 comments on commit 686dfa5

Please sign in to comment.