fakes.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 "fakes.h"
  9. @implementation UIFakeDatePicker
  10. - (void)setCalendar:(NSCalendar *)calendar {
  11. }
  12. - (void)setDate:(NSDate *_Nonnull)date animated:(BOOL)animated {
  13. }
  14. - (NSCalendar *)calendar {
  15. return [NSCalendar currentCalendar];
  16. }
  17. - (NSInteger) numberOfComponents {
  18. return 0;
  19. }
  20. - (NSInteger)numberOfRowsInComponent:(NSInteger)component {
  21. return 0;
  22. }
  23. - (CGSize)rowSizeForComponent:(NSInteger)component {
  24. return CGSizeZero;
  25. }
  26. - (nullable UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component {
  27. return nil;
  28. }
  29. // Reloading whole view or single component
  30. - (void)reloadAllComponents {
  31. }
  32. - (void)reloadComponent:(NSInteger)component {
  33. }
  34. // selection. in this case, it means showing the appropriate row in the middle
  35. - (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated {
  36. }
  37. - (NSInteger)selectedRowInComponent:(NSInteger)component {
  38. return -1;
  39. }
  40. @end
  41. @interface UIFakeSwitch() {
  42. BOOL _isOn;
  43. }
  44. @end
  45. @implementation UIFakeSwitch
  46. - (BOOL)isOn {
  47. return _isOn;
  48. }
  49. - (void)setOn:(BOOL)on{
  50. [self setOn:on animated:true];
  51. }
  52. - (NSString *)onTitle {
  53. return @"TRUE";
  54. }
  55. - (NSString *)offTitle {
  56. return @"FALSE";
  57. }
  58. - (void)setOn:(BOOL)on animated:(BOOL)animated {
  59. _isOn = on;
  60. if (_isOn){
  61. [self setTitle:[self onTitle] forState:UIControlStateNormal];
  62. } else {
  63. [self setTitle:[self offTitle] forState:UIControlStateNormal];
  64. }
  65. //[self sendActionsForControlEvents:[self allControlEvents]];
  66. }
  67. + (id)newSwitch {
  68. return [UIFakeSwitch buttonWithType:UIButtonTypeSystem];
  69. }
  70. -(instancetype)initWithFrame:(CGRect)frame {
  71. return [super initWithFrame:frame];
  72. }
  73. - (instancetype)initWithCoder:(id)coder {
  74. LOG_SELF;
  75. return [super initWithCoder:coder];
  76. }
  77. @end
  78. @implementation UIFakeSlider
  79. - (void)setValue:(float)value animated:(BOOL)animated {
  80. }
  81. - (void)setThumbImage:(nullable UIImage *)image forState:(UIControlState)state {
  82. }
  83. - (void)setMinimumTrackImage:(nullable UIImage *)image forState:(UIControlState)state {
  84. }
  85. - (void)setMaximumTrackImage:(nullable UIImage *)image forState:(UIControlState)state {
  86. }
  87. - (nullable UIImage *)thumbImageForState:(UIControlState)state {
  88. return nil;
  89. }
  90. - (nullable UIImage *)minimumTrackImageForState:(UIControlState)state {
  91. return nil;
  92. }
  93. - (nullable UIImage *)maximumTrackImageForState:(UIControlState)state {
  94. return nil;
  95. }
  96. - (CGRect)minimumValueImageRectForBounds:(CGRect)bounds {
  97. return CGRectZero;
  98. }
  99. - (CGRect)maximumValueImageRectForBounds:(CGRect)bounds {
  100. return CGRectZero;
  101. }
  102. - (CGRect)trackRectForBounds:(CGRect)bounds {
  103. return CGRectZero;
  104. }
  105. - (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value {
  106. return CGRectZero;
  107. }
  108. @end