From 3a985657959967b36f2d36e6efadd1e529cf69b9 Mon Sep 17 00:00:00 2001 From: Adrian Schoenig Date: Fri, 9 Aug 2024 16:48:46 +1000 Subject: [PATCH] Fix issue where a page header accessory couldn't be tapped on the trailing side --- .../cards/TGPageHeaderView.swift | 15 ++++++++++++++- .../cards/TGPageHeaderView.xib | 15 +++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Sources/TGCardViewController/cards/TGPageHeaderView.swift b/Sources/TGCardViewController/cards/TGPageHeaderView.swift index 83a6e74..87136c9 100644 --- a/Sources/TGCardViewController/cards/TGPageHeaderView.swift +++ b/Sources/TGCardViewController/cards/TGPageHeaderView.swift @@ -13,6 +13,9 @@ public class TGPageHeaderView: TGHeaderView { @IBOutlet weak var accessoryWrapperView: UIView! @IBOutlet weak var accessoryWrapperHeightConstraint: NSLayoutConstraint! + @IBOutlet weak var accessoryTrailingConstraint: NSLayoutConstraint! + @IBOutlet weak var buttonTrailingConstraint: NSLayoutConstraint! + static func instantiate() -> TGPageHeaderView { guard let view = TGCardViewController.bundle.loadNibNamed("TGPageHeaderView", owner: nil, options: nil)!.first as? TGPageHeaderView @@ -68,7 +71,17 @@ public class TGPageHeaderView: TGHeaderView { var rightAction: (() -> Void)? { didSet { - rightButton?.isHidden = (rightAction == nil) + if rightAction != nil { + rightButton?.isHidden = false + accessoryTrailingConstraint.priority = .defaultLow + buttonTrailingConstraint.priority = .required + setNeedsUpdateConstraints() + } else { + rightButton?.isHidden = true + accessoryTrailingConstraint.priority = .required + buttonTrailingConstraint.priority = .defaultLow + setNeedsUpdateConstraints() + } } } diff --git a/Sources/TGCardViewController/cards/TGPageHeaderView.xib b/Sources/TGCardViewController/cards/TGPageHeaderView.xib index 145ccf6..0652e1d 100644 --- a/Sources/TGCardViewController/cards/TGPageHeaderView.xib +++ b/Sources/TGCardViewController/cards/TGPageHeaderView.xib @@ -1,9 +1,9 @@ - + - + @@ -14,14 +14,14 @@ - + -