@@ -14,7 +14,7 @@ class ActivityListViewController: UIViewController, TableViewContainer, ImmuTabl
1414
1515 let containerStackView = UIStackView ( )
1616
17- let filterStackView = UIStackView ( )
17+ let filterView = FilterBarView ( )
1818 let dateFilterChip = FilterChipButton ( )
1919 let activityTypeFilterChip = FilterChipButton ( )
2020
@@ -35,10 +35,6 @@ class ActivityListViewController: UIViewController, TableViewContainer, ImmuTabl
3535 fileprivate var viewModel : ActivityListViewModel
3636 private enum Constants {
3737 static let estimatedRowHeight : CGFloat = 62
38- static let filterHeightAnchor : CGFloat = 24
39- static let filterStackViewSpacing : CGFloat = 8
40- static let filterBarHorizontalPadding : CGFloat = 16
41- static let filterBarVerticalPadding : CGFloat = 8
4238 }
4339
4440 // MARK: - GUI
@@ -162,48 +158,13 @@ class ActivityListViewController: UIViewController, TableViewContainer, ImmuTabl
162158 }
163159
164160 private func setupFilterBar( ) {
165- let filterIcon = UIImageView ( image: UIImage . gridicon ( . filter) )
166- filterIcon. tintColor = . listIcon
167- filterIcon. heightAnchor. constraint ( equalToConstant: Constants . filterHeightAnchor) . isActive = true
168- filterStackView. alignment = . center
169- filterStackView. spacing = Constants . filterStackViewSpacing
170- filterStackView. addArrangedSubview ( filterIcon)
171- let scrollView = UIScrollView ( )
172- scrollView. canCancelContentTouches = true
173- scrollView. showsHorizontalScrollIndicator = false
174- filterStackView. addArrangedSubview ( dateFilterChip)
175- filterStackView. addArrangedSubview ( activityTypeFilterChip)
176- scrollView. addSubview ( filterStackView)
177- containerStackView. addArrangedSubview ( scrollView)
178- filterStackView. translatesAutoresizingMaskIntoConstraints = false
179- NSLayoutConstraint . activate ( [
180- filterStackView. leftAnchor. constraint ( equalTo: scrollView. leftAnchor, constant: Constants . filterBarHorizontalPadding) ,
181- filterStackView. rightAnchor. constraint ( equalTo: scrollView. rightAnchor, constant: Constants . filterBarHorizontalPadding) ,
182- filterStackView. topAnchor. constraint ( equalTo: scrollView. topAnchor, constant: Constants . filterBarVerticalPadding) ,
183- filterStackView. bottomAnchor. constraint ( equalTo: scrollView. bottomAnchor, constant: Constants . filterBarVerticalPadding) ,
184- scrollView. heightAnchor. constraint ( equalTo: filterStackView. heightAnchor, constant: 2 * Constants. filterBarVerticalPadding)
185- ] )
186-
187- // Ensure that the stackview is right aligned in RTL layouts
188- if view. userInterfaceLayoutDirection ( ) == . rightToLeft {
189- scrollView. transform = CGAffineTransform ( rotationAngle: CGFloat ( Double . pi) )
190- filterStackView. transform = CGAffineTransform ( rotationAngle: CGFloat ( Double . pi) )
191- }
161+ containerStackView. addArrangedSubview ( filterView)
192162
193- setupDateFilter ( )
163+ filterView. add ( button: dateFilterChip)
164+ filterView. add ( button: activityTypeFilterChip)
194165
166+ setupDateFilter ( )
195167 setupActivityTypeFilter ( )
196-
197- let separator = UIView ( )
198- separator. translatesAutoresizingMaskIntoConstraints = false
199- scrollView. addSubview ( separator)
200- NSLayoutConstraint . activate ( [
201- separator. bottomAnchor. constraint ( equalTo: scrollView. bottomAnchor, constant: 16 ) ,
202- separator. leftAnchor. constraint ( equalTo: scrollView. leftAnchor) ,
203- separator. widthAnchor. constraint ( equalTo: scrollView. widthAnchor) ,
204- separator. heightAnchor. constraint ( equalToConstant: 1 )
205- ] )
206- WPStyleGuide . applyBorderStyle ( separator)
207168 }
208169
209170 private func setupDateFilter( ) {
0 commit comments