From 0daa429aee2fae1d179f36b1014dee7f81ae9584 Mon Sep 17 00:00:00 2001 From: Juan Manuel Pereira Date: Wed, 21 Feb 2024 19:16:07 -0300 Subject: [PATCH] Fix constraints muted tab compressed --- DuckDuckGo/TabBar/View/TabBarViewItem.swift | 16 ++++++++++++---- DuckDuckGo/TabBar/View/TabBarViewItem.xib | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/DuckDuckGo/TabBar/View/TabBarViewItem.swift b/DuckDuckGo/TabBar/View/TabBarViewItem.swift index 6f0af9ecc6..266bfacd21 100644 --- a/DuckDuckGo/TabBar/View/TabBarViewItem.swift +++ b/DuckDuckGo/TabBar/View/TabBarViewItem.swift @@ -55,7 +55,6 @@ final class TabBarViewItem: NSCollectionViewItem { enum Constants { static let textFieldPadding: CGFloat = 28 static let textFieldPaddingNoFavicon: CGFloat = 12 - static let textFieldPaddingMuteIconPresent: CGFloat = 48 } var widthStage: WidthStage { @@ -97,6 +96,7 @@ final class TabBarViewItem: NSCollectionViewItem { @IBOutlet weak var titleTextField: NSTextField! @IBOutlet weak var titleTextFieldLeadingConstraint: NSLayoutConstraint! + @IBOutlet weak var titleTextFieldLeadingMuteConstraint: NSLayoutConstraint! @IBOutlet weak var closeButton: MouseOverButton! @IBOutlet weak var rightSeparatorView: ColorView! @IBOutlet weak var mouseOverView: MouseOverView! @@ -455,10 +455,18 @@ final class TabBarViewItem: NSCollectionViewItem { } private func setupMutedTabIconPosition() { - if !mutedTabIcon.isHidden { - titleTextFieldLeadingConstraint.constant = Constants.textFieldPaddingMuteIconPresent - } else { + if mutedTabIcon.isHidden { + titleTextFieldLeadingConstraint.priority = .defaultHigh + titleTextFieldLeadingMuteConstraint.priority = .defaultLow titleTextFieldLeadingConstraint.constant = faviconWrapperView.isHidden ? Constants.textFieldPaddingNoFavicon : Constants.textFieldPadding + } else { + if titleTextField.isHidden { + titleTextFieldLeadingMuteConstraint.priority = .defaultLow + titleTextFieldLeadingConstraint.priority = .defaultLow + } else { + titleTextFieldLeadingMuteConstraint.priority = .required + titleTextFieldLeadingConstraint.priority = .defaultLow + } } } } diff --git a/DuckDuckGo/TabBar/View/TabBarViewItem.xib b/DuckDuckGo/TabBar/View/TabBarViewItem.xib index a3c41007b8..3bcb22a67b 100644 --- a/DuckDuckGo/TabBar/View/TabBarViewItem.xib +++ b/DuckDuckGo/TabBar/View/TabBarViewItem.xib @@ -148,6 +148,7 @@ + @@ -176,6 +177,7 @@ +