@@ -25,18 +25,15 @@ final class HomeView: UIView {
2525 return element
2626 } ( )
2727
28- private lazy var tableView : UITableView = {
29- let tableView = UITableView ( frame: . zero)
30- tableView. translatesAutoresizingMaskIntoConstraints = false
31- tableView. register ( ActivityCellView . self, forCellReuseIdentifier: ActivityCellView . reuseIdentifier)
32- tableView. register ( UITableViewCell . self, forCellReuseIdentifier: UITableViewCell . reuseIdentifier)
33- tableView. dataSource = self
34- tableView. delegate = self
35- return tableView
28+ private lazy var activityListView : ActivityListView = {
29+ let element = ActivityListView ( )
30+ element. translatesAutoresizingMaskIntoConstraints = false
31+ return element
3632 } ( )
37-
33+
3834 init ( ) {
3935 super. init ( frame: . zero)
36+ self . activityListView. configTableViewProtocol ( delegate: self , dataSource: self )
4037 self . setupViews ( )
4138 }
4239
@@ -49,7 +46,7 @@ final class HomeView: UIView {
4946 accountSummaryView. updateValues ( balance: configuration. homeData. balance,
5047 savings: configuration. homeData. savings,
5148 spending: configuration. homeData. spending)
52- tableView . reloadData ( )
49+ activityListView . reloadData ( )
5350 }
5451}
5552
@@ -63,7 +60,7 @@ private extension HomeView {
6360
6461 func configureSubviews( ) {
6562 addSubview ( accountSummaryView)
66- addSubview ( tableView )
63+ addSubview ( activityListView )
6764 }
6865
6966 func configureSubviewsConstraints( ) {
@@ -72,33 +69,34 @@ private extension HomeView {
7269 accountSummaryView. leadingAnchor. constraint ( equalTo: safeAreaLayoutGuide. leadingAnchor, constant: 16 ) ,
7370 accountSummaryView. trailingAnchor. constraint ( equalTo: safeAreaLayoutGuide. trailingAnchor, constant: - 16 ) ,
7471
75- tableView . topAnchor. constraint ( equalTo: accountSummaryView. bottomAnchor, constant: 16 ) ,
76- tableView . leadingAnchor. constraint ( equalTo: safeAreaLayoutGuide. leadingAnchor) ,
77- tableView . trailingAnchor. constraint ( equalTo: safeAreaLayoutGuide. trailingAnchor) ,
78- tableView . bottomAnchor. constraint ( equalTo: safeAreaLayoutGuide. bottomAnchor)
72+ activityListView . topAnchor. constraint ( equalTo: accountSummaryView. bottomAnchor, constant: 16 ) ,
73+ activityListView . leadingAnchor. constraint ( equalTo: safeAreaLayoutGuide. leadingAnchor) ,
74+ activityListView . trailingAnchor. constraint ( equalTo: safeAreaLayoutGuide. trailingAnchor) ,
75+ activityListView . bottomAnchor. constraint ( equalTo: safeAreaLayoutGuide. bottomAnchor)
7976 ] )
8077 }
8178}
8279
8380extension HomeView : UITableViewDataSource , UITableViewDelegate {
81+
8482 public func tableView( _ tableView: UITableView , numberOfRowsInSection section: Int ) -> Int {
85- return activities. count
83+ activities. count
8684 }
8785
8886 public func tableView( _ tableView: UITableView , cellForRowAt indexPath: IndexPath ) -> UITableViewCell {
8987 guard let cell: ActivityCellView = . createCell( for: tableView, at: indexPath) ,
9088 indexPath. row < activities. count else {
9189 return . init( )
9290 }
93-
94-
9591 cell. updateValues ( activity: activities [ indexPath. row] )
9692 return cell
9793 }
9894
99-
10095 func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
10196 delegate? . didSelectActivity ( )
10297 }
98+
99+ func tableView( _ tableView: UITableView , titleForHeaderInSection section: Int ) -> String ? {
100+ " Activity "
101+ }
103102}
104-
0 commit comments