Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Add activity indicator when searching for/loading rss feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Feb 24, 2021
1 parent 977118f commit c33750a
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ class BraveTodayAddSourceViewController: UITableViewController {
private let feedDataSource: FeedDataSource
var sourcesAdded: ((Set<RSSFeedLocation>) -> Void)?

private var isLoading: Bool = false
private var isLoading: Bool = false {
didSet {
if isLoading {
self.activityIndicator.startAnimating()
} else {
self.activityIndicator.stopAnimating()
}
}
}
private let activityIndicator = UIActivityIndicatorView(style: .gray).then {
$0.hidesWhenStopped = true
}

init(dataSource: FeedDataSource) {
self.feedDataSource = dataSource
Expand Down Expand Up @@ -44,6 +55,7 @@ class BraveTodayAddSourceViewController: UITableViewController {
navigationItem.largeTitleDisplayMode = .always
navigationItem.backButtonTitle = ""
navigationItem.leftBarButtonItem = .init(barButtonSystemItem: .cancel, target: self, action: #selector(tappedCancel))
navigationItem.rightBarButtonItem = .init(customView: activityIndicator)

textField.addTarget(self, action: #selector(textFieldTextChanged), for: .editingChanged)
textField.delegate = self
Expand Down Expand Up @@ -102,8 +114,10 @@ class BraveTodayAddSourceViewController: UITableViewController {
text.replaceSubrange(range, with: [])
}
guard let url = URIFixup.getURL(text) else { return }
isLoading = true
downloadPageData(for: url) { [weak self] result in
guard let self = self else { return }
self.isLoading = false
switch result {
case .success(let data):
let resultsController = BraveTodayAddSourceResultsViewController(
Expand Down

0 comments on commit c33750a

Please sign in to comment.