Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback for top card if trait collection changes #18

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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