Skip to content

Commit 52192a7

Browse files
committed
Added loading indicator for data migration
1 parent 27134fe commit 52192a7

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

TCAT/AppDelegate.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
7171
CustomNavigationController(rootViewController: rootVC)
7272

7373
// v1.2.2 Data Migration
74-
print("Begin Data Migration")
75-
if VersionStore.shared.savedAppVersion <= WhatsNew.Version(major: 1, minor: 2, patch: 1) {
74+
if
75+
VersionStore.shared.savedAppVersion <= WhatsNew.Version(major: 1, minor: 2, patch: 1),
76+
let homeViewController = rootVC as? HomeViewController
77+
{
78+
print("Begin Data Migration")
79+
homeViewController.showLoadingScreen()
7680
migrationToNewPlacesModel { (success, errorDescription) in
77-
if let homeViewController = rootVC as? HomeViewController {
78-
homeViewController.viewWillAppear(false)
79-
}
81+
homeViewController.removeLoadingScreen()
8082
print("Data Migration Complete - Success: \(success), Error: \(errorDescription ?? "n/a")")
8183
let payload = DataMigrationOnePointThreePayload(success: success, errorDescription: errorDescription)
8284
Analytics.shared.log(payload)

TCAT/Controllers/HomeViewController.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,33 @@ class HomeViewController: UIViewController {
297297
let navigationVC = CustomNavigationController(rootViewController: informationViewController)
298298
present(navigationVC, animated: true)
299299
}
300+
301+
var loadingView = UIView()
302+
303+
/// Show a temporary loading screen
304+
func showLoadingScreen() {
305+
306+
loadingView.backgroundColor = Colors.backgroundWash
307+
view.addSubview(loadingView)
308+
309+
loadingView.snp.makeConstraints { (make) in
310+
make.top.bottom.leading.trailing.equalToSuperview()
311+
}
312+
313+
let indicator = LoadingIndicator()
314+
loadingView.addSubview(indicator)
315+
indicator.snp.makeConstraints { (make) in
316+
make.center.equalToSuperview()
317+
make.width.height.equalTo(40)
318+
}
319+
320+
}
321+
322+
func removeLoadingScreen() {
323+
loadingView.removeFromSuperview()
324+
viewWillAppear(false)
325+
}
326+
300327
}
301328

302329
// MARK: TableView DataSource

0 commit comments

Comments
 (0)