Add loading spinner on restore

This commit is contained in:
Adam Demasi 2021-09-06 19:27:47 +09:30
parent e3d88f7122
commit 47e20ddb99
No known key found for this signature in database
GPG key ID: 5D3B26B3D58C7D91
2 changed files with 31 additions and 0 deletions

View file

@ -8,6 +8,12 @@
#import <UIKit/UIKit.h>
@interface UIAlertController (Private)
@property (nonatomic, retain) UIViewController *contentViewController;
@end
@interface UIAlertAction (Common)
+ (UIAlertAction *)okAction;
+ (UIAlertAction *)okActionWithHandler:(void (^)(UIAlertAction *action))handler;

View file

@ -114,6 +114,31 @@ NSString *backupNameSelected;
alertControllerWithTitle:@"Restoring from backup"
message:@"Your device will respring when the process is completed."
preferredStyle:UIAlertControllerStyleAlert];
UIActivityIndicatorViewStyle indicatorStyle = UIActivityIndicatorViewStyleGray;
if (@available(iOS 13, *)) {
indicatorStyle = UIActivityIndicatorViewStyleMedium;
}
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:indicatorStyle];
activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
[activityIndicator startAnimating];
finishedRestoreAlert.contentViewController = [[UIViewController alloc] init];
[finishedRestoreAlert.contentViewController.view addSubview:activityIndicator];
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[activityIndicator]|"
options:kNilOptions
metrics:nil
views:@{
@"activityIndicator": activityIndicator
}]];
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[activityIndicator]|"
options:kNilOptions
metrics:nil
views:@{
@"activityIndicator": activityIndicator
}]];
[self presentViewController:finishedRestoreAlert animated:YES completion:nil];
//RUN RESTORE SCRIPT