Skip to content

Commit b96668e

Browse files
authored
Callback for top card if trait collection changes (#18)
1 parent f4ef72f commit b96668e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Sources/TGCardViewController/TGCardViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ open class TGCardViewController: UIViewController {
470470
// to landscape mode, the card will be in the extended state, which requires
471471
// the card's contents to be scrollable. Hence, we reenable the scolling.
472472
updateCardScrolling(allow: true, view: topCardView)
473+
474+
topCard?.traitCollectionDidChange(previousTraitCollection)
473475
}
474476

475477
private func updateCardScrolling(allow: Bool, view: TGCardView?) {

Sources/TGCardViewController/cards/TGCard.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,14 @@ open class TGCard: UIResponder, TGPreferrableView {
270270
viewIsVisible = false
271271
}
272272

273+
/// Called when the card is the top card and the trait collection of the TGCardViewController change
274+
///
275+
/// Get the current/new trait collection by calling `controller?.traitCollection`.
276+
///
277+
/// - Parameter previousTraitCollection: Previous trait collection, if any
278+
open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
279+
}
280+
273281
/// Called when the card moved, potentially to a new position
274282
///
275283
/// - Parameters:

0 commit comments

Comments
 (0)