fakes.m 2.7 KB

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