aboutsummaryrefslogtreecommitdiff
path: root/foray
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-03-16 10:21:08 +1100
committerNicholas Tay <nick@windblume.net>2022-03-16 10:21:08 +1100
commit6235b4f7f8a172b0c8595527184a9e6c0c4cb79c (patch)
tree341df7c25b2d720b0b5fcc8166507fb69d417b97 /foray
parent5fbe87e25c1136e29494d181edbdbf6d6dbba6e1 (diff)
downloadforayios-6235b4f7f8a172b0c8595527184a9e6c0c4cb79c.tar.gz
forayios-6235b4f7f8a172b0c8595527184a9e6c0c4cb79c.tar.bz2
forayios-6235b4f7f8a172b0c8595527184a9e6c0c4cb79c.zip
Loading overlay on main screen
I'm not 100% sure if this is the best way to do it, but it looks decent and it works. Resources: - https://stackoverflow.com/questions/27960556/loading-an-overlay-when-running-long-tasks-in-ios
Diffstat (limited to 'foray')
-rw-r--r--foray/ForayTableViewController.swift11
1 files changed, 11 insertions, 0 deletions
diff --git a/foray/ForayTableViewController.swift b/foray/ForayTableViewController.swift
index fd4854e..67f0bc5 100644
--- a/foray/ForayTableViewController.swift
+++ b/foray/ForayTableViewController.swift
@@ -55,6 +55,15 @@ class ForayTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
+ // Not sure if this is the right way to go about this...
+ let alert = UIAlertController(title: nil, message: "Grabbing data...", preferredStyle: .alert)
+ let loadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
+ loadingIndicator.hidesWhenStopped = true
+ loadingIndicator.style = UIActivityIndicatorView.Style.medium
+ loadingIndicator.startAnimating();
+ alert.view.addSubview(loadingIndicator)
+ present(alert, animated: true, completion: nil)
+
loadApiData(onComplete: { (apiItems) in
self.items = apiItems
@@ -69,6 +78,8 @@ class ForayTableViewController: UITableViewController {
self.tableView.reloadData()
})
+
+ dismiss(animated: false, completion: nil)
}
func loadApiData(onComplete: @escaping ([MyItem]) -> ()) {