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

Commit 970ac9d

Browse files
authored
Improve empty retry UX (#2323)
1 parent b2b757f commit 970ac9d

File tree

9 files changed

+27
-22
lines changed

9 files changed

+27
-22
lines changed

Classes/Issues/IssuesViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ final class IssuesViewController: MessageViewController,
621621

622622
// MARK: EmptyViewDelegate
623623

624-
func didTapRetry() {
625-
self.feed.refreshHead()
624+
func didTapRetry(view: EmptyView) {
625+
feed.refreshHead()
626626
}
627627

628628
// MARK: MessageTextViewListener

Classes/PullRequestReviews/PullRequestReviewCommentsViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ final class PullRequestReviewCommentsViewController: MessageViewController,
193193

194194
// MARK: EmptyViewDelegate
195195

196-
func didTapRetry() {
197-
self.feed.refreshHead()
196+
func didTapRetry(view: EmptyView) {
197+
feed.refreshHead()
198198
}
199199

200200
// MARK: IssueTextActionsViewSendDelegate

Classes/Repository/RepositoryCodeBlobViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ final class RepositoryCodeBlobViewController: UIViewController, EmptyViewDelegat
169169

170170
// MARK: EmptyViewDelegate
171171

172-
func didTapRetry() {
173-
self.onRefresh()
172+
func didTapRetry(view: EmptyView) {
173+
onRefresh()
174174
}
175175

176176
}

Classes/Repository/RepositoryWebViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ extension RepositoryWebViewController: WKNavigationDelegate {
133133

134134
extension RepositoryWebViewController: EmptyViewDelegate {
135135

136-
func didTapRetry() {
137-
self.fetch()
136+
func didTapRetry(view: EmptyView) {
137+
fetch()
138138
}
139139

140140
}

Classes/Search/SearchViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class SearchViewController: UIViewController,
235235

236236
// MARK: EmptyViewDelegate
237237

238-
func didTapRetry() {
238+
func didTapRetry(view: EmptyView) {
239239
searchBar.resignFirstResponder()
240240

241241
guard let term = searchTerm(for: searchBar.text) else { return }

Classes/View Controllers/BaseListViewController.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ LoadMoreSectionControllerDelegate {
7878
// MARK: Public API
7979

8080
final func update(animated: Bool) {
81-
self.feed.finishLoading(dismissRefresh: true, animated: animated)
81+
feed.finishLoading(dismissRefresh: true, animated: animated)
8282
}
8383

8484
final func update(
@@ -88,9 +88,9 @@ LoadMoreSectionControllerDelegate {
8888
) {
8989
assert(Thread.isMainThread)
9090

91-
self.hasError = false
91+
hasError = false
9292
self.page = page
93-
self.feed.finishLoading(dismissRefresh: true, animated: animated, completion: completion)
93+
feed.finishLoading(dismissRefresh: true, animated: animated, completion: completion)
9494
}
9595

9696
final func error(
@@ -179,8 +179,11 @@ LoadMoreSectionControllerDelegate {
179179

180180
// MARK: EmptyViewDelegate
181181

182-
func didTapRetry() {
183-
self.feed.refreshHead()
182+
func didTapRetry(view: EmptyView) {
183+
// order is required to hide the error empty view while loading
184+
feed.refreshHead()
185+
hasError = false
186+
feed.adapter.performUpdates(animated: false, completion: nil)
184187
}
185188

186189
// MARK: LoadMoreSectionControllerDelegate

Classes/View Controllers/BaseListViewController2.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ EmptyViewDelegate {
169169

170170
// MARK: EmptyViewDelegate
171171

172-
func didTapRetry() {
173-
self.feed.refreshHead()
172+
func didTapRetry(view: EmptyView) {
173+
// order is required to hide the error empty view while loading
174+
feed.refreshHead()
175+
hasError = false
176+
feed.adapter.performUpdates(animated: false, completion: nil)
174177
}
175178

176179
}

Classes/Views/Constants.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ enum Constants {
5656
static let assignees = NSLocalizedString("Assignees", comment: "")
5757
static let reviewers = NSLocalizedString("Reviewers", comment: "")
5858
static let reviewGitHubAccess = NSLocalizedString("Review GitHub Access", comment: "")
59-
static let tryAgain = NSLocalizedString("Try Again", comment: "")
6059
static let clear = NSLocalizedString("Clear", comment: "")
6160
}
6261
}

Classes/Views/EmptyView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010
import SnapKit
1111

1212
protocol EmptyViewDelegate: class {
13-
func didTapRetry()
13+
func didTapRetry(view: EmptyView)
1414
}
1515

1616
final class EmptyView: UIView {
@@ -30,8 +30,8 @@ final class EmptyView: UIView {
3030
addSubview(label)
3131

3232
button.isHidden = true
33-
button.titleLabel?.font = Styles.Text.button.preferredFont
34-
button.setTitle(Constants.Strings.tryAgain, for: .normal)
33+
button.titleLabel?.font = Styles.Text.secondaryBold.preferredFont
34+
button.setTitle(NSLocalizedString("Try Again", comment: ""), for: .normal)
3535
button.setTitleColor(Styles.Colors.Blue.medium.color, for: .normal)
3636
button.addTarget(self, action: #selector(tapRetry), for: .touchUpInside)
3737
addSubview(button)
@@ -43,7 +43,7 @@ final class EmptyView: UIView {
4343

4444
button.snp.makeConstraints { make in
4545
make.centerX.equalTo(self)
46-
make.top.equalTo(label).offset(Styles.Sizes.gutter)
46+
make.top.equalTo(label).offset(2*Styles.Sizes.gutter)
4747
}
4848
}
4949

@@ -52,6 +52,6 @@ final class EmptyView: UIView {
5252
}
5353

5454
@objc private func tapRetry(sender: UIButton) {
55-
delegate?.didTapRetry()
55+
delegate?.didTapRetry(view: self)
5656
}
5757
}

0 commit comments

Comments
 (0)