Skip to content

Commit 512de61

Browse files
Fix an issue with pinned content offsets in SafetyNumberConfirmationSheet
1 parent 605077b commit 512de61

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Signal/src/ViewControllers/SafetyNumberConfirmationSheet.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ class SafetyNumberConfirmationSheet: UIViewController {
274274
let maxAnimationDuration: TimeInterval = 0.2
275275
var startingHeight: CGFloat?
276276
var startingTranslation: CGFloat?
277+
var pinnedContentOffset: CGPoint?
277278

278279
func setupInteractiveSizing() {
279280
desiredVisibleContentHeight = minimizedHeight
@@ -303,12 +304,13 @@ class SafetyNumberConfirmationSheet: UIViewController {
303304
case .began, .changed:
304305
guard beginInteractiveTransitionIfNecessary(sender),
305306
let startingHeight = startingHeight,
306-
let startingTranslation = startingTranslation else {
307+
let startingTranslation = startingTranslation,
308+
let pinnedContentOffset = pinnedContentOffset else {
307309
return resetInteractiveTransition()
308310
}
309311

310312
// We're in an interactive transition, so don't let the scrollView scroll.
311-
tableView.contentOffset.y = 0
313+
tableView.contentOffset = pinnedContentOffset
312314
tableView.showsVerticalScrollIndicator = false
313315

314316
// We may have panned some distance if we were scrolling before we started
@@ -396,7 +398,7 @@ class SafetyNumberConfirmationSheet: UIViewController {
396398
}
397399

398400
func beginInteractiveTransitionIfNecessary(_ sender: UIPanGestureRecognizer) -> Bool {
399-
let tryingToDismiss = tableView.contentOffset.y <= 0
401+
let tryingToDismiss = tableView.contentOffset.y <= 0 || tableView.panGestureRecognizer != sender
400402
let tryingToMaximize = visibleContentHeight < maximizedHeight && tableView.height < tableView.contentSize.height
401403

402404
// If we're at the top of the scrollView, or the view is not
@@ -411,12 +413,20 @@ class SafetyNumberConfirmationSheet: UIViewController {
411413
startingHeight = visibleContentHeight
412414
}
413415

416+
if pinnedContentOffset == nil {
417+
pinnedContentOffset = tableView.contentOffset.y < 0 ? .zero : tableView.contentOffset
418+
}
419+
414420
return true
415421
}
416422

417423
func resetInteractiveTransition() {
418424
startingTranslation = nil
419425
startingHeight = nil
426+
if let pinnedContentOffset = pinnedContentOffset {
427+
tableView.contentOffset = pinnedContentOffset
428+
}
429+
pinnedContentOffset = nil
420430
tableView.showsVerticalScrollIndicator = true
421431
}
422432

0 commit comments

Comments
 (0)