Skip to content

Commit

Permalink
- General fixes for #74 & #50
Browse files Browse the repository at this point in the history
- Remove unused init function.
- Add CountDownTimer support to blocks.
- Remove redudant countDownDuration init
  • Loading branch information
skywinder committed Oct 15, 2014
1 parent 00ac4f1 commit 9b6e806
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
5 changes: 1 addition & 4 deletions Pickers/ActionSheetDatePicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@class ActionSheetDatePicker;

typedef void(^ActionDateDoneBlock)(ActionSheetDatePicker *picker, NSDate *selectedDate, id origin);
typedef void(^ActionDateDoneBlock)(ActionSheetDatePicker *picker, id selectedDate, id origin); //selectedDate is NSDate or NSNumber for "UIDatePickerModeCountDownTimer"
typedef void(^ActionDateCancelBlock)(ActionSheetDatePicker *picker);

@interface ActionSheetDatePicker : AbstractActionSheetPicker
Expand Down Expand Up @@ -61,9 +61,6 @@ typedef void(^ActionDateCancelBlock)(ActionSheetDatePicker *picker);

- (id)initWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate target:(id)target action:(SEL)action origin:(id)origin cancelAction:(SEL)cancelAction;

// mgm: additional initializer which allows to set countdownduration
- (id)initWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode countDownDuration:(NSTimeInterval)duration target:(id)target action:(SEL)action origin:(id)origin cancelAction:(SEL)cancelAction;


- (instancetype)initWithTitle:(NSString *)title
datePickerMode:(UIDatePickerMode)datePickerMode
Expand Down
22 changes: 6 additions & 16 deletions Pickers/ActionSheetDatePicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,6 @@ - (id)initWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePicke
self.title = title;
self.datePickerMode = datePickerMode;
self.selectedDate = selectedDate;
self.countDownDuration = 60;
}
return self;
}

// mgm: additional initializer which allows to set countdownduration
- (id)initWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode countDownDuration:(NSTimeInterval)duration target:(id)target action:(SEL)action origin:(id)origin cancelAction:(SEL)cancelAction
{
self = [super initWithTarget:target successAction:action cancelAction:cancelAction origin:origin];
if (self) {
self.title = title;
self.datePickerMode = datePickerMode;
self.countDownDuration = duration;
}
return self;
}
Expand Down Expand Up @@ -118,8 +105,7 @@ - (UIView *)configuredPickerView {
datePicker.timeZone = self.timeZone;
datePicker.locale = self.locale;

// mgm: Set the datePicker according to mode
// if datepicker is set with a date in countdownmode then
// if datepicker is set with a date in countDownMode then
// 1h is added to the initial countdown
if (self.datePickerMode == UIDatePickerModeCountDownTimer) {
datePicker.countDownDuration = self.countDownDuration;
Expand All @@ -139,7 +125,11 @@ - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)action origin:(id)orig
{
if (self.onActionSheetDone)
{
self.onActionSheetDone(self, self.selectedDate, origin);
if (self.datePickerMode == UIDatePickerModeCountDownTimer)
self.onActionSheetDone(self, @(self.countDownDuration), origin);
else
self.onActionSheetDone(self, self.selectedDate, origin);

return;
}
else if ([target respondsToSelector:action])
Expand Down

0 comments on commit 9b6e806

Please sign in to comment.