Skip to content

Commit b5946e4

Browse files
committed
Add loading indicators to brb
1 parent 8bc9673 commit b5946e4

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

Eatery/Controllers/BRB Feature/BRBConnectionHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class BRBConnectionHandler: WKWebView, WKNavigationDelegate {
9595
getHTML { (html: NSString) in
9696
let tableHTMLRegex = "(<tr class=\\\"(?:even|odd|odd first-child)\\\"><td class=\\\"first-child account_name\\\">(.*?)<\\/td><td class=\\\"date_(and_|)time\\\"><span class=\\\"date\\\">(.*?)<\\/span><\\/td><td class=\\\"activity_details\\\">(.*?)<\\/td><td class=\\\"last-child amount_points (credit|debit)\\\" title=\\\"(credit|debit)\\\">(.*?)<\\/td><\\/tr>)"
9797

98-
let regex = try? NSRegularExpression(pattern: tableHTMLRegex as String, options: .useUnicodeWordBoundaries)
98+
let regex = try? NSRegularExpression(pattern: tableHTMLRegex, options: .useUnicodeWordBoundaries)
9999
if let matches = regex?.matches(in: html as String, options: NSRegularExpression.MatchingOptions.withTransparentBounds , range: NSMakeRange(0, html.length))
100100
{
101101
for match in matches

Eatery/Controllers/BRB Feature/BRBLoginView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import NVActivityIndicatorView
23

34
protocol BRBLoginViewDelegate {
45
func brbLoginViewClickedLogin(brbLoginView: BRBLoginView, netid: String, password: String)
@@ -18,7 +19,7 @@ class BRBLoginView: UIView, UITextFieldDelegate {
1819
let privacyStatementButton = UIButton()
1920
let privacyStatementTextView = UITextView()
2021

21-
var activityIndicator = UIActivityIndicatorView()
22+
var activityIndicator: NVActivityIndicatorView!
2223

2324
override init(frame: CGRect) {
2425
super.init(frame: frame)
@@ -160,8 +161,7 @@ class BRBLoginView: UIView, UITextFieldDelegate {
160161
make.height.equalTo(55)
161162
}
162163

163-
activityIndicator = UIActivityIndicatorView()
164-
activityIndicator.color = .white
164+
activityIndicator = NVActivityIndicatorView(frame: CGRect(x: 0.0, y: 0.0, width: 22.0, height: 22.0), type: .circleStrokeSpin, color: .white, padding: nil)
165165
addSubview(activityIndicator)
166166
activityIndicator.snp.makeConstraints { make in
167167
make.center.equalTo(loginButton)

Eatery/Controllers/BRB Feature/BRBViewController.swift

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import UIKit
22
import WebKit
33
import SafariServices
44
import Crashlytics
5+
import NVActivityIndicatorView
56

67
class BRBViewController: UIViewController, BRBConnectionDelegate, BRBLoginViewDelegate, BRBAccountSettingsDelegate, UITableViewDelegate, UITableViewDataSource {
78

@@ -11,8 +12,7 @@ class BRBViewController: UIViewController, BRBConnectionDelegate, BRBLoginViewDe
1112
var timer: Timer!
1213

1314
var tableView: UITableView!
14-
let activityIndicatorView = UIActivityIndicatorView()
15-
let activityIndicatorDescriptionLabel = UILabel()
15+
var activityIndicatorView: NVActivityIndicatorView!
1616
let timeout = 30.0 // seconds
1717
var time = 0.0 // time of request
1818
var historyHeader : EateriesCollectionViewHeaderView?
@@ -35,12 +35,6 @@ class BRBViewController: UIViewController, BRBConnectionDelegate, BRBLoginViewDe
3535
}
3636

3737
connectionHandler.delegate = self
38-
39-
activityIndicatorView.color = .black
40-
activityIndicatorView.hidesWhenStopped = true
41-
activityIndicatorDescriptionLabel.text = "Logging in, this may take a minute"
42-
activityIndicatorDescriptionLabel.textAlignment = .center
43-
activityIndicatorDescriptionLabel.font = UIFont.systemFont(ofSize: 12)
4438

4539
navigationItem.rightBarButtonItem?.isEnabled = false
4640

@@ -117,13 +111,8 @@ class BRBViewController: UIViewController, BRBConnectionDelegate, BRBLoginViewDe
117111
}
118112

119113
func setupAccountPage() {
120-
121114
diningHistory = connectionHandler.diningHistory
122115

123-
if diningHistory.count == 0 {
124-
activityIndicatorView.startAnimating()
125-
}
126-
127116
navigationItem.rightBarButtonItem?.isEnabled = true
128117

129118
tableView = UITableView(frame: .zero, style: .grouped)
@@ -139,6 +128,10 @@ class BRBViewController: UIViewController, BRBConnectionDelegate, BRBLoginViewDe
139128
tableView.snp.makeConstraints { make in
140129
make.top.edges.equalToSuperview()
141130
}
131+
132+
activityIndicatorView = NVActivityIndicatorView(frame: CGRect(x: 16.0, y: 8.0, width: 36.0, height: 36.0), type: .circleStrokeSpin, color: .gray)
133+
activityIndicatorView.startAnimating()
134+
tableView.tableFooterView = activityIndicatorView
142135
}
143136

144137
/// MARK: Table view delegate/data source
@@ -240,6 +233,9 @@ class BRBViewController: UIViewController, BRBConnectionDelegate, BRBLoginViewDe
240233

241234
let indexPaths = (0..<entries.count).map { IndexPath(row: $0, section: 1) }
242235
self.tableView.insertRows(at: indexPaths, with: .automatic)
236+
237+
tableView.tableFooterView = nil
238+
activityIndicatorView.removeFromSuperview()
243239
}
244240

245241
func showSafariVC() {
@@ -264,9 +260,6 @@ class BRBViewController: UIViewController, BRBConnectionDelegate, BRBLoginViewDe
264260
keychainItemWrapper["netid"] = loginView?.netidTextField.text! as AnyObject?
265261
keychainItemWrapper["password"] = loginView?.passwordTextField.text! as AnyObject?
266262
}
267-
268-
activityIndicatorView.stopAnimating()
269-
activityIndicatorDescriptionLabel.removeFromSuperview()
270263

271264
if loginView != nil {
272265
loginView?.superview?.removeFromSuperview()

Eatery/Controllers/EateriesViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class EateriesViewController: UIViewController, MenuButtonsDelegate, CLLocationM
217217
}, completion: nil)
218218
}
219219

220-
UIView.animate(withDuration: 0.55) {
220+
UIView.animate(withDuration: 0.35) {
221221
self.activityIndicator.alpha = 0.0
222222
}
223223
}

0 commit comments

Comments
 (0)