Skip to content

Commit f4ef72f

Browse files
authored
Adds support for top card having a UIRefreshControl (#17)
1 parent 12f3686 commit f4ef72f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Sources/TGCardViewController/TGCardViewController.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ extension TGCardViewController {
12521252
topCardView?.grabHandles.forEach {
12531253
updateCardHandleAccessibility(handle: $0, position: position)
12541254
}
1255-
1255+
12561256
let mapIsInteractive = cardIsNextToMap(in: traitCollection) || position != .extended
12571257
mapViewController.isUserInteractionEnabled = mapIsInteractive
12581258
topFloatingViewWrapper.isUserInteractionEnabled = mapIsInteractive
@@ -1454,7 +1454,8 @@ extension TGCardViewController {
14541454
mode == .floating,
14551455
let scrollView = recogniser.view as? UIScrollView,
14561456
scrollView == topCardView?.contentScrollView,
1457-
panner.isEnabled
1457+
panner.isEnabled,
1458+
scrollView.refreshControl == nil
14581459
else { return }
14591460

14601461
let negativity = scrollView.contentOffset.y
@@ -1993,6 +1994,14 @@ extension TGCardViewController: UIGestureRecognizerDelegate {
19931994
case .collapsed, .peaking: return false
19941995
}
19951996

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

0 commit comments

Comments
 (0)