Skip to content

Commit

Permalink
Adds support for top card having a UIRefreshControl (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
nighthawk committed May 22, 2023
1 parent 12f3686 commit f4ef72f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Sources/TGCardViewController/TGCardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ extension TGCardViewController {
topCardView?.grabHandles.forEach {
updateCardHandleAccessibility(handle: $0, position: position)
}

let mapIsInteractive = cardIsNextToMap(in: traitCollection) || position != .extended
mapViewController.isUserInteractionEnabled = mapIsInteractive
topFloatingViewWrapper.isUserInteractionEnabled = mapIsInteractive
Expand Down Expand Up @@ -1454,7 +1454,8 @@ extension TGCardViewController {
mode == .floating,
let scrollView = recogniser.view as? UIScrollView,
scrollView == topCardView?.contentScrollView,
panner.isEnabled
panner.isEnabled,
scrollView.refreshControl == nil
else { return }

let negativity = scrollView.contentOffset.y
Expand Down Expand Up @@ -1993,6 +1994,14 @@ extension TGCardViewController: UIGestureRecognizerDelegate {
case .collapsed, .peaking: return false
}

} else if gestureRecognizer == panner {
// Don't allow panning if the card is extended and there's a refresh
// control
guard let innerScroll = topCardView?.contentScrollView else { return true }
return cardWrapperDesiredTopConstraint.constant > extendedMinY
|| innerScroll.refreshControl == nil
|| touch.location(in: innerScroll).y <= 0

} else {
return true
}
Expand Down

0 comments on commit f4ef72f

Please sign in to comment.