Skip to content

Commit

Permalink
Fixed favicon position on normal tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaemepereira committed Feb 20, 2024
1 parent f14e026 commit dba7113
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
22 changes: 11 additions & 11 deletions DuckDuckGo/TabBar/View/TabBarViewItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ final class TabBarViewItem: NSCollectionViewItem {
static let textFieldPadding: CGFloat = 28
static let textFieldPaddingNoFavicon: CGFloat = 12
static let textFieldPaddingMuteIconPresent: CGFloat = 48
static let faviconLeadingPadding: CGFloat = 4
static let faviconLeadingPaddingMuteIconPresent: CGFloat = 6
// static let faviconLeadingPadding: CGFloat = 7
// static let faviconLeadingPaddingMuteIconPresent: CGFloat = 7
}

var widthStage: WidthStage {
Expand Down Expand Up @@ -353,20 +353,19 @@ final class TabBarViewItem: NSCollectionViewItem {
updateSeparatorView()
permissionCloseButtonTrailingConstraint.isActive = !closeButton.isHidden
titleTextField.isHidden = widthStage.isTitleHidden && faviconImageView.image != nil
// faviconWrapperViewLeadingConstraint.constant = Constants.faviconLeadingPadding

if mutedTabIcon.isHidden {
faviconWrapperViewCenterConstraint.priority = titleTextField.isHidden ? .defaultHigh : .defaultLow
faviconWrapperViewLeadingConstraint.priority = titleTextField.isHidden ? .defaultLow : .defaultHigh
} else {
// When the mute icon is visible and the tab is compressed we need to center both
faviconWrapperViewCenterConstraint.priority = .defaultLow
faviconWrapperViewLeadingConstraint.priority = .defaultHigh

if titleTextField.isHidden { // If the title text is hidden it means the tab is compressed
faviconWrapperViewLeadingConstraint.constant = Constants.faviconLeadingPaddingMuteIconPresent
} else {
faviconWrapperViewLeadingConstraint.constant = Constants.faviconLeadingPadding
}
// faviconWrapperViewCenterConstraint.priority = .defaultLow
// faviconWrapperViewLeadingConstraint.priority = .defaultHigh
//
// if titleTextField.isHidden { // If the title text is hidden it means the tab is compressed
// faviconWrapperViewLeadingConstraint.constant = Constants.faviconLeadingPaddingMuteIconPresent
// }
}

updateBorderLayerColor()
Expand Down Expand Up @@ -440,6 +439,7 @@ final class TabBarViewItem: NSCollectionViewItem {
faviconWrapperView.isHidden = favicon == nil
titleTextFieldLeadingConstraint.constant = faviconWrapperView.isHidden ? Constants.textFieldPaddingNoFavicon : Constants.textFieldPadding
faviconImageView.image = favicon
faviconImageView.imageScaling = .scaleProportionallyDown
}

private func setupMuteOrUnmutedIcon() {
Expand Down Expand Up @@ -616,7 +616,7 @@ extension TabBarViewItem {
}

enum Width: CGFloat {
case minimum = 56
case minimum = 50
case minimumSelected = 120
case maximum = 240
}
Expand Down
24 changes: 12 additions & 12 deletions DuckDuckGo/TabBar/View/TabBarViewItem.xib
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY" userLabel="Tab Bar View Item">
<rect key="frame" x="0.0" y="0.0" width="300" height="34"/>
<rect key="frame" x="0.0" y="0.0" width="300" height="36"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<imageView hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Dwg-SU-uiu" userLabel="Muted Tab Icon">
Expand All @@ -23,15 +23,15 @@
<color key="contentTintColor" red="0.0" green="0.0" blue="0.0" alpha="0.83999999999999997" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="jlg-2n-tzm" customClass="MouseOverView" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="0.0" y="1" width="300" height="33"/>
<rect key="frame" x="0.0" y="1" width="300" height="35"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="mouseOverColor">
<color key="value" name="TabMouseOverColor"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</customView>
<textField wantsLayer="YES" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="DFD-8r-YGx" userLabel="Title Text Field">
<rect key="frame" x="30" y="9" width="264" height="16"/>
<rect key="frame" x="30" y="10" width="264" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="vWW-sG-CAf"/>
</constraints>
Expand All @@ -42,10 +42,10 @@
</textFieldCell>
</textField>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="A6g-eG-dOW">
<rect key="frame" x="5" y="5" width="24" height="24"/>
<rect key="frame" x="5" y="6" width="24" height="24"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Kky-kZ-lU9" userLabel="Favicon Image View">
<rect key="frame" x="4" y="5" width="16" height="16"/>
<rect key="frame" x="4" y="4" width="16" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="16" id="UYc-rf-9hh"/>
<constraint firstAttribute="height" constant="16" id="ey5-m5-Uxp"/>
Expand All @@ -57,11 +57,11 @@
<constraint firstAttribute="height" constant="24" id="JIG-o6-vrA"/>
<constraint firstAttribute="width" constant="24" id="b6u-P2-tfb"/>
<constraint firstItem="Kky-kZ-lU9" firstAttribute="centerX" secondItem="A6g-eG-dOW" secondAttribute="centerX" id="sh1-7s-uE8"/>
<constraint firstItem="Kky-kZ-lU9" firstAttribute="top" secondItem="A6g-eG-dOW" secondAttribute="top" constant="3" id="zDL-E0-5JQ"/>
<constraint firstItem="Kky-kZ-lU9" firstAttribute="centerY" secondItem="A6g-eG-dOW" secondAttribute="centerY" id="zKn-Ex-Yor"/>
</constraints>
</customView>
<button translatesAutoresizingMaskIntoConstraints="NO" id="XdB-Qn-iD9" userLabel="Active Permission" customClass="MouseOverButton" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="255" y="9" width="16" height="16"/>
<rect key="frame" x="255" y="10" width="16" height="16"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="Camera-Tab-Active" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="8II-A1-ote">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -87,7 +87,7 @@
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="vuD-rY-Vzl" userLabel="Close Button" customClass="MouseOverButton" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="275" y="8" width="16" height="16"/>
<rect key="frame" x="275" y="10" width="16" height="16"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="Close" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="ykX-aF-551">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -113,7 +113,7 @@
</connections>
</button>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="opQ-Od-dCO" userLabel="Right Separator View" customClass="ColorView" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="299" y="7" width="1" height="20"/>
<rect key="frame" x="299" y="8" width="1" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="VIX-I9-y80"/>
<constraint firstAttribute="height" constant="20" id="kbX-vZ-Ybs"/>
Expand All @@ -125,14 +125,15 @@
</userDefinedRuntimeAttributes>
</customView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="890-3t-v5O" userLabel="Mouse Click View" customClass="MouseOverView" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="300" height="34"/>
<rect key="frame" x="0.0" y="0.0" width="300" height="36"/>
<connections>
<outlet property="delegate" destination="4MN-w4-aCk" id="Fnb-31-k2v"/>
</connections>
</customView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="jlg-2n-tzm" secondAttribute="trailing" id="0eL-gX-odc"/>
<constraint firstItem="vuD-rY-Vzl" firstAttribute="centerY" secondItem="Hz6-mo-xeY" secondAttribute="centerY" id="1O2-c9-rXM"/>
<constraint firstItem="DFD-8r-YGx" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="32" id="4P8-mH-XGb"/>
<constraint firstItem="Dwg-SU-uiu" firstAttribute="top" secondItem="Kky-kZ-lU9" secondAttribute="top" id="4Se-Lc-LhL"/>
<constraint firstItem="XdB-Qn-iD9" firstAttribute="centerY" secondItem="Hz6-mo-xeY" secondAttribute="centerY" id="6wl-2B-Woa"/>
Expand All @@ -144,7 +145,6 @@
<constraint firstAttribute="trailing" secondItem="DFD-8r-YGx" secondAttribute="trailing" constant="8" id="L7J-mr-jLh"/>
<constraint firstAttribute="bottom" secondItem="890-3t-v5O" secondAttribute="bottom" id="N7I-JC-tT1"/>
<constraint firstItem="A6g-eG-dOW" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" priority="250" id="PF1-mZ-U4m"/>
<constraint firstAttribute="bottom" secondItem="vuD-rY-Vzl" secondAttribute="bottom" constant="8" id="Pgs-Ex-Cp9"/>
<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"/>
Expand All @@ -158,7 +158,7 @@
<constraint firstAttribute="bottom" secondItem="jlg-2n-tzm" secondAttribute="bottom" constant="1" id="vcb-oV-uSI"/>
<constraint firstAttribute="trailing" secondItem="vuD-rY-Vzl" secondAttribute="trailing" constant="9" id="web-9k-BYT"/>
</constraints>
<point key="canvasLocation" x="-61" y="120.5"/>
<point key="canvasLocation" x="-61" y="120"/>
</customView>
<collectionViewItem id="4MN-w4-aCk" customClass="TabBarViewItem" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<connections>
Expand Down

0 comments on commit dba7113

Please sign in to comment.