Skip to content

Commit

Permalink
Fix constraints muted tab compressed
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaemepereira committed Feb 22, 2024
1 parent 56b0b45 commit 0daa429
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions DuckDuckGo/TabBar/View/TabBarViewItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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!
Expand Down Expand Up @@ -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
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/TabBar/View/TabBarViewItem.xib
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<constraint firstItem="A6g-eG-dOW" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="5" id="TSx-41-S2A"/>
<constraint firstAttribute="trailing" secondItem="opQ-Od-dCO" secondAttribute="trailing" id="WPC-fb-K22"/>
<constraint firstItem="A6g-eG-dOW" firstAttribute="centerY" secondItem="Hz6-mo-xeY" secondAttribute="centerY" id="aQg-CK-diJ"/>
<constraint firstItem="DFD-8r-YGx" firstAttribute="leading" secondItem="Dwg-SU-uiu" secondAttribute="trailing" priority="250" constant="4" id="cnx-Mc-8eH"/>
<constraint firstItem="890-3t-v5O" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="giH-0s-4s4"/>
<constraint firstItem="Dwg-SU-uiu" firstAttribute="leading" secondItem="A6g-eG-dOW" secondAttribute="trailing" id="h0G-ek-exQ"/>
<constraint firstItem="vuD-rY-Vzl" firstAttribute="leading" secondItem="XdB-Qn-iD9" secondAttribute="trailing" constant="4" id="lqC-R5-KOi"/>
Expand Down Expand Up @@ -176,6 +177,7 @@
<outlet property="tabLoadingPermissionLeadingConstraint" destination="uNR-JN-6RT" id="r7F-38-4Nx"/>
<outlet property="titleTextField" destination="DFD-8r-YGx" id="6mj-b0-Oq3"/>
<outlet property="titleTextFieldLeadingConstraint" destination="4P8-mH-XGb" id="mKz-Wl-mQJ"/>
<outlet property="titleTextFieldLeadingMuteConstraint" destination="cnx-Mc-8eH" id="UFf-Vr-1qH"/>
<outlet property="view" destination="Hz6-mo-xeY" id="DwG-v1-cn3"/>
</connections>
</collectionViewItem>
Expand Down

0 comments on commit 0daa429

Please sign in to comment.