Skip to content

Commit

Permalink
added nullablities
Browse files Browse the repository at this point in the history
  • Loading branch information
nimati committed Aug 30, 2016
1 parent 313c09b commit ea6e329
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 60 deletions.
2 changes: 2 additions & 0 deletions Example/FCAlertView/ExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ - (IBAction)showAlert:(id)sender {
*/

[alert addButton:@"Block" withActionBlock:nil];

/* USING BLOCK ACTION FOR DONE BUTTON -- Uncomment to Try it out
[alert doneActionBlock:^{
Expand Down
36 changes: 18 additions & 18 deletions Example/Pods/FCAlertView/FCAlertView/Classes/FCAlertView.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 22 additions & 12 deletions Example/Pods/FCAlertView/FCAlertView/Classes/FCAlertView.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions FCAlertView/Classes/FCAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,34 @@
typedef void (^FCActionBlock)(void);
@property (nonatomic, copy) FCActionBlock actionBlock;
@property (nonatomic, copy) FCActionBlock doneBlock;
- (void)addButton:(NSString *)title withActionBlock:(FCActionBlock)action;
- (void)doneActionBlock:(FCActionBlock)action;
- (void)addButton:(NSString *)title withActionBlock:(nullable FCActionBlock)action;
- (void)doneActionBlock:(nullable FCActionBlock)action;

// Color Schemes

@property (nonatomic, retain) UIColor * colorScheme;
@property (nonatomic, retain) UIColor * titleColor;
@property (nonatomic, retain) UIColor * subTitleColor;
@property (nonatomic, retain) UIColor * __nullable colorScheme;
@property (nonatomic, retain) UIColor * __nullable titleColor;
@property (nonatomic, retain) UIColor * __nullable subTitleColor;

// Preset Flat Colors

@property (nonatomic, retain) UIColor * flatTurquoise;
@property (nonatomic, retain) UIColor * flatGreen;
@property (nonatomic, retain) UIColor * flatBlue;
@property (nonatomic, retain) UIColor * flatMidnight;
@property (nonatomic, retain) UIColor * flatPurple;
@property (nonatomic, retain) UIColor * flatOrange;
@property (nonatomic, retain) UIColor * flatRed;
@property (nonatomic, retain) UIColor * flatSilver;
@property (nonatomic, retain) UIColor * flatGray;
@property (nonatomic, retain) UIColor * __nullable flatTurquoise;
@property (nonatomic, retain) UIColor * __nullable flatGreen;
@property (nonatomic, retain) UIColor * __nullable flatBlue;
@property (nonatomic, retain) UIColor * __nullable flatMidnight;
@property (nonatomic, retain) UIColor * __nullable flatPurple;
@property (nonatomic, retain) UIColor * __nullable flatOrange;
@property (nonatomic, retain) UIColor * __nullable flatRed;
@property (nonatomic, retain) UIColor * __nullable flatSilver;
@property (nonatomic, retain) UIColor * __nullable flatGray;

@end

@protocol FCAlertViewDelegate <NSObject>
@optional
- (void)FCAlertView:(FCAlertView *)alertView clickedButtonIndex:(NSInteger)index buttonTitle:(NSString *)title;
- (void)FCAlertViewDismissed:(FCAlertView *)alertView;
- (void)FCAlertViewWillAppear:(FCAlertView *)alertView;
- (void)FCAlertDoneButtonClicked:(FCAlertView *)alertView;
- (void)FCAlertView:( FCAlertView * _Null_unspecified )alertView clickedButtonIndex:(NSInteger)index buttonTitle:(NSString * _Null_unspecified)title;
- (void)FCAlertViewDismissed:(FCAlertView * _Null_unspecified)alertView;
- (void)FCAlertViewWillAppear:(FCAlertView * _Null_unspecified)alertView;
- (void)FCAlertDoneButtonClicked:(FCAlertView * _Null_unspecified)alertView;

@end
34 changes: 22 additions & 12 deletions FCAlertView/Classes/FCAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ - (void)drawRect:(CGRect)rect {
alertViewVector = [UIButton buttonWithType:UIButtonTypeCustom];
else
alertViewVector = [UIButton buttonWithType:UIButtonTypeSystem];

alertViewVector.frame = CGRectMake(alertViewContents.frame.size.width/2 - 15.0f,
-15.0f,
30.0f,
Expand Down Expand Up @@ -577,12 +577,12 @@ - (void) showAlertInView:(UIViewController *)view withTitle:(NSString *)title wi

if (!alertViewWithVector)
vectorImage = image;

// Checks prior to presenting View

[self checkCustomizationValid];
[self safetyCloseCheck];

[view.view.window addSubview:self];

}
Expand Down Expand Up @@ -627,37 +627,47 @@ - (void) dismissAlertView {

}

#pragma mark - Action Block Methods

- (void)addButton:(NSString *)title withActionBlock:(FCActionBlock)action {

if (alertButtons.count < 2)
[alertButtons addObject:@{@"title" : title,
@"action" : action}];
if (alertButtons.count < 2) {
if (action != nil)
[alertButtons addObject:@{@"title" : title,
@"action" : action}];
else
[alertButtons addObject:@{@"title" : title,
@"action" : @0}];
}

_numberOfButtons = alertButtons.count;

}

- (void)doneActionBlock:(FCActionBlock)action {

self.doneBlock = action;
if (action != nil)
self.doneBlock = action;

}

#pragma mark - ACTIONS
#pragma mark Button Selection

- (void)handleButton:(id)sender {

id<FCAlertViewDelegate> strongDelegate = self.delegate;

UIButton *clickedButton = (UIButton*)sender;

NSDictionary *btnDict = [alertButtons objectAtIndex:[sender tag]];

if ([btnDict objectForKey:@"action"] != nil && ![[btnDict objectForKey:@"action"] isEqual:@0]) {
FCActionBlock block = [btnDict objectForKey:@"action"];
if (block)
block();
if (btnDict != nil) {
if ([btnDict objectForKey:@"action"] != nil && ![[btnDict objectForKey:@"action"] isEqual:@0]) {
FCActionBlock block = [btnDict objectForKey:@"action"];
if (block)
block();
}
}

if ([strongDelegate respondsToSelector:@selector(FCAlertView:clickedButtonIndex:buttonTitle:)]) {
Expand Down

0 comments on commit ea6e329

Please sign in to comment.