Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dismiss Animation Completion Block #239

Merged
merged 2 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions SCLAlertView/SCLAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

typedef NSAttributedString* (^SCLAttributedFormatBlock)(NSString *value);
typedef void (^SCLDismissBlock)(void);
typedef void (^SCLDismissAnimationCompletionBlock)(void);
typedef void (^SCLForceHideBlock)(void);

@interface SCLAlertView : UIViewController
Expand Down Expand Up @@ -246,10 +247,17 @@ typedef NS_ENUM(NSInteger, SCLAlertViewBackground)
*/
- (void)alertIsDismissed:(SCLDismissBlock)dismissBlock;

/** Warns that alerts dismiss animation is completed
*
* Warns that alerts dismiss animation is completed
*/
- (void)alertDismissAnimationIsCompleted:(SCLDismissAnimationCompletionBlock)dismissAnimationCompletionBlock;

/** Hide SCLAlertView
*
* Hide SCLAlertView using animation and removing from super view.
*/

- (void)hideView;

/** SCLAlertView visibility
Expand Down Expand Up @@ -542,6 +550,7 @@ typedef NS_ENUM(NSInteger, SCLAlertViewBackground)

#pragma mark - Custom Setters
@property(copy, nonatomic) SCLAlertViewBuilder *(^alertIsDismissed) (SCLDismissBlock dismissBlock);
@property(copy, nonatomic) SCLAlertViewBuilder *(^alertDismissAnimationIsCompleted) (SCLDismissAnimationCompletionBlock dismissAnimationCompletionBlock);
@property(copy, nonatomic) SCLAlertViewBuilder *(^removeTopCircle)(void);
@property(copy, nonatomic) SCLAlertViewBuilder *(^addCustomView)(UIView *view);
@property(copy, nonatomic) SCLAlertViewBuilder *(^addTextField)(NSString *title);
Expand Down
18 changes: 18 additions & 0 deletions SCLAlertView/SCLAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ @interface SCLAlertView () <UITextFieldDelegate, UIGestureRecognizerDelegate>
@property (strong, nonatomic) UIWindow *previousWindow;
@property (strong, nonatomic) UIWindow *SCLAlertWindow;
@property (copy, nonatomic) SCLDismissBlock dismissBlock;
@property (copy, nonatomic) SCLDismissAnimationCompletionBlock dismissAnimationCompletionBlock;
@property (weak, nonatomic) UIViewController *rootViewController;
@property (weak, nonatomic) id<UIGestureRecognizerDelegate> restoreInteractivePopGestureDelegate;
@property (assign, nonatomic) SystemSoundID soundID;
Expand Down Expand Up @@ -1170,6 +1171,10 @@ - (void)alertIsDismissed:(SCLDismissBlock)dismissBlock
self.dismissBlock = dismissBlock;
}

- (void)alertDismissAnimationIsCompleted:(SCLDismissAnimationCompletionBlock)dismissAnimationCompletionBlock{
self.dismissAnimationCompletionBlock = dismissAnimationCompletionBlock;
}

- (SCLForceHideBlock)forceHideBlock:(SCLForceHideBlock)forceHideBlock
{
_forceHideBlock = forceHideBlock;
Expand Down Expand Up @@ -1376,6 +1381,9 @@ - (void)fadeOutWithDuration:(NSTimeInterval)duration
[self.view removeFromSuperview];
[self removeFromParentViewController];
}
if ( _dismissAnimationCompletionBlock ){
self.dismissAnimationCompletionBlock();
}
}];
}

Expand Down Expand Up @@ -2011,6 +2019,16 @@ - (instancetype)initWithNewWindowWidth:(CGFloat)width {
}
return _alertIsDismissed;
}
-(SCLAlertViewBuilder *(^)(SCLDismissAnimationCompletionBlock))alertDismissAnimationIsCompleted{
if (!_alertDismissAnimationIsCompleted) {
__weak typeof(self) weakSelf = self;
_alertDismissAnimationIsCompleted = ^(SCLDismissAnimationCompletionBlock dismissAnimationCompletionBlock) {
[weakSelf.alertView alertDismissAnimationIsCompleted:dismissAnimationCompletionBlock];
return weakSelf;
};
}
return _alertDismissAnimationIsCompleted;
}
- (SCLAlertViewBuilder *(^) (void))removeTopCircle {
if (!_removeTopCircle) {
__weak typeof(self) weakSelf = self;
Expand Down