From 9b6e806439323712066e2adc5fedca2972adb3a3 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 15 Oct 2014 12:09:20 +0300 Subject: [PATCH] - General fixes for #74 & #50 - Remove unused init function. - Add CountDownTimer support to blocks. - Remove redudant countDownDuration init --- Pickers/ActionSheetDatePicker.h | 5 +---- Pickers/ActionSheetDatePicker.m | 22 ++++++---------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Pickers/ActionSheetDatePicker.h b/Pickers/ActionSheetDatePicker.h index 209a54ff0..448ebdbe6 100755 --- a/Pickers/ActionSheetDatePicker.h +++ b/Pickers/ActionSheetDatePicker.h @@ -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 @@ -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 diff --git a/Pickers/ActionSheetDatePicker.m b/Pickers/ActionSheetDatePicker.m index 52f29e470..74700b22e 100755 --- a/Pickers/ActionSheetDatePicker.m +++ b/Pickers/ActionSheetDatePicker.m @@ -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; } @@ -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; @@ -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])