Skip to content

Commit

Permalink
Show previous alert (if available) upon dismissing of current
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott90 committed Dec 2, 2013
1 parent 6ed66ab commit 7e6b9fb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
16 changes: 16 additions & 0 deletions SDCAlertView/SDCAlertViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ - (void)showAlert:(SDCAlertView *)alert animated:(BOOL)animated {

[self changeActiveWindowIfNeeded];

if ([self.alertViews count] > 1) {
SDCAlertView *previousAlert = self.alertViews[0];
CATransform3D transformFrom = CATransform3DMakeScale(1, 1, 1);
CATransform3D transformTo = CATransform3DMakeScale(SDCAlertViewDismissingAnimationScale, SDCAlertViewDismissingAnimationScale, 1);

[self animateAlertTransform:previousAlert from:transformFrom to:transformTo];
[self animateAlertOpacity:previousAlert from:1 to:0];
}

[alert willBePresented];

if (animated) {
Expand Down Expand Up @@ -169,6 +178,13 @@ - (void)dismissAlert:(SDCAlertView *)alert animated:(BOOL)animated completion:(v
if ([self.alertViews count] == 0) {
self.backgroundColorView.layer.opacity = 0;
[self.backgroundColorView.layer addAnimation:opacityAnimation forKey:@"opacity"];
} else {
[[self currentAlert] setNeedsUpdateConstraints];
CATransform3D transformFrom = CATransform3DMakeScale(SDCAlertViewDismissingAnimationScale, SDCAlertViewDismissingAnimationScale, 1);
CATransform3D transformTo = CATransform3DMakeScale(1, 1, 1);
[self animateAlertTransform:[self currentAlert] from:transformFrom to:transformTo];

[self animateAlertOpacity:[self currentAlert] from:0 to:1];
}
} completionHandler:dismissBlock];
} else {
Expand Down
17 changes: 15 additions & 2 deletions SDCAlertView/SDCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "SDCAlertView.h"
#import "UIView+SDCAutoLayout.h"

@interface SDCViewController () <UITableViewDelegate>
@interface SDCViewController () <UITableViewDelegate, UIAlertViewDelegate>

@end

Expand All @@ -23,16 +23,24 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
if (indexPath.section == 0) {
[[[UIAlertView alloc] initWithTitle:@"Title"
message:@"This is a message"
delegate:nil
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil] show];
[[[UIAlertView alloc] initWithTitle:@"Title"
message:@"This is a message"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil] show];

} else if (indexPath.section == 1) {
if (indexPath.row == 0) {
[[[SDCAlertView alloc] initWithTitle:@"Title"
message:@"This is a message"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil] show];
SDCAlertView *alert2 = [[SDCAlertView alloc] initWithTitle:@"Title" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
[alert2 performSelector:@selector(show) withObject:nil afterDelay:3];
} else if (indexPath.row == 1) {
[[[SDCAlertView alloc] initWithTitle:@"Title"
message:@"This is a message"
Expand Down Expand Up @@ -132,6 +140,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (void)didPresentAlertView:(UIAlertView *)alertView {

}


- (void)updateProgressView:(NSTimer *)timer {
UIProgressView *progressView = [timer userInfo];

Expand Down

0 comments on commit 7e6b9fb

Please sign in to comment.