Skip to content

Commit

Permalink
Fix for notifying cards other than top when having more than one init…
Browse files Browse the repository at this point in the history
…ial card
  • Loading branch information
nighthawk committed Mar 4, 2023
1 parent 5f7676a commit c4585f9
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 @@ -483,7 +483,7 @@ open class TGCardViewController: UIViewController {
if view.superview != nil, !mapView.frame.isEmpty {
if !didAddInitialCards {
didAddInitialCards = true
initialCards.forEach { push($0, animated: false) }
initialCards.forEach { push($0, animated: false, allowToNotify: $0 == initialCards.last, completionHandler: nil) }
}

fixPositioning()
Expand Down Expand Up @@ -733,6 +733,15 @@ extension TGCardViewController {
animated: Bool = true,
copyStyle: Bool = true,
completionHandler: (() -> Void)? = nil
) {
push(top, animated: animated, copyStyle: copyStyle, allowToNotify: true, completionHandler: completionHandler)
}

private func push(_ top: TGCard,
animated: Bool,
copyStyle: Bool = true,
allowToNotify: Bool,
completionHandler: (() -> Void)?
) {
guard isViewLoaded else {
return assertionFailure("Tried to push before view was loaded")
Expand All @@ -750,7 +759,7 @@ extension TGCardViewController {
// 2. Updating card logic and informing of transition
let oldTop = cardWithView(atIndex: cards.count - 1)
let oldShadowFrame = cardWrapperShadow.frame
let notify = isVisible
let notify = isVisible && allowToNotify
if notify {
oldTop?.card.willDisappear(animated: animated)
}
Expand Down

0 comments on commit c4585f9

Please sign in to comment.