KBDatePickerView.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #import <UIKit/UIKit.h>
  2. #import "Macros.h"
  3. #define NUMBER_OF_CELLS 100000
  4. #define TABLE_TAG(XX) \
  5. XX(KBTableViewTagMonths, = 501) \
  6. XX(KBTableViewTagDays, )\
  7. XX(KBTableViewTagYears, )\
  8. XX(KBTableViewTagHours, )\
  9. XX(KBTableViewTagMinutes, )\
  10. XX(KBTableViewTagAMPM, )\
  11. XX(KBTaleViewWeekday, )
  12. DECLARE_ENUM(KBTableViewTag, TABLE_TAG)
  13. #define PICKER_MODE(XX) \
  14. XX(KBDatePickerModeTime, ) \
  15. XX(KBDatePickerModeDate, ) \
  16. XX(KBDatePickerModeDateAndTime, ) \
  17. XX(KBDatePickerModeCountDownTimer, )
  18. DECLARE_ENUM(KBDatePickerMode, PICKER_MODE)
  19. @interface UIView (Helper)
  20. -(void)removeAllSubviews;
  21. @end
  22. @interface UIStackView (Helper)
  23. - (void)removeAllArrangedSubviews;
  24. - (void)setArrangedViews:(NSArray * _Nonnull )views;
  25. @end
  26. @interface KBTableView: UITableView
  27. @property NSIndexPath * _Nullable selectedIndexPath;
  28. @property CGFloat customWidth;
  29. @property id _Nullable selectedValue;
  30. - (instancetype _Nonnull )initWithTag:(KBTableViewTag)tag delegate:(id _Nonnull )delegate;
  31. - (id _Nullable )valueForIndexPath:(NSIndexPath *_Nonnull)indexPath;
  32. - (NSArray *_Nonnull)visibleValues;
  33. @end
  34. // Enums are all defined like this to make it easier to convert them to / from string versions of themselves.
  35. @interface KBDatePickerView: UIControl <UITableViewDelegate, UITableViewDataSource>
  36. @property (nonnull, nonatomic, strong) NSDate *date;
  37. @property (nullable, nonatomic, strong) NSDate *minimumDate;
  38. @property (nullable, nonatomic, strong) NSDate *maximumDate;
  39. @property BOOL showDateLabel;
  40. @property KBDatePickerMode datePickerMode;
  41. @property NSInteger topOffset;
  42. @property (nonatomic, copy, nullable) void (^itemSelectedBlock)(NSDate * _Nullable date);
  43. +(id _Nonnull )todayInYear:(NSInteger)year;
  44. + (NSDateFormatter * _Nonnull )sharedDateFormatter;
  45. @end
  46. #define DLog(format, ...) CFShow((__bridge CFStringRef)[NSString stringWithFormat:format, ## __VA_ARGS__]);
  47. #define LOG_SELF NSLog(@"[KBDatePickerView] %@ %@", self, NSStringFromSelector(_cmd))
  48. #define DPLog(format, ...) NSLog(@"[KBDatePickerView] %@",[NSString stringWithFormat:format, ## __VA_ARGS__]);
  49. #define DLOG_SELF DLog(@"%@ %@", self, NSStringFromSelector(_cmd))