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

Improve empty retry UX #2323

Merged
merged 1 commit into from
Oct 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Classes/Issues/IssuesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ final class IssuesViewController: MessageViewController,

// MARK: EmptyViewDelegate

func didTapRetry() {
self.feed.refreshHead()
func didTapRetry(view: EmptyView) {
feed.refreshHead()
}

// MARK: MessageTextViewListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ final class PullRequestReviewCommentsViewController: MessageViewController,

// MARK: EmptyViewDelegate

func didTapRetry() {
self.feed.refreshHead()
func didTapRetry(view: EmptyView) {
feed.refreshHead()
}

// MARK: IssueTextActionsViewSendDelegate
Expand Down
4 changes: 2 additions & 2 deletions Classes/Repository/RepositoryCodeBlobViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ final class RepositoryCodeBlobViewController: UIViewController, EmptyViewDelegat

// MARK: EmptyViewDelegate

func didTapRetry() {
self.onRefresh()
func didTapRetry(view: EmptyView) {
onRefresh()
}

}
4 changes: 2 additions & 2 deletions Classes/Repository/RepositoryWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ extension RepositoryWebViewController: WKNavigationDelegate {

extension RepositoryWebViewController: EmptyViewDelegate {

func didTapRetry() {
self.fetch()
func didTapRetry(view: EmptyView) {
fetch()
}

}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Search/SearchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class SearchViewController: UIViewController,

// MARK: EmptyViewDelegate

func didTapRetry() {
func didTapRetry(view: EmptyView) {
searchBar.resignFirstResponder()

guard let term = searchTerm(for: searchBar.text) else { return }
Expand Down
13 changes: 8 additions & 5 deletions Classes/View Controllers/BaseListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ LoadMoreSectionControllerDelegate {
// MARK: Public API

final func update(animated: Bool) {
self.feed.finishLoading(dismissRefresh: true, animated: animated)
feed.finishLoading(dismissRefresh: true, animated: animated)
}

final func update(
Expand All @@ -88,9 +88,9 @@ LoadMoreSectionControllerDelegate {
) {
assert(Thread.isMainThread)

self.hasError = false
hasError = false
self.page = page
self.feed.finishLoading(dismissRefresh: true, animated: animated, completion: completion)
feed.finishLoading(dismissRefresh: true, animated: animated, completion: completion)
}

final func error(
Expand Down Expand Up @@ -179,8 +179,11 @@ LoadMoreSectionControllerDelegate {

// MARK: EmptyViewDelegate

func didTapRetry() {
self.feed.refreshHead()
func didTapRetry(view: EmptyView) {
// order is required to hide the error empty view while loading
feed.refreshHead()
hasError = false
feed.adapter.performUpdates(animated: false, completion: nil)
}

// MARK: LoadMoreSectionControllerDelegate
Expand Down
7 changes: 5 additions & 2 deletions Classes/View Controllers/BaseListViewController2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ EmptyViewDelegate {

// MARK: EmptyViewDelegate

func didTapRetry() {
self.feed.refreshHead()
func didTapRetry(view: EmptyView) {
// order is required to hide the error empty view while loading
feed.refreshHead()
hasError = false
feed.adapter.performUpdates(animated: false, completion: nil)
}

}
1 change: 0 additions & 1 deletion Classes/Views/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ enum Constants {
static let assignees = NSLocalizedString("Assignees", comment: "")
static let reviewers = NSLocalizedString("Reviewers", comment: "")
static let reviewGitHubAccess = NSLocalizedString("Review GitHub Access", comment: "")
static let tryAgain = NSLocalizedString("Try Again", comment: "")
static let clear = NSLocalizedString("Clear", comment: "")
}
}
10 changes: 5 additions & 5 deletions Classes/Views/EmptyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit
import SnapKit

protocol EmptyViewDelegate: class {
func didTapRetry()
func didTapRetry(view: EmptyView)
}

final class EmptyView: UIView {
Expand All @@ -30,8 +30,8 @@ final class EmptyView: UIView {
addSubview(label)

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

button.snp.makeConstraints { make in
make.centerX.equalTo(self)
make.top.equalTo(label).offset(Styles.Sizes.gutter)
make.top.equalTo(label).offset(2*Styles.Sizes.gutter)
}
}

Expand All @@ -52,6 +52,6 @@ final class EmptyView: UIView {
}

@objc private func tapRetry(sender: UIButton) {
delegate?.didTapRetry()
delegate?.didTapRetry(view: self)
}
}