

#import <UIKit/UIKit.h>
@class SLDatePickerDO;
@class SLDatePickView;
@protocol SLDatePickerDelegate;

typedef void (^CancleBtnClickBlock)(void);
typedef void (^SLDatePickSureBtnClickBlock)(NSString * _Nullable str);

/**
 日期控件样式

 - SLDatePickerYM: 年月/年
 - SLDatePickerYMD: 年月日
 - SLDatePickerHM: 时分
 */
typedef NS_ENUM(NSUInteger, SLDatePickerStyle) {
    SLDatePickerYM,
    SLDatePickerYMD,
    SLDatePickerHM,
};


NS_ASSUME_NONNULL_BEGIN

@interface SLDatePickView : UIView


/**
 *  @brief 实例化
 *
 *  @param dateStyle 日期样式
 *  @param pickerDO  日期数据项
 *
 *  @return PCDatePicker
 */
-(nonnull id)initWithStyle:(SLDatePickerStyle)dateStyle pickerData:(nonnull SLDatePickerDO *)pickerDO;

/**
 *  @brief 代理
 */
@property(nullable,nonatomic,strong) id<SLDatePickerDelegate> delegate;

- (void)show;

/**
 *  @brief 日期选择器的样式
 */
@property(nonatomic,assign) SLDatePickerStyle dateStyle;

/**
 *  @brief 数据项
 */
@property(nullable,nonatomic,strong) SLDatePickerDO *pickerDO;

@property(nonatomic, copy)CancleBtnClickBlock cancleBtnClickBlock;

@property (nonatomic, copy)SLDatePickSureBtnClickBlock resultBlock;

- (void)setTitleLabelText:(NSString *)text;

@end



@interface SLDatePickerDO : NSObject

/**
 *  @brief ID
 */
@property (nonatomic, copy) NSString *strID;

/**
 *  @brief 已经选择的日期内容
 */
@property (nonatomic, copy) NSString *strText;

/**
 *  @brief 最小日期
 */
@property (nonatomic, copy) NSString *minDateString;

/**
 *  @brief 最大日期
 */
@property (nonatomic, copy) NSString *maxDateString;

/**
 *  @brief 日期格式
 */
@property (nonatomic, copy) NSString *format;

/**
 *  @brief 回调函数
 */
@property (nonatomic, copy) NSString *callbackString;


@end


@protocol SLDatePickerDelegate <NSObject>

@optional
/**
 *  @brief 选中日期代理
 *
 *  @param customPicker     PCDatePicker
 *  @param resultDateString 返回日期字符串
 */
-(void)datePick:(nonnull SLDatePickView *)customPicker result:(nullable NSString *)resultDateString;
/**
 *  @brief 取消选择代理
 *
 *  @param customPicker PCDatePicker
 */
-(void)datePickerDidCancel:(nonnull SLDatePickView *)customPicker;

@end


#define kITLocalDate(date) \
\
NSTimeZone *zone = [NSTimeZone systemTimeZone];\
NSInteger interval = [zone secondsFromGMTForDate:date];\
date = [date dateByAddingTimeInterval:interval]

@interface SLCustDatePickView : UIView

/**
 The maximum date defaults to December 2100
 */
@property (nullable, copy, nonatomic) NSDate *maximumDate;

/**
 You can set the default date or default year or defalut month
 The default select date is now
 */
@property (nullable, copy, nonatomic) NSDate *defaultDate;

/**
 The minimum default date is January 1900
 */
@property (nullable, copy, nonatomic) NSDate *minimumDate;

/**
 Whether to show "today", default is yes
 If today is displayed, the maximum date is now
 If you do not show today, the minimum date defaults to January 1900, the maximum date defaults to December 2100,
 */
@property (nonatomic, getter = isShowToday) BOOL showToday;

/**
 You can set the default date or default year or defalut month
 Default is this year
 minimumDate <= defaultYear <= maximumDate
 */
@property (nonatomic) NSInteger defaultYear;

/**
 You can set the default date or default year or defalut month
 Default is this month
 1 < defaultMonth < 12
 */
@property (nonatomic) NSInteger defaultMonth;

@property (nonatomic, assign) NSInteger selectedYear;
@property (nonatomic, assign) NSInteger selectedMonth;
@property (strong, nonatomic) NSDateFormatter *dateFormatter;

/**
 Refresh the data
 */
- (void)refreshData;

@end


NS_ASSUME_NONNULL_END
