Skip to content

Commit

Permalink
Callback for top card if trait collection changes (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
nighthawk committed Jun 23, 2023
1 parent f4ef72f commit b96668e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/TGCardViewController/TGCardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ open class TGCardViewController: UIViewController {
// to landscape mode, the card will be in the extended state, which requires
// the card's contents to be scrollable. Hence, we reenable the scolling.
updateCardScrolling(allow: true, view: topCardView)

topCard?.traitCollectionDidChange(previousTraitCollection)
}

private func updateCardScrolling(allow: Bool, view: TGCardView?) {
Expand Down
8 changes: 8 additions & 0 deletions Sources/TGCardViewController/cards/TGCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ open class TGCard: UIResponder, TGPreferrableView {
viewIsVisible = false
}

/// Called when the card is the top card and the trait collection of the TGCardViewController change
///
/// Get the current/new trait collection by calling `controller?.traitCollection`.
///
/// - Parameter previousTraitCollection: Previous trait collection, if any
open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
}

/// Called when the card moved, potentially to a new position
///
/// - Parameters:
Expand Down

0 comments on commit b96668e

Please sign in to comment.