Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit e4f6e20

Browse files
authored
add empty error view to latest base VC (#2283)
1 parent 18de137 commit e4f6e20

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Classes/View Controllers/BaseListViewController2.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ protocol BaseListViewController2EmptyDataSource: class {
2020
class BaseListViewController2<PageType: CustomStringConvertible>: UIViewController,
2121
ListSwiftAdapterDataSource,
2222
FeedDelegate,
23-
LoadMoreSectionController2Delegate {
23+
LoadMoreSectionController2Delegate,
24+
ListSwiftAdapterEmptyViewSource,
25+
EmptyViewDelegate {
2426

2527
private let emptyErrorMessage: String
2628

@@ -44,6 +46,7 @@ LoadMoreSectionController2Delegate {
4446
super.viewDidLoad()
4547
feed.viewDidLoad()
4648
feed.swiftAdapter.dataSource = self
49+
feed.swiftAdapter.emptyViewSource = self
4750
}
4851

4952
override func viewWillAppear(_ animated: Bool) {
@@ -146,5 +149,22 @@ LoadMoreSectionController2Delegate {
146149
func didSelect(controller: LoadMoreSectionController2) {
147150
fetch(page: page)
148151
}
152+
153+
// MARK: ListSwiftAdapterEmptyViewSource
154+
155+
func emptyView(adapter: ListSwiftAdapter) -> UIView? {
156+
guard hasError else { return nil }
157+
let empty = EmptyView()
158+
empty.label.text = emptyErrorMessage
159+
empty.delegate = self
160+
empty.button.isHidden = false
161+
return empty
162+
}
163+
164+
// MARK: EmptyViewDelegate
165+
166+
func didTapRetry() {
167+
self.feed.refreshHead()
168+
}
149169

150170
}

0 commit comments

Comments
 (0)