Skip to content

Commit 55d801a

Browse files
authoredMar 12, 2025
Refactor FXIOS-11595 [Tab tray UI experiment] Improvements to tab tray (#25268)
* Improvements * Adjust gradient
1 parent 6c871db commit 55d801a

File tree

4 files changed

+28
-36
lines changed

4 files changed

+28
-36
lines changed
 

‎firefox-ios/Client/Frontend/Browser/Tabs/LayoutManager/TabsSectionManager.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TabsSectionManager: FeatureFlaggable {
1111
static let cellAbsoluteHeight: CGFloat = 200
1212
static let experimentCellAbsoluteHeight: CGFloat = 220
1313
static let cardSpacing: CGFloat = 16
14-
static let experimentCardSpacing: CGFloat = 32
14+
static let experimentCardSpacing: CGFloat = 28
1515
static let standardInset: CGFloat = 18
1616
static let iPadInset: CGFloat = 50
1717
static let iPadTopSiteInset: CGFloat = 25

‎firefox-ios/Client/Frontend/Browser/Tabs/Views/ExperimentTabCell.swift

+19-33
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
1515
static let unselectedBorderWidth: CGFloat = 0.8
1616
static let cornerRadius: CGFloat = 16
1717
static let subviewDefaultPadding: CGFloat = 6.0
18-
static let faviconYOffset: CGFloat = 10.0
19-
static let faviconSize: CGFloat = 20
18+
static let faviconSize = CGSize(width: 16, height: 16)
19+
static let fallbackFaviconSize = CGSize(width: 24, height: 24)
2020
static let closeButtonSize: CGFloat = 32
2121
static let textBoxHeight: CGFloat = 32
2222
static let closeButtonEdgeInset = NSDirectionalEdgeInsets(top: 10,
@@ -26,10 +26,6 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
2626
static let closeButtonTop: CGFloat = 6
2727
static let closeButtonTrailing: CGFloat = 8
2828
static let tabViewFooterSpacing: CGFloat = 4
29-
30-
// Using the same sizes for fallback favicon as the top sites on the homepage
31-
static let imageBackgroundSize = TopSiteItemCell.UX.imageBackgroundSize
32-
static let topSiteIconSize = TopSiteItemCell.UX.iconSize
3329
}
3430
// MARK: - Properties
3531

@@ -39,7 +35,10 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
3935
var animator: SwipeAnimator?
4036
weak var delegate: TabCellDelegate?
4137

42-
private lazy var smallFaviconView: FaviconImageView = .build()
38+
private lazy var smallFaviconView: FaviconImageView = .build { view in
39+
view.isHidden = true
40+
}
41+
4342
private lazy var favicon: FaviconImageView = .build()
4443

4544
// MARK: - UI
@@ -59,22 +58,14 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
5958
view.clipsToBounds = true
6059
}
6160

62-
private lazy var faviconBG: UIView = .build { view in
63-
view.layer.cornerRadius = HomepageViewModel.UX.generalCornerRadius
64-
view.layer.borderWidth = HomepageViewModel.UX.generalBorderWidth
65-
view.layer.shadowOffset = HomepageViewModel.UX.shadowOffset
66-
view.layer.shadowRadius = HomepageViewModel.UX.shadowRadius
67-
view.isHidden = true
68-
}
69-
7061
private lazy var screenshotView: UIImageView = .build { view in
7162
view.contentMode = .scaleAspectFill
7263
view.clipsToBounds = true
7364
}
7465

7566
private lazy var titleText: UILabel = .build { label in
7667
label.numberOfLines = 1
77-
label.font = FXFontStyles.Regular.caption1.scaledFont()
68+
label.font = FXFontStyles.Regular.footnote.scaledFont()
7869
label.adjustsFontForContentSizeCategory = true
7970
label.isAccessibilityElement = false
8071
}
@@ -95,7 +86,8 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
9586

9687
override func layoutSubviews() {
9788
super.layoutSubviews()
98-
favicon.layer.cornerRadius = UX.faviconSize / 2
89+
favicon.layer.cornerRadius = UX.faviconSize.height / 2
90+
smallFaviconView.layer.cornerRadius = UX.fallbackFaviconSize.height / 2
9991
}
10092

10193
// MARK: - Initializer
@@ -112,8 +104,7 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
112104
footerView.addArrangedSubview(favicon)
113105
footerView.addArrangedSubview(titleText)
114106

115-
faviconBG.addSubview(smallFaviconView)
116-
backgroundHolder.addSubviews(screenshotView, faviconBG, closeButton)
107+
backgroundHolder.addSubviews(screenshotView, smallFaviconView, closeButton)
117108

118109
accessibilityCustomActions = [
119110
UIAccessibilityCustomAction(name: .TabTrayCloseAccessibilityCustomAction,
@@ -201,14 +192,14 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
201192
named: StandardImageIdentifiers.Large.globe
202193
)?.withRenderingMode(.alwaysTemplate)
203194
smallFaviconView.manuallySetImage(defaultImage ?? UIImage())
204-
faviconBG.isHidden = false
195+
smallFaviconView.isHidden = false
205196
screenshotView.image = nil
206197
} else if let tabScreenshot = tabModel.screenshot {
207198
// Use Tab screenshot when available
208199
screenshotView.image = tabScreenshot
209200
} else {
210201
// Favicon or letter image when tab screenshot isn't available
211-
faviconBG.isHidden = false
202+
smallFaviconView.isHidden = false
212203
screenshotView.image = nil
213204

214205
if let tabURL = tabModel.url?.absoluteString {
@@ -243,7 +234,7 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
243234
screenshotView.image = nil
244235
backgroundHolder.transform = .identity
245236
backgroundHolder.alpha = 1
246-
faviconBG.isHidden = true
237+
smallFaviconView.isHidden = true
247238
layer.shadowOffset = .zero
248239
layer.shadowPath = nil
249240
layer.shadowOpacity = 0
@@ -265,8 +256,8 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
265256
footerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
266257
footerView.trailingAnchor.constraint(lessThanOrEqualTo: contentView.trailingAnchor),
267258

268-
favicon.heightAnchor.constraint(equalToConstant: UX.faviconSize),
269-
favicon.widthAnchor.constraint(equalToConstant: UX.faviconSize),
259+
favicon.heightAnchor.constraint(equalToConstant: UX.faviconSize.height),
260+
favicon.widthAnchor.constraint(equalToConstant: UX.faviconSize.width),
270261

271262
closeButton.heightAnchor.constraint(equalToConstant: UX.closeButtonSize),
272263
closeButton.widthAnchor.constraint(equalToConstant: UX.closeButtonSize),
@@ -281,15 +272,10 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
281272
screenshotView.trailingAnchor.constraint(equalTo: backgroundHolder.trailingAnchor),
282273
screenshotView.bottomAnchor.constraint(equalTo: backgroundHolder.bottomAnchor),
283274

284-
faviconBG.centerYAnchor.constraint(equalTo: backgroundHolder.centerYAnchor, constant: UX.faviconYOffset),
285-
faviconBG.centerXAnchor.constraint(equalTo: backgroundHolder.centerXAnchor),
286-
faviconBG.heightAnchor.constraint(equalToConstant: UX.imageBackgroundSize.height),
287-
faviconBG.widthAnchor.constraint(equalToConstant: UX.imageBackgroundSize.width),
288-
289-
smallFaviconView.heightAnchor.constraint(equalToConstant: UX.topSiteIconSize.height),
290-
smallFaviconView.widthAnchor.constraint(equalToConstant: UX.topSiteIconSize.width),
291-
smallFaviconView.centerYAnchor.constraint(equalTo: faviconBG.centerYAnchor),
292-
smallFaviconView.centerXAnchor.constraint(equalTo: faviconBG.centerXAnchor),
275+
smallFaviconView.heightAnchor.constraint(equalToConstant: UX.fallbackFaviconSize.height),
276+
smallFaviconView.widthAnchor.constraint(equalToConstant: UX.fallbackFaviconSize.width),
277+
smallFaviconView.centerYAnchor.constraint(equalTo: backgroundHolder.centerYAnchor),
278+
smallFaviconView.centerXAnchor.constraint(equalTo: backgroundHolder.centerXAnchor),
293279
])
294280
}
295281

‎firefox-ios/Client/Frontend/Browser/Tabs/Views/TabDisplayPanelViewController.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class TabDisplayPanelViewController: UIViewController,
131131
])
132132

133133
if isTabTrayUIExperimentsEnabled, !tabsState.isPrivateTabsEmpty, isCompactLayout {
134-
gradientLayer.locations = [0.0, 0.1]
134+
gradientLayer.locations = [0.0, 0.02, 0.08, 0.12]
135135
fadeView.layer.addSublayer(gradientLayer)
136136
view.addSubview(fadeView)
137137

@@ -181,6 +181,8 @@ class TabDisplayPanelViewController: UIViewController,
181181
if isTabTrayUIExperimentsEnabled {
182182
gradientLayer.colors = [
183183
currentTheme().colors.layer1.cgColor,
184+
currentTheme().colors.layer1.cgColor,
185+
currentTheme().colors.layer1.withAlphaComponent(0.95).cgColor,
184186
currentTheme().colors.layer1.withAlphaComponent(0.0).cgColor
185187
]
186188
}

‎firefox-ios/Client/Frontend/Browser/Tabs/Views/TabDisplayView.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,11 @@ class TabDisplayView: UIView,
277277

278278
func applyTheme(theme: Theme) {
279279
self.theme = theme
280-
collectionView.backgroundColor = theme.colors.layer3
280+
if isTabTrayUIExperimentsEnabled {
281+
collectionView.backgroundColor = theme.colors.layer1
282+
} else {
283+
collectionView.backgroundColor = theme.colors.layer3
284+
}
281285
}
282286

283287
private func getSection(for sectionIndex: Int) -> TabDisplayViewSection {

0 commit comments

Comments
 (0)
Failed to load comments.