Skip to content

Commit d3fb479

Browse files
authoredMar 14, 2025
Refactor FXIOS-11611 [Tab tray UI experiment] Adjust tab thumbnail for dynamic type (#25331)
* Cell height was absolute for tab content + ensure it scales * Revert minor changes not needed
1 parent 05909ff commit d3fb479

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed
 

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

+17-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TabsSectionManager: FeatureFlaggable {
99
// On iPad we can set to have bigger tabs, on iPhone we need smaller ones
1010
static let cellEstimatedWidth: CGFloat = UIDevice.current.userInterfaceIdiom == .pad ? 250 : 170
1111
static let cellAbsoluteHeight: CGFloat = 200
12-
static let experimentCellAbsoluteHeight: CGFloat = 220
12+
static let experimentCellEstimatedHeight: CGFloat = 220
1313
static let cardSpacing: CGFloat = 16
1414
static let experimentCardSpacing: CGFloat = 28
1515
static let standardInset: CGFloat = 18
@@ -41,13 +41,23 @@ class TabsSectionManager: FeatureFlaggable {
4141
? minNumberOfCellsPerRow
4242
: maxNumberOfCellsPerRow
4343

44-
let cellHeight = isTabTrayUIExperimentsEnabled ? UX.experimentCellAbsoluteHeight : UX.cellAbsoluteHeight
45-
let itemSize = NSCollectionLayoutSize(
46-
widthDimension: .estimated(UX.cellEstimatedWidth),
47-
heightDimension: .absolute(cellHeight)
48-
)
49-
let item = NSCollectionLayoutItem(layoutSize: itemSize)
44+
let itemSize: NSCollectionLayoutSize
45+
let cellHeight: CGFloat
46+
if isTabTrayUIExperimentsEnabled {
47+
cellHeight = UX.experimentCellEstimatedHeight
48+
itemSize = NSCollectionLayoutSize(
49+
widthDimension: .estimated(UX.cellEstimatedWidth),
50+
heightDimension: .estimated(cellHeight)
51+
)
52+
} else {
53+
cellHeight = UX.cellAbsoluteHeight
54+
itemSize = NSCollectionLayoutSize(
55+
widthDimension: .estimated(UX.cellEstimatedWidth),
56+
heightDimension: .absolute(cellHeight)
57+
)
58+
}
5059

60+
let item = NSCollectionLayoutItem(layoutSize: itemSize)
5161
let groupSize = NSCollectionLayoutSize(
5262
widthDimension: .fractionalWidth(1),
5363
heightDimension: .estimated(cellHeight)

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

+16-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
2929
static let shadowRadius: CGFloat = 4
3030
static let shadowOffset = CGSize(width: 0, height: 2)
3131
static let shadowOpacity: Float = 1
32+
static let thumbnailScreenshotHeight: CGFloat = 200
3233
}
3334
// MARK: - Properties
3435

@@ -43,6 +44,7 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
4344
}
4445

4546
private lazy var favicon: FaviconImageView = .build()
47+
private lazy var faviconContainer: UIView = .build()
4648

4749
// MARK: - UI
4850

@@ -53,6 +55,8 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
5355
stackView.alignment = .fill
5456
stackView.spacing = UX.tabViewFooterSpacing
5557
stackView.backgroundColor = .clear
58+
stackView.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
59+
stackView.setContentHuggingPriority(.defaultHigh, for: .vertical)
5660
}
5761

5862
private lazy var backgroundHolder: UIView = .build { view in
@@ -71,6 +75,8 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
7175
label.font = FXFontStyles.Regular.footnote.scaledFont()
7276
label.adjustsFontForContentSizeCategory = true
7377
label.isAccessibilityElement = false
78+
label.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
79+
label.setContentHuggingPriority(.defaultHigh, for: .vertical)
7480
}
7581

7682
private lazy var closeButton: UIButton = .build { button in
@@ -110,8 +116,9 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
110116
contentView.addSubview(backgroundHolder)
111117
contentView.addSubview(footerView)
112118

113-
footerView.addArrangedSubview(favicon)
119+
footerView.addArrangedSubview(faviconContainer)
114120
footerView.addArrangedSubview(titleText)
121+
faviconContainer.addSubview(favicon)
115122

116123
backgroundHolder.addSubviews(screenshotView, smallFaviconView, closeButton)
117124

@@ -263,16 +270,22 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
263270
backgroundHolder.topAnchor.constraint(equalTo: contentView.topAnchor),
264271
backgroundHolder.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
265272
backgroundHolder.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
266-
backgroundHolder.bottomAnchor.constraint(equalTo: footerView.topAnchor,
267-
constant: -UX.tabViewFooterSpacing),
273+
backgroundHolder.heightAnchor.constraint(equalToConstant: UX.thumbnailScreenshotHeight),
268274

275+
footerView.topAnchor.constraint(equalTo: backgroundHolder.bottomAnchor,
276+
constant: UX.tabViewFooterSpacing),
269277
footerView.leadingAnchor.constraint(greaterThanOrEqualTo: contentView.leadingAnchor),
270278
footerView.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
271279
footerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
272280
footerView.trailingAnchor.constraint(lessThanOrEqualTo: contentView.trailingAnchor),
273281

282+
faviconContainer.topAnchor.constraint(lessThanOrEqualTo: favicon.topAnchor),
283+
faviconContainer.bottomAnchor.constraint(greaterThanOrEqualTo: favicon.bottomAnchor),
284+
faviconContainer.leadingAnchor.constraint(equalTo: favicon.leadingAnchor),
285+
faviconContainer.trailingAnchor.constraint(equalTo: favicon.trailingAnchor),
274286
favicon.heightAnchor.constraint(equalToConstant: UX.faviconSize.height),
275287
favicon.widthAnchor.constraint(equalToConstant: UX.faviconSize.width),
288+
favicon.centerYAnchor.constraint(equalTo: titleText.centerYAnchor),
276289

277290
closeButton.heightAnchor.constraint(equalToConstant: UX.closeButtonSize),
278291
closeButton.widthAnchor.constraint(equalToConstant: UX.closeButtonSize),

0 commit comments

Comments
 (0)
Failed to load comments.