fakes.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // fakes.h
  3. // FLEX
  4. //
  5. // Created by Kevin Bradley on 12/22/20.
  6. // Copyright © 2020 Flipboard. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "FLEXMacros.h"
  10. #import "KBSlider.h"
  11. typedef NS_ENUM(NSInteger, UIFakeDatePickerMode) {
  12. UIFakeDatePickerModeTime, // Displays hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. 6 | 53 | PM)
  13. UIFakeDatePickerModeDate, // Displays month, day, and year depending on the locale setting (e.g. November | 15 | 2007)
  14. UIFakeDatePickerModeDateAndTime, // Displays date, hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. Wed Nov 15 | 6 | 53 | PM)
  15. UIFakeDatePickerModeCountDownTimer, // Displays hour and minute (e.g. 1 | 53)
  16. } ;
  17. typedef NS_ENUM(NSInteger, UIFakeDatePickerStyle) {
  18. /// Automatically pick the best style available for the current platform & mode.
  19. UIFakeDatePickerStyleAutomatic,
  20. /// Use the wheels (UIPickerView) style.
  21. UIFakeDatePickerStyleWheels,
  22. /// Use a compact style for the date picker. Editing occurs in an overlay.
  23. UIFakeDatePickerStyleCompact,
  24. };
  25. @interface UIFakeDatePicker : UIControl <NSCoding>
  26. @property (nonatomic) UIFakeDatePickerMode datePickerMode; // default is UIFakeDatePickerModeDateAndTime
  27. @property (nullable, nonatomic, strong) NSLocale *locale; // default is [NSLocale currentLocale]. setting nil returns to default
  28. @property (null_resettable, nonatomic, copy) NSCalendar *calendar; // default is [NSCalendar currentCalendar]. setting nil returns to default
  29. @property (nullable, nonatomic, strong) NSTimeZone *timeZone; // default is nil. use current time zone or time zone from calendar
  30. @property (nonatomic, strong) NSDate * _Nonnull date; // default is current dat _Nonnull e when picker created. Ignored in countdown timer mode. for that mode, picker starts at 0:00
  31. @property (nullable, nonatomic, strong) NSDate *minimumDate; // specify min/max date range. default is nil. When min > max, the values are ignored. Ignored in countdown timer mode
  32. @property (nullable, nonatomic, strong) NSDate *maximumDate; // default is nil
  33. @property (nonatomic) NSTimeInterval countDownDuration; // for UIFakeDatePickerModeCountDownTimer, ignored otherwise. default is 0.0. limit is 23:59 (86,399 seconds). value being set is div 60 (drops remaining seconds).
  34. @property (nonatomic) NSInteger minuteInterval; // display minutes wheel with interval. interval must be evenly divided into 60. default is 1. min is 1, max is 30
  35. - (void)setDate:(NSDate *_Nonnull)date animated:(BOOL)animated; // if a_Nonnullnimated is YES, animate the wheels of time to display the new date
  36. /// Request a style for the date picker. If the style changed, then the date picker may need to be resized and will generate a layout pass to display correctly.
  37. @property (nonatomic, readwrite, assign) UIFakeDatePickerStyle preferredDatePickerStyle;
  38. /// The style that the date picker is using for its layout. This property always returns a concrete style (never automatic).
  39. @property (nonatomic, readonly, assign) UIFakeDatePickerStyle datePickerStyle;
  40. @end
  41. @interface UIFakeSwitch : UIButton <NSCoding>
  42. @property(nullable, nonatomic, strong) UIColor *onTintColor;
  43. @property(nullable, nonatomic, strong) UIColor *thumbTintColor;
  44. @property(nullable, nonatomic, strong) UIImage *onImage;
  45. @property(nullable, nonatomic, strong) UIImage *offImage;
  46. @property(nonatomic,getter=isOn) BOOL on;
  47. - (instancetype _Nonnull )initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER; // This class enforces a size appropriate for the control, and so the frame size is ignored.
  48. - (nullable instancetype)initWithCoder:(NSCoder *_Nonnull)coder NS_DESIGNATED_INITIALIZER;
  49. - (void)setOn:(BOOL)on animated:(BOOL)animated; // does not send action
  50. + (id _Nonnull )newSwitch;
  51. @end
  52. @interface UIFakeSlider: UIControl <NSCoding>
  53. @property(nonatomic) float value;
  54. @property(nonatomic) float minimumValue;
  55. @property(nonatomic) float maximumValue;
  56. @property(nonatomic) float minValue;
  57. @property(nonatomic) float maxValue;
  58. @property(nonatomic) float allowedMinValue;
  59. @property(nonatomic) float allowedMaxValue;
  60. @property(nullable, nonatomic,strong) UIImage *minimumValueImage;
  61. @property(nullable, nonatomic,strong) UIImage *maximumValueImage;
  62. @property(nonatomic,getter=isContinuous) BOOL continuous;
  63. @property(nullable, nonatomic,strong) UIColor *minimumTrackTintColor;
  64. @property(nullable, nonatomic,strong) UIColor *maximumTrackTintColor;
  65. @property(nullable, nonatomic,strong) UIColor *thumbTintColor;
  66. - (void)setValue:(float)value animated:(BOOL)animated;
  67. - (void)setThumbImage:(nullable UIImage *)image forState:(UIControlState)state;
  68. - (void)setMinimumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
  69. - (void)setMaximumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
  70. - (nullable UIImage *)thumbImageForState:(UIControlState)state;
  71. - (nullable UIImage *)minimumTrackImageForState:(UIControlState)state;
  72. - (nullable UIImage *)maximumTrackImageForState:(UIControlState)state;
  73. @property(nullable,nonatomic,readonly) UIImage *currentThumbImage;
  74. @property(nullable,nonatomic,readonly) UIImage *currentMinimumTrackImage;
  75. @property(nullable,nonatomic,readonly) UIImage *currentMaximumTrackImage;
  76. // lets a subclass lay out the track and thumb as needed
  77. - (CGRect)minimumValueImageRectForBounds:(CGRect)bounds;
  78. - (CGRect)maximumValueImageRectForBounds:(CGRect)bounds;
  79. - (CGRect)trackRectForBounds:(CGRect)bounds;
  80. - (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value;
  81. @end