Skip to content

Commit

Permalink
Revert back bouncing normal tab
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaemepereira committed Feb 21, 2024
1 parent dba7113 commit 77d568e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo/PinnedTabs/View/PinnedTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import SwiftUIExtensions
struct PinnedTabView: View {
enum Const {
static let dimension: CGFloat = 34
static let cornerRadius: CGFloat = 8.5
static let cornerRadius: CGFloat = 8
}

@ObservedObject var model: Tab
Expand Down
7 changes: 4 additions & 3 deletions DuckDuckGo/TabBar/View/TabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -473,14 +473,14 @@ final class TabBarViewController: NSViewController {
return numberOfItems
}

private func currentTabWidth(selected: Bool = false, removedIndex: Int? = nil) -> CGFloat {
private func currentTabWidth(selected: Bool = false, isMuted: Bool = false, removedIndex: Int? = nil) -> CGFloat {
let numberOfItems = CGFloat(self.layoutNumberOfItems(removedIndex: removedIndex))
guard numberOfItems > 0 else {
return 0
}

let tabsWidth = scrollView.bounds.width - footerCurrentWidthDimension
let minimumWidth = selected ? TabBarViewItem.Width.minimumSelected.rawValue : TabBarViewItem.Width.minimum.rawValue
let minimumWidth = selected ? TabBarViewItem.Width.minimumSelected.rawValue : (isMuted ? TabBarViewItem.Width.minumumMuted.rawValue : TabBarViewItem.Width.minimum.rawValue)

if tabMode == .divided {
var dividedWidth = tabsWidth / numberOfItems
Expand Down Expand Up @@ -795,7 +795,8 @@ extension TabBarViewController: NSCollectionViewDelegateFlowLayout {

func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize {
let isItemSelected = tabCollectionViewModel.selectionIndex == .unpinned(indexPath.item)
return NSSize(width: self.currentTabWidth(selected: isItemSelected), height: TabBarViewItem.Height.standard.rawValue)
let isMuted = tabCollectionViewModel.tabCollection.tabs[indexPath.item].audioState == .muted
return NSSize(width: self.currentTabWidth(selected: isItemSelected, isMuted: isMuted), height: TabBarViewItem.Height.standard.rawValue)
}

}
Expand Down
28 changes: 15 additions & 13 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 = 7
// static let faviconLeadingPaddingMuteIconPresent: CGFloat = 7
static let faviconLeadingPadding: CGFloat = 5
static let faviconLeadingPaddingMuteIconPresent: CGFloat = 7
}

var widthStage: WidthStage {
Expand Down Expand Up @@ -278,7 +278,7 @@ final class TabBarViewItem: NSCollectionViewItem {
layer.borderWidth = TabShadowConfig.dividerSize
layer.opacity = TabShadowConfig.alpha
layer.maskedCorners = [.layerMaxXMaxYCorner, .layerMinXMaxYCorner]
layer.cornerRadius = 11
layer.cornerRadius = 7
layer.mask = layerMask
return layer
}()
Expand Down Expand Up @@ -330,7 +330,7 @@ final class TabBarViewItem: NSCollectionViewItem {

private func setupView() {
view.wantsLayer = true
view.layer?.cornerRadius = 11
view.layer?.cornerRadius = 7
view.layer?.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
view.layer?.masksToBounds = true
view.layer?.addSublayer(borderLayer)
Expand All @@ -353,19 +353,20 @@ 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
// }
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
}
}

updateBorderLayerColor()
Expand All @@ -378,7 +379,7 @@ final class TabBarViewItem: NSCollectionViewItem {

// Adjust colors for burner window
if isBurner && faviconImageView.image === TabViewModel.Favicon.burnerHome {
faviconImageView.contentTintColor = .textColor
faviconImageView.contentTintColor = .textColor
} else {
faviconImageView.contentTintColor = nil
}
Expand Down Expand Up @@ -612,11 +613,12 @@ extension TabBarViewItem: MouseClickViewDelegate {
extension TabBarViewItem {

enum Height: CGFloat {
case standard = 34
case standard = 32
}

enum Width: CGFloat {
case minimum = 50
case minumumMuted = 56
case minimumSelected = 120
case maximum = 240
}
Expand Down
18 changes: 9 additions & 9 deletions DuckDuckGo/TabBar/View/TabBarViewItem.xib
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<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="36"/>
<rect key="frame" x="0.0" y="0.0" width="300" height="32"/>
<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">
<rect key="frame" x="29" y="10" width="16" height="16"/>
<rect key="frame" x="29" y="8" width="16" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="ILs-aB-D7E"/>
<constraint firstAttribute="width" constant="16" id="Qyf-Aw-VnE"/>
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="35"/>
<rect key="frame" x="0.0" y="1" width="300" height="31"/>
<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="10" width="264" height="16"/>
<rect key="frame" x="30" y="8" width="264" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="vWW-sG-CAf"/>
</constraints>
Expand All @@ -42,7 +42,7 @@
</textFieldCell>
</textField>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="A6g-eG-dOW">
<rect key="frame" x="5" y="6" width="24" height="24"/>
<rect key="frame" x="5" y="4" 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="4" width="16" height="16"/>
Expand All @@ -61,7 +61,7 @@
</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="10" width="16" height="16"/>
<rect key="frame" x="255" y="8" 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="10" width="16" height="16"/>
<rect key="frame" x="275" y="8" 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="8" width="1" height="20"/>
<rect key="frame" x="299" y="6" 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,7 +125,7 @@
</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="36"/>
<rect key="frame" x="0.0" y="0.0" width="300" height="32"/>
<connections>
<outlet property="delegate" destination="4MN-w4-aCk" id="Fnb-31-k2v"/>
</connections>
Expand Down

0 comments on commit 77d568e

Please sign in to comment.