Skip to content

Commit

Permalink
Merge pull request #3 from skedgo/hotfix/table-card-unable-to-scroll-…
Browse files Browse the repository at this point in the history
…to-the-bottom

Table card unable to scroll to the bottom
  • Loading branch information
pnuts2 authored Sep 10, 2021
2 parents 3e818fc + 950d3e8 commit c45f2b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
10 changes: 9 additions & 1 deletion Sources/TGCardViewController/TGCardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,17 @@ open class TGCardViewController: UIViewController {
mapManager.edgePadding = edgePadding
}
}

if let scrollView = topCardView?.contentScrollView {
view.updateConstraintsIfNeeded() // to get the correct frames

let adjustedBottom = cardIsNextToMap(in: traitCollection) ? view.safeAreaInsets.bottom : (headerView.frame.maxY + view.safeAreaInsets.top - view.safeAreaInsets.bottom)

scrollView.contentInset.bottom = adjustedBottom
scrollView.verticalScrollIndicatorInsets.bottom = adjustedBottom
}
}


// MARK: - UIStateRestoring

private var restoredCardPosition: TGCardPosition?
Expand Down
21 changes: 3 additions & 18 deletions Sources/TGCardViewController/cards/TGTableCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,11 @@ open class TGTableCard: TGCard {
open override func didAppear(animated: Bool) {
super.didAppear(animated: animated)

guard
let scrollCardView = cardView as? TGScrollCardView,
let embeddedScrollView = scrollCardView.embeddedScrollView
else {
assertionFailure()
return
}

if scrollCardView.safeAreaInsets.bottom == 0 {
// For devices with physical Home button, we need to add some extra padding
// from the bottom, otherwise, the last row of the table view will be
// partially hidden below the screen.
embeddedScrollView.contentInset.bottom = scrollCardView.safeAreaInsets.bottom + 16
embeddedScrollView.verticalScrollIndicatorInsets.bottom = scrollCardView.safeAreaInsets.bottom + 16
} else {
embeddedScrollView.contentInset.bottom = scrollCardView.safeAreaInsets.bottom
embeddedScrollView.verticalScrollIndicatorInsets.bottom = scrollCardView.safeAreaInsets.bottom
guard let scrollCardView = cardView as? TGScrollCardView else {
assertionFailure()
return
}


autoDeselect(scrollCardView)
}

Expand Down

0 comments on commit c45f2b1

Please sign in to comment.