Skip to content

Commit

Permalink
Fixes when pairing with nav bar
Browse files Browse the repository at this point in the history
1. Don't account twice for the top overlap, keeping extended close
   to the nav bar.
2. Fix landscape where card content was always faded out
  • Loading branch information
nighthawk committed Sep 11, 2021
1 parent c45f2b1 commit b9d0f67
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions Sources/TGCardViewController/TGCardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -607,26 +607,22 @@ open class TGCardViewController: UIViewController {

// Add it a bit of extra space around the switch-over to still detect
// same position after hiding/showing bars
let peakMargin = peakY - 44
let collapsedMargin = collapsedMinY - 44
let peakMargin = max(extendedMinY, peakY - 44)
let collapsedMargin = max(peakY, collapsedMinY - 44)

switch (cardY, traitCollection.verticalSizeClass) {
case (0..<peakMargin, _): return .extended
case (peakMargin..<collapsedMargin, .regular): return .peaking
case (0...peakMargin, _): return .extended
case (peakMargin...collapsedMargin, .regular): return .peaking
default: return .collapsed
}
}

fileprivate var extendedMinY: CGFloat {
var value = topOverlap

if let navigationBar = navigationController?.navigationBar {
value += navigationBar.frame.height
}
if mode == .floating, view.safeAreaInsets.bottom > 0 {
value += Constants.minMapSpaceWithHomeIndicator
} else if mode == .floating {
value += Constants.minMapSpace
if mode == .floating {
let bottomMinSpace = view.safeAreaInsets.bottom > 0 ? Constants.minMapSpaceWithHomeIndicator : Constants.minMapSpace
value += bottomMinSpace
}

return value
Expand Down

0 comments on commit b9d0f67

Please sign in to comment.