Skip to content

Commit

Permalink
Update demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
Friend-LGA committed May 14, 2017
1 parent 0b44fbe commit e4c0b6f
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 23 deletions.
57 changes: 49 additions & 8 deletions Demo/LGAlertViewDemo/TableViewControllerActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,31 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:@"Connecting to server..."
buttonTitles:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
delegate:self];

[alertView showAnimated:YES completionHandler:nil];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
if (alertView && alertView.isShowing) {
[alertView dismissAnimated:YES completionHandler:nil];
alertView.progressLabelText = @"Done, will be closed after 3...";

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
alertView.progressLabelText = @"Done, will be closed after 2...";

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
alertView.progressLabelText = @"Done, will be closed after 1...";

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
if (alertView && alertView.isShowing) {
[alertView dismissAnimated:YES completionHandler:nil];
}
});
});
});
}
});

Expand All @@ -378,16 +393,31 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:@"Connecting to server..."
buttonTitles:nil
cancelButtonTitle:@"I'm hurry"
destructiveButtonTitle:nil
delegate:self];

[alertView showAnimated:YES completionHandler:nil];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
if (alertView && alertView.isShowing) {
[alertView dismissAnimated:YES completionHandler:nil];
alertView.progressLabelText = @"Done, will be closed after 3...";

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
alertView.progressLabelText = @"Done, will be closed after 2...";

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
alertView.progressLabelText = @"Done, will be closed after 1...";

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
if (alertView && alertView.isShowing) {
[alertView dismissAnimated:YES completionHandler:nil];
}
});
});
});
}
});

Expand All @@ -397,7 +427,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView = [[LGAlertView alloc] initWithProgressViewAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:@"0 %"
progress:0.0
progressLabelText:@"Connecting to server..."
buttonTitles:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
Expand All @@ -413,7 +444,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView = [[LGAlertView alloc] initWithProgressViewAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:@"0 %"
progress:0.0
progressLabelText:@"Connecting to server..."
buttonTitles:nil
cancelButtonTitle:@"I'm hurry"
destructiveButtonTitle:nil
Expand All @@ -429,6 +461,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView1 = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:nil
buttonTitles:nil
cancelButtonTitle:@"I'm hurry"
destructiveButtonTitle:nil
Expand Down Expand Up @@ -456,6 +489,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView1 = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:nil
buttonTitles:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
Expand Down Expand Up @@ -483,6 +517,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView1 = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:nil
buttonTitles:nil
cancelButtonTitle:@"I'm hurry"
destructiveButtonTitle:nil
Expand Down Expand Up @@ -510,6 +545,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView1 = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:nil
buttonTitles:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
Expand Down Expand Up @@ -537,6 +573,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView1 = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:nil
buttonTitles:nil
cancelButtonTitle:@"I'm hurry"
destructiveButtonTitle:nil
Expand Down Expand Up @@ -564,6 +601,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
LGAlertView *alertView1 = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading"
message:@"Waiting please"
style:LGAlertViewStyleActionSheet
progressLabelText:nil
buttonTitles:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
Expand Down Expand Up @@ -600,13 +638,16 @@ - (void)updateProgressWithAlertView:(LGAlertView *)alertView {
[alertView dismissAnimated:YES completionHandler:nil];
}
else {
float progress = alertView.progress+0.0025;
float progress = alertView.progress + 0.0025;

if (progress > 1.0) {
progress = 1.0;
}

[alertView setProgress:progress progressLabelText:[NSString stringWithFormat:@"%.0f %%", progress*100]];
float percentage = progress * 100.0;

alertView.progress = progress;
alertView.progressLabelText = [NSString stringWithFormat:@"%.0f %%", percentage];

[self updateProgressWithAlertView:alertView];
}
Expand Down
Loading

0 comments on commit e4c0b6f

Please sign in to comment.