fakes.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. typedef NS_ENUM(NSInteger, UIFakeDatePickerMode) {
  11. UIFakeDatePickerModeTime, // Displays hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. 6 | 53 | PM)
  12. UIFakeDatePickerModeDate, // Displays month, day, and year depending on the locale setting (e.g. November | 15 | 2007)
  13. UIFakeDatePickerModeDateAndTime, // Displays date, hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. Wed Nov 15 | 6 | 53 | PM)
  14. UIFakeDatePickerModeCountDownTimer, // Displays hour and minute (e.g. 1 | 53)
  15. } ;
  16. typedef NS_ENUM(NSInteger, UIFakeDatePickerStyle) {
  17. /// Automatically pick the best style available for the current platform & mode.
  18. UIFakeDatePickerStyleAutomatic,
  19. /// Use the wheels (UIPickerView) style.
  20. UIFakeDatePickerStyleWheels,
  21. /// Use a compact style for the date picker. Editing occurs in an overlay.
  22. UIFakeDatePickerStyleCompact,
  23. };
  24. @interface UIFakeDatePicker : UIControl <NSCoding>
  25. @property (nonatomic) UIFakeDatePickerMode datePickerMode; // default is UIFakeDatePickerModeDateAndTime
  26. @property (nullable, nonatomic, strong) NSLocale *locale; // default is [NSLocale currentLocale]. setting nil returns to default
  27. @property (null_resettable, nonatomic, copy) NSCalendar *calendar; // default is [NSCalendar currentCalendar]. setting nil returns to default
  28. @property (nullable, nonatomic, strong) NSTimeZone *timeZone; // default is nil. use current time zone or time zone from calendar
  29. @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
  30. @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
  31. @property (nullable, nonatomic, strong) NSDate *maximumDate; // default is nil
  32. @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).
  33. @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
  34. - (void)setDate:(NSDate *_Nonnull)date animated:(BOOL)animated; // if a_Nonnullnimated is YES, animate the wheels of time to display the new date
  35. /// 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.
  36. @property (nonatomic, readwrite, assign) UIFakeDatePickerStyle preferredDatePickerStyle;
  37. /// The style that the date picker is using for its layout. This property always returns a concrete style (never automatic).
  38. @property (nonatomic, readonly, assign) UIFakeDatePickerStyle datePickerStyle;
  39. @end
  40. @interface UIFakeSwitch : UIButton <NSCoding>
  41. @property(nullable, nonatomic, strong) UIColor *onTintColor;
  42. @property(nullable, nonatomic, strong) UIColor *thumbTintColor;
  43. @property(nullable, nonatomic, strong) UIImage *onImage;
  44. @property(nullable, nonatomic, strong) UIImage *offImage;
  45. @property(nonatomic,getter=isOn) BOOL on;
  46. - (instancetype _Nonnull )initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER; // This class enforces a size appropriate for the control, and so the frame size is ignored.
  47. - (nullable instancetype)initWithCoder:(NSCoder *_Nonnull)coder NS_DESIGNATED_INITIALIZER;
  48. - (void)setOn:(BOOL)on animated:(BOOL)animated; // does not send action
  49. + (id _Nonnull )newSwitch;
  50. @end
  51. @interface UIFakeSlider: UIControl <NSCoding>
  52. @property(nonatomic) float value;
  53. @property(nonatomic) float minimumValue;
  54. @property(nonatomic) float maximumValue;
  55. @property(nonatomic) float minValue;
  56. @property(nonatomic) float maxValue;
  57. @property(nonatomic) float allowedMinValue;
  58. @property(nonatomic) float allowedMaxValue;
  59. @property(nullable, nonatomic,strong) UIImage *minimumValueImage;
  60. @property(nullable, nonatomic,strong) UIImage *maximumValueImage;
  61. @property(nonatomic,getter=isContinuous) BOOL continuous;
  62. @property(nullable, nonatomic,strong) UIColor *minimumTrackTintColor;
  63. @property(nullable, nonatomic,strong) UIColor *maximumTrackTintColor;
  64. @property(nullable, nonatomic,strong) UIColor *thumbTintColor;
  65. - (void)setValue:(float)value animated:(BOOL)animated;
  66. - (void)setThumbImage:(nullable UIImage *)image forState:(UIControlState)state;
  67. - (void)setMinimumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
  68. - (void)setMaximumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
  69. - (nullable UIImage *)thumbImageForState:(UIControlState)state;
  70. - (nullable UIImage *)minimumTrackImageForState:(UIControlState)state;
  71. - (nullable UIImage *)maximumTrackImageForState:(UIControlState)state;
  72. @property(nullable,nonatomic,readonly) UIImage *currentThumbImage;
  73. @property(nullable,nonatomic,readonly) UIImage *currentMinimumTrackImage;
  74. @property(nullable,nonatomic,readonly) UIImage *currentMaximumTrackImage;
  75. // lets a subclass lay out the track and thumb as needed
  76. - (CGRect)minimumValueImageRectForBounds:(CGRect)bounds;
  77. - (CGRect)maximumValueImageRectForBounds:(CGRect)bounds;
  78. - (CGRect)trackRectForBounds:(CGRect)bounds;
  79. - (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value;
  80. @end