@@ -11,6 +11,7 @@ import UIKit
1111
1212 private var viewModel : PostsCardViewModel !
1313 private var ghostableTableView : UITableView ?
14+ private var errorView : DashboardCardInnerErrorView ?
1415
1516 private let status : BasePost . Status = . draft
1617
@@ -31,6 +32,11 @@ import UIKit
3132 viewModel. viewDidLoad ( )
3233 }
3334
35+ override func viewWillAppear( _ animated: Bool ) {
36+ super. viewWillAppear ( animated)
37+ hideSeparatorForGhostCells ( )
38+ }
39+
3440 override func viewDidAppear( _ animated: Bool ) {
3541 super. viewDidAppear ( animated)
3642 tableView. dataSource = viewModel
@@ -49,14 +55,15 @@ private extension PostsCardViewController {
4955 func configureTableView( ) {
5056 view. addSubview ( tableView)
5157 tableView. translatesAutoresizingMaskIntoConstraints = false
58+ tableView. isScrollEnabled = false
5259 view. pinSubviewToAllEdges ( tableView)
5360 let postCompactCellNib = PostCompactCell . defaultNib
5461 tableView. register ( postCompactCellNib, forCellReuseIdentifier: PostCompactCell . defaultReuseID)
5562 tableView. separatorStyle = . none
5663 }
5764
5865 func configureGhostableTableView( ) {
59- let ghostableTableView = IntrinsicTableView ( )
66+ let ghostableTableView = PostCardTableView ( )
6067
6168 view. addSubview ( ghostableTableView)
6269
@@ -83,6 +90,11 @@ private extension PostsCardViewController {
8390 ghostableTableView? . removeFromSuperview ( )
8491 }
8592
93+ func hideSeparatorForGhostCells( ) {
94+ ghostableTableView? . visibleCells
95+ . forEach { ( $0 as? PostCompactCell ) ? . hideSeparator ( ) }
96+ }
97+
8698 enum Constants {
8799 static let numberOfPosts = 3
88100 }
@@ -105,8 +117,21 @@ extension PostsCardViewController: PostsCardView {
105117 }
106118
107119 func hideLoading( ) {
120+ errorView? . removeFromSuperview ( )
108121 removeGhostableTableView ( )
109122 }
123+
124+ func showError( message: String , retry: Bool ) {
125+ let errorView = DashboardCardInnerErrorView ( message: message, canRetry: retry)
126+ errorView. delegate = self
127+ errorView. translatesAutoresizingMaskIntoConstraints = false
128+ tableView. addSubview ( withFadeAnimation: errorView)
129+ tableView. pinSubviewToSafeArea ( errorView)
130+ self . errorView = errorView
131+
132+ // Force the table view to recalculate its height
133+ _ = tableView. intrinsicContentSize
134+ }
110135}
111136
112137// MARK: - EditorAnalyticsProperties
@@ -126,6 +151,14 @@ extension PostsCardViewController: EditorAnalyticsProperties {
126151 }
127152}
128153
154+ // MARK: - DashboardCardInnerErrorViewDelegate
155+
156+ extension PostsCardViewController : DashboardCardInnerErrorViewDelegate {
157+ func retry( ) {
158+ viewModel. retry ( )
159+ }
160+ }
161+
129162// MARK: - PostCardTableView
130163
131164extension NSNotification . Name {
0 commit comments