@@ -15,8 +15,8 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
15
15
static let unselectedBorderWidth : CGFloat = 0.8
16
16
static let cornerRadius : CGFloat = 16
17
17
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 )
20
20
static let closeButtonSize : CGFloat = 32
21
21
static let textBoxHeight : CGFloat = 32
22
22
static let closeButtonEdgeInset = NSDirectionalEdgeInsets ( top: 10 ,
@@ -26,10 +26,6 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
26
26
static let closeButtonTop : CGFloat = 6
27
27
static let closeButtonTrailing : CGFloat = 8
28
28
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
33
29
}
34
30
// MARK: - Properties
35
31
@@ -39,7 +35,10 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
39
35
var animator : SwipeAnimator ?
40
36
weak var delegate : TabCellDelegate ?
41
37
42
- private lazy var smallFaviconView : FaviconImageView = . build( )
38
+ private lazy var smallFaviconView : FaviconImageView = . build { view in
39
+ view. isHidden = true
40
+ }
41
+
43
42
private lazy var favicon : FaviconImageView = . build( )
44
43
45
44
// MARK: - UI
@@ -59,22 +58,14 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
59
58
view. clipsToBounds = true
60
59
}
61
60
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
-
70
61
private lazy var screenshotView : UIImageView = . build { view in
71
62
view. contentMode = . scaleAspectFill
72
63
view. clipsToBounds = true
73
64
}
74
65
75
66
private lazy var titleText : UILabel = . build { label in
76
67
label. numberOfLines = 1
77
- label. font = FXFontStyles . Regular. caption1 . scaledFont ( )
68
+ label. font = FXFontStyles . Regular. footnote . scaledFont ( )
78
69
label. adjustsFontForContentSizeCategory = true
79
70
label. isAccessibilityElement = false
80
71
}
@@ -95,7 +86,8 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
95
86
96
87
override func layoutSubviews( ) {
97
88
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
99
91
}
100
92
101
93
// MARK: - Initializer
@@ -112,8 +104,7 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
112
104
footerView. addArrangedSubview ( favicon)
113
105
footerView. addArrangedSubview ( titleText)
114
106
115
- faviconBG. addSubview ( smallFaviconView)
116
- backgroundHolder. addSubviews ( screenshotView, faviconBG, closeButton)
107
+ backgroundHolder. addSubviews ( screenshotView, smallFaviconView, closeButton)
117
108
118
109
accessibilityCustomActions = [
119
110
UIAccessibilityCustomAction ( name: . TabTrayCloseAccessibilityCustomAction,
@@ -201,14 +192,14 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
201
192
named: StandardImageIdentifiers . Large. globe
202
193
) ? . withRenderingMode ( . alwaysTemplate)
203
194
smallFaviconView. manuallySetImage ( defaultImage ?? UIImage ( ) )
204
- faviconBG . isHidden = false
195
+ smallFaviconView . isHidden = false
205
196
screenshotView. image = nil
206
197
} else if let tabScreenshot = tabModel. screenshot {
207
198
// Use Tab screenshot when available
208
199
screenshotView. image = tabScreenshot
209
200
} else {
210
201
// Favicon or letter image when tab screenshot isn't available
211
- faviconBG . isHidden = false
202
+ smallFaviconView . isHidden = false
212
203
screenshotView. image = nil
213
204
214
205
if let tabURL = tabModel. url? . absoluteString {
@@ -243,7 +234,7 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
243
234
screenshotView. image = nil
244
235
backgroundHolder. transform = . identity
245
236
backgroundHolder. alpha = 1
246
- faviconBG . isHidden = true
237
+ smallFaviconView . isHidden = true
247
238
layer. shadowOffset = . zero
248
239
layer. shadowPath = nil
249
240
layer. shadowOpacity = 0
@@ -265,8 +256,8 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
265
256
footerView. bottomAnchor. constraint ( equalTo: contentView. bottomAnchor) ,
266
257
footerView. trailingAnchor. constraint ( lessThanOrEqualTo: contentView. trailingAnchor) ,
267
258
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 ) ,
270
261
271
262
closeButton. heightAnchor. constraint ( equalToConstant: UX . closeButtonSize) ,
272
263
closeButton. widthAnchor. constraint ( equalToConstant: UX . closeButtonSize) ,
@@ -281,15 +272,10 @@ class ExperimentTabCell: UICollectionViewCell, ThemeApplicable, ReusableCell, Fe
281
272
screenshotView. trailingAnchor. constraint ( equalTo: backgroundHolder. trailingAnchor) ,
282
273
screenshotView. bottomAnchor. constraint ( equalTo: backgroundHolder. bottomAnchor) ,
283
274
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) ,
293
279
] )
294
280
}
295
281
0 commit comments