Skip to content

Commit

Permalink
Reorganize SDCAlertViewCoordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
sberrevoets committed Mar 29, 2014
1 parent 86534fb commit 19436dd
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions SDCAlertView/SDCAlertViewCoordinator.m
Expand Up @@ -61,6 +61,8 @@ + (instancetype)sharedCoordinator {
return sharedCoordinator;
}

#pragma mark - Transition Queue

- (BOOL)enqueuePresentingAnimationOfAlert:(SDCAlertView *)alert {
if (!self.presentingAlert && !self.dismissingAlert)
return NO;
Expand Down Expand Up @@ -92,24 +94,15 @@ - (BOOL)enqueueDismissingAnimationOfAlert:(SDCAlertView *)alert withButtonIndex:
return YES;
}

- (void)presentAlert:(SDCAlertView *)alert {
if ([self enqueuePresentingAnimationOfAlert:alert])
return;

[self.alerts addObject:alert];

if (self.presentingAlert)
return;

if (!self.visibleAlert)
[self makeAlertWindowKeyWindow];
- (void)dequeueNextTransition {
NSInvocation *nextInvocation = [self.transitionQueue firstObject];
[self.transitionQueue removeObject:nextInvocation];

[alert willBePresented];
[self showAlert:alert replacingAlert:self.visibleAlert completion:^{
[alert wasPresented];
}];
[nextInvocation invokeWithTarget:self];
}

#pragma mark - Presenting & Dismissing

- (void)showAlert:(SDCAlertView *)newAlert replacingAlert:(SDCAlertView *)oldAlert completion:(void(^)())completionHandler {
if (!newAlert)
[self resaturateUI];
Expand All @@ -134,11 +127,19 @@ - (void)showAlert:(SDCAlertView *)newAlert replacingAlert:(SDCAlertView *)oldAle
}];
}

- (void)dequeueNextTransition {
NSInvocation *nextInvocation = [self.transitionQueue firstObject];
[self.transitionQueue removeObject:nextInvocation];
- (void)presentAlert:(SDCAlertView *)alert {
if ([self enqueuePresentingAnimationOfAlert:alert])
return;

[nextInvocation invokeWithTarget:self];
[self.alerts addObject:alert];

if (!self.visibleAlert)
[self makeAlertWindowKeyWindow];

[alert willBePresented];
[self showAlert:alert replacingAlert:self.visibleAlert completion:^{
[alert wasPresented];
}];
}

- (void)dismissAlert:(SDCAlertView *)alert withButtonIndex:(NSInteger)buttonIndex {
Expand Down Expand Up @@ -168,6 +169,8 @@ - (BOOL)dismissAlertImmediately:(SDCAlertView *)alert withButtonIndex:(NSInteger
return YES;
}

#pragma mark - Window Switching

- (void)resaturateUI {
self.userWindow.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
}
Expand Down

0 comments on commit 19436dd

Please sign in to comment.