@@ -77,7 +77,38 @@ public class Collection: View, UICollectionViewDataSource {
7777 reversed = value
7878 return self
7979 }
80+ }
81+
82+ extension Collection : UICollectionViewDelegate {
83+ public func collectionView( _ collectionView: UICollectionView , didSelectItemAt indexPath: IndexPath ) { }
84+ public func collectionView( _ collectionView: UICollectionView , shouldHighlightItemAt indexPath: IndexPath ) -> Bool { false }
85+ }
86+
87+ extension Collection : UIScrollViewDelegate {
88+ @discardableResult
89+ public func contentOffset( _ position: CGPoint , animated: Bool = true ) -> Self {
90+ collectionView. setContentOffset ( position, animated: animated)
91+ return self
92+ }
8093
94+ @discardableResult
95+ public func scrollPosition( _ binding: UIKitPlus . State < CGPoint > ) -> Self {
96+ scrollPosition = binding
97+ return self
98+ }
99+
100+ @discardableResult
101+ public func scrollPosition< V> ( _ expressable: ExpressableState < V , CGPoint > ) -> Self {
102+ scrollPosition = expressable. unwrap ( )
103+ return self
104+ }
105+
106+ public func scrollViewDidScroll( _ scrollView: UIScrollView ) {
107+ scrollPosition? . wrappedValue = scrollView. contentOffset
108+ }
109+ }
110+
111+ extension Collection {
81112 // MARK: Indicators
82113
83114 @discardableResult
@@ -99,33 +130,31 @@ public class Collection: View, UICollectionViewDataSource {
99130 collectionView. showsVerticalScrollIndicator = false
100131 return self
101132 }
102- }
103-
104- extension Collection : UICollectionViewDelegate {
105- public func collectionView( _ collectionView: UICollectionView , didSelectItemAt indexPath: IndexPath ) { }
106- public func collectionView( _ collectionView: UICollectionView , shouldHighlightItemAt indexPath: IndexPath ) -> Bool { false }
107- }
108-
109- extension Collection : UIScrollViewDelegate {
133+
134+ // MARK: Content Inset
135+
110136 @discardableResult
111- public func contentOffset ( _ position : CGPoint , animated : Bool = true ) -> Self {
112- collectionView. setContentOffset ( position , animated : animated )
137+ public func contentInset ( _ insets : UIEdgeInsets ) -> Self {
138+ collectionView. contentInset = insets
113139 return self
114140 }
115141
116142 @discardableResult
117- public func scrollPosition( _ binding: UIKitPlus . State < CGPoint > ) -> Self {
118- scrollPosition = binding
119- return self
143+ public func contentInset( top: CGFloat = 0 , left: CGFloat = 0 , right: CGFloat = 0 , bottom: CGFloat = 0 ) -> Self {
144+ contentInset ( . init( top: top, left: left, bottom: bottom, right: right) )
120145 }
121146
147+ // MARK: Scroll Indicator Inset
148+
122149 @discardableResult
123- public func scrollPosition < V > ( _ expressable : ExpressableState < V , CGPoint > ) -> Self {
124- scrollPosition = expressable . unwrap ( )
150+ public func scrollIndicatorInsets ( _ insets : UIEdgeInsets ) -> Self {
151+ collectionView . scrollIndicatorInsets = insets
125152 return self
126153 }
127154
128- public func scrollViewDidScroll( _ scrollView: UIScrollView ) {
129- scrollPosition? . wrappedValue = scrollView. contentOffset
155+ @discardableResult
156+ public func scrollIndicatorInsets( top: CGFloat = 0 , left: CGFloat = 0 , bottom: CGFloat = 0 , right: CGFloat = 0 ) -> Self {
157+ scrollIndicatorInsets ( . init( top: top, left: left, bottom: bottom, right: right) )
130158 }
131159}
160+
0 commit comments