@@ -6,25 +6,36 @@ import Common
66import Foundation
77import SiteImageView
88
9+ @MainActor
10+ protocol BookmarksCellProtocol : ReusableCell where Self: UIView {
11+ func configure( config: BookmarkConfiguration , theme: Theme )
12+ }
13+
914/// A cell used in homepage's Bookmarks section.
10- final class BookmarksCell : UICollectionViewCell , ReusableCell , ThemeApplicable , Blurrable {
15+ final class BookmarksCell : UICollectionViewCell , BookmarksCellProtocol , ThemeApplicable , Blurrable {
1116 private struct UX {
12- static let containerSpacing : CGFloat = 16
13- static let heroImageSize = CGSize ( width: 126 , height: 82 )
17+ static let containerSpacing : CGFloat = 4
18+ static let heroImageSize = CGSize ( width: 126 , height: 68 )
1419 static let generalSpacing : CGFloat = 8
20+ static let contentSpacing : CGFloat = 4
21+ static let generalCornerRadius : CGFloat = 16
22+ static let heroImageCornerRadius : CGFloat = 13
1523 }
1624
1725 // MARK: - UI Elements
1826 private var rootContainer : UIView = . build { view in
1927 view. backgroundColor = . clear
20- view. layer. cornerRadius = HomepageUX . generalCornerRadius
28+ view. layer. cornerRadius = UX . generalCornerRadius
2129 }
2230
2331 private var heroImageView : HeroImageView = . build { _ in }
2432
33+ let titleContainer : UIView = . build( )
34+
2535 let itemTitle : UILabel = . build { label in
2636 label. font = FXFontStyles . Regular. caption1. scaledFont ( )
2737 label. adjustsFontForContentSizeCategory = true
38+ label. numberOfLines = 2
2839 }
2940
3041 // MARK: - Inits
@@ -49,14 +60,15 @@ final class BookmarksCell: UICollectionViewCell, ReusableCell, ThemeApplicable,
4960
5061 override func layoutSubviews( ) {
5162 super. layoutSubviews ( )
52- rootContainer . layer. shadowPath = UIBezierPath (
53- roundedRect: rootContainer . bounds,
54- cornerRadius: HomepageUX . generalCornerRadius) . cgPath
63+ contentView . layer. shadowPath = UIBezierPath (
64+ roundedRect: contentView . bounds,
65+ cornerRadius: UX . generalCornerRadius) . cgPath
5566 }
5667
5768 func configure( config: BookmarkConfiguration , theme: Theme ) {
5869 let heroImageViewModel = HomepageHeroImageViewModel (
5970 urlStringRequest: config. site. url,
71+ generalCornerRadius: UX . heroImageCornerRadius,
6072 heroImageSize: UX . heroImageSize
6173 )
6274 heroImageView. setHeroImage ( heroImageViewModel)
@@ -69,7 +81,8 @@ final class BookmarksCell: UICollectionViewCell, ReusableCell, ThemeApplicable,
6981
7082 private func setupLayout( ) {
7183 contentView. backgroundColor = . clear
72- rootContainer. addSubviews ( heroImageView, itemTitle)
84+ titleContainer. addSubview ( itemTitle)
85+ rootContainer. addSubviews ( heroImageView, titleContainer)
7386 contentView. addSubview ( rootContainer)
7487
7588 NSLayoutConstraint . activate ( [
@@ -78,32 +91,32 @@ final class BookmarksCell: UICollectionViewCell, ReusableCell, ThemeApplicable,
7891 rootContainer. trailingAnchor. constraint ( equalTo: contentView. trailingAnchor) ,
7992 rootContainer. bottomAnchor. constraint ( equalTo: contentView. bottomAnchor) ,
8093
81- heroImageView. topAnchor. constraint ( equalTo: rootContainer. topAnchor,
82- constant: UX . containerSpacing) ,
83- heroImageView. leadingAnchor. constraint ( equalTo: rootContainer. leadingAnchor,
84- constant: UX . containerSpacing) ,
85- heroImageView. trailingAnchor. constraint ( equalTo: rootContainer. trailingAnchor,
86- constant: - UX. containerSpacing) ,
94+ heroImageView. topAnchor. constraint ( equalTo: rootContainer. topAnchor, constant: UX . containerSpacing) ,
95+ heroImageView. leadingAnchor. constraint ( equalTo: rootContainer. leadingAnchor, constant: UX . containerSpacing) ,
96+ heroImageView. trailingAnchor. constraint ( equalTo: rootContainer. trailingAnchor, constant: - UX. containerSpacing) ,
8797 heroImageView. heightAnchor. constraint ( equalToConstant: UX . heroImageSize. height) ,
8898 heroImageView. widthAnchor. constraint ( equalToConstant: UX . heroImageSize. width) ,
8999
90- itemTitle. topAnchor. constraint ( equalTo: heroImageView. bottomAnchor,
91- constant: UX . generalSpacing) ,
92- itemTitle. leadingAnchor. constraint ( equalTo: heroImageView. leadingAnchor) ,
93- itemTitle. trailingAnchor. constraint ( equalTo: heroImageView. trailingAnchor) ,
94- itemTitle. bottomAnchor. constraint ( equalTo: rootContainer. bottomAnchor,
95- constant: - UX. generalSpacing) ,
100+ titleContainer. topAnchor. constraint ( equalTo: heroImageView. bottomAnchor, constant: UX . contentSpacing) ,
101+ titleContainer. leadingAnchor. constraint ( equalTo: rootContainer. leadingAnchor, constant: UX . generalSpacing) ,
102+ titleContainer. trailingAnchor. constraint ( equalTo: rootContainer. trailingAnchor, constant: - UX. generalSpacing) ,
103+ titleContainer. bottomAnchor. constraint ( equalTo: rootContainer. bottomAnchor, constant: - UX. generalSpacing) ,
104+
105+ itemTitle. topAnchor. constraint ( equalTo: titleContainer. topAnchor) ,
106+ itemTitle. leadingAnchor. constraint ( equalTo: titleContainer. leadingAnchor) ,
107+ itemTitle. trailingAnchor. constraint ( equalTo: titleContainer. trailingAnchor) ,
108+ itemTitle. bottomAnchor. constraint ( lessThanOrEqualTo: titleContainer. bottomAnchor)
96109 ] )
97110 }
98111
99112 private func setupShadow( theme: Theme ) {
100- rootContainer . layer. shadowPath = UIBezierPath ( roundedRect: rootContainer . bounds,
101- cornerRadius: HomepageUX . generalCornerRadius) . cgPath
113+ contentView . layer. shadowPath = UIBezierPath ( roundedRect: contentView . bounds,
114+ cornerRadius: UX . generalCornerRadius) . cgPath
102115
103- rootContainer . layer. shadowColor = theme. colors. shadowDefault. cgColor
104- rootContainer . layer. shadowOpacity = HomepageUX . shadowOpacity
105- rootContainer . layer. shadowOffset = HomepageUX . shadowOffset
106- rootContainer . layer. shadowRadius = HomepageUX . shadowRadius
116+ contentView . layer. shadowColor = theme. colors. shadowDefault. cgColor
117+ contentView . layer. shadowOpacity = HomepageUX . shadowOpacity
118+ contentView . layer. shadowOffset = HomepageUX . shadowOffset
119+ contentView . layer. shadowRadius = HomepageUX . shadowRadius
107120 }
108121
109122 // MARK: - ThemeApplicable
0 commit comments