Browse Source

cleaned out UIFakeSlider stub code and did cleanup related to that. took out menu controller from globals for tvOS since its not applicable.

Kevin Bradley 3 years ago
parent
commit
75b3cbcf99

+ 2 - 0
Classes/GlobalStateExplorers/Globals/FLEXGlobalsViewController.m

@@ -137,7 +137,9 @@
                 [self globalsEntryForRow:FLEXGlobalsRowURLSession],
                 [self globalsEntryForRow:FLEXGlobalsRowURLCache],
                 [self globalsEntryForRow:FLEXGlobalsRowNotificationCenter],
+#if !TARGET_OS_TV
                 [self globalsEntryForRow:FLEXGlobalsRowMenuController],
+#endif
                 [self globalsEntryForRow:FLEXGlobalsRowFileManager],
                 [self globalsEntryForRow:FLEXGlobalsRowTimeZone],
                 [self globalsEntryForRow:FLEXGlobalsRowLocale],

+ 1 - 1
Classes/Network/FLEXNetworkSettingsController.m

@@ -116,7 +116,7 @@
     [NSUserDefaults.standardUserDefaults flex_toggleBoolForKey:kFLEXDefaultsRegisterJSONExplorerKey];
 }
 
-- (void)cacheLimitAdjusted:(UIFakeSlider *)sender {
+- (void)cacheLimitAdjusted:(KBSlider *)sender {
     self.cacheLimitValue = sender.value;
 }
 

+ 2 - 3
Classes/ViewHierarchy/SnapshotExplorer/FHSSnapshotView.h

@@ -30,12 +30,11 @@ NS_ASSUME_NONNULL_BEGIN
 
 /// Views of these classes will have their headers hidden
 @property (nonatomic) NSArray<Class> *headerExclusions;
+@property (nonatomic, readonly) FHSRangeSlider *depthSlider; //this is a UIControl, it wont work OOB on tvOS but the snapshot viewer isnt working on tvOS anyway, moot for now.
 #if !TARGET_OS_TV
 @property (nonatomic, readonly) UISlider *spacingSlider;
-@property (nonatomic, readonly) FHSRangeSlider *depthSlider;
 #else
-@property (nonatomic, readonly) UIFakeSlider *spacingSlider;
-@property (nonatomic, readonly) UIFakeSlider *depthSlider;
+@property (nonatomic, readonly) KBSlider *spacingSlider;
 #endif
 
 - (void)emphasizeViews:(NSArray<UIView *> *)emphasizedViews;

+ 3 - 7
Classes/ViewHierarchy/SnapshotExplorer/FHSSnapshotView.m

@@ -69,7 +69,7 @@
     #if !TARGET_OS_TV
     _spacingSlider = [UISlider new];
     #else
-    _spacingSlider = [UIFakeSlider new];
+    _spacingSlider = [KBSlider new];
     #endif
     self.spacingSlider.minimumValue = 0;
     self.spacingSlider.maximumValue = 100;
@@ -84,11 +84,7 @@
 }
 
 - (void)initDepthSlider {
-    #if !TARGET_OS_TV
     _depthSlider = [FHSRangeSlider new];
-    #else
-    _depthSlider = [UIFakeSlider new];
-    #endif
     [self.depthSlider
         addTarget:self
         action:@selector(depthSliderDidChange:)
@@ -281,7 +277,7 @@
     }
 }
 
-- (void)spacingSliderDidChange:(UIFakeSlider *)slider {
+- (void)spacingSliderDidChange:(KBSlider *)slider { //easier to make a KBSlider since they are API compatible - one less #if macro!
     // TODO: hiding the header when flat logic
 
     for (FHSSnapshotNodes *nodes in self.nodesMap.allValues) {
@@ -301,7 +297,7 @@
     }
 }
 
-- (void)depthSliderDidChange:(UIFakeSlider *)slider {
+- (void)depthSliderDidChange:(FHSRangeSlider *)slider {
     CGFloat min = slider.minValue, max = slider.maxValue;
     for (FHSSnapshotNodes *nodes in self.nodesMap.allValues) {
         CGFloat depth = nodes.depth;

+ 1 - 1
Classes/tvOS/KBSlider.h

@@ -24,7 +24,7 @@ typedef NS_ENUM(NSInteger, DPadState) {
 @property CGFloat value;
 @property CGFloat minimumValue;
 @property CGFloat maximumValue;
-@property BOOL isContinuous;
+@property(nonatomic,getter=isContinuous) BOOL continuous;
 @property UIColor *maximumTrackTintColor;
 @property UIColor *minimumTrackTintColor;
 @property UIColor *thumbTintColor;

+ 10 - 1
Classes/tvOS/KBSlider.m

@@ -16,6 +16,7 @@
     UIColor *_minimumTrackTintColor;
     UIColor *_thumbTintColor;
     CGFloat _focusScaleFactor;
+    BOOL _continuous;
     
     BOOL _isEnabled;
     BOOL _isSelected;
@@ -84,7 +85,7 @@
     
     _storedValue = _defaultValue;
     _dPadState = DPadStateSelect;
-    _isContinuous = _defaultIsContinuous;
+    _continuous = _defaultIsContinuous;
     
     _minimumTrackViewImages = [NSMutableDictionary new];
     _maximumTrackViewImages = [NSMutableDictionary new];
@@ -101,6 +102,14 @@
     
 }
 
+- (BOOL)isContinuous {
+    return _continuous;
+}
+
+- (void)setContinuous:(BOOL)continuous {
+    _continuous = continuous;
+}
+
 - (void)setSelected:(BOOL)selected {
     _isSelected = selected;
     [self updateStateDependantViews];

+ 0 - 41
Classes/tvOS/fakes.h

@@ -72,44 +72,3 @@ typedef NS_ENUM(NSInteger, TVTableViewCellAccessoryType) {
 - (void)setOn:(BOOL)on animated:(BOOL)animated; // does not send action
 + (id _Nonnull )newSwitch;
 @end
-
-//Stub slider, any instances that still use this are only in the snapshot baesd views which dont work yet, this will be pruned once that update is made.
-
-@interface UIFakeSlider: UIControl <NSCoding>
-@property(nonatomic) float value;
-@property(nonatomic) float minimumValue;
-@property(nonatomic) float maximumValue;
-@property(nonatomic) float minValue;
-@property(nonatomic) float maxValue;
-@property(nonatomic) float allowedMinValue;
-@property(nonatomic) float allowedMaxValue;
-@property(nullable, nonatomic,strong) UIImage *minimumValueImage;
-@property(nullable, nonatomic,strong) UIImage *maximumValueImage;
-
-@property(nonatomic,getter=isContinuous) BOOL continuous;
-
-@property(nullable, nonatomic,strong) UIColor *minimumTrackTintColor;
-@property(nullable, nonatomic,strong) UIColor *maximumTrackTintColor;
-@property(nullable, nonatomic,strong) UIColor *thumbTintColor;
-
-- (void)setValue:(float)value animated:(BOOL)animated;
-
-- (void)setThumbImage:(nullable UIImage *)image forState:(UIControlState)state;
-- (void)setMinimumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
-- (void)setMaximumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
-
-- (nullable UIImage *)thumbImageForState:(UIControlState)state;
-- (nullable UIImage *)minimumTrackImageForState:(UIControlState)state;
-- (nullable UIImage *)maximumTrackImageForState:(UIControlState)state;
-
-@property(nullable,nonatomic,readonly) UIImage *currentThumbImage;
-@property(nullable,nonatomic,readonly) UIImage *currentMinimumTrackImage;
-@property(nullable,nonatomic,readonly) UIImage *currentMaximumTrackImage;
-
-// lets a subclass lay out the track and thumb as needed
-- (CGRect)minimumValueImageRectForBounds:(CGRect)bounds;
-- (CGRect)maximumValueImageRectForBounds:(CGRect)bounds;
-- (CGRect)trackRectForBounds:(CGRect)bounds;
-- (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value;
-
-@end

+ 36 - 49
Classes/tvOS/fakes.m

@@ -67,6 +67,39 @@
     return _isOn;
 }
 
+- (void)initDefaults {
+    self.onTintColor = [UIColor greenColor];
+}
+
+- (instancetype)initWithCoder:(NSCoder *)coder {
+    self = [super initWithCoder:coder];
+    if (self){
+        [self initDefaults];
+    }
+    return self;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (self){
+        [self initDefaults];
+    }
+    return self;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    self = [super initWithFrame:frame];
+    if (self){
+        [self initDefaults];
+    }
+    return self;
+}
+
+- (UIColor *)backgroundColor {
+    if ([self isOn]) return self.onTintColor;
+    return [super backgroundColor];
+}
+
 - (void)setOn:(BOOL)on{
     [self setOn:on animated:true];
 }
@@ -90,56 +123,10 @@
 }
 
 + (id)newSwitch {
-    return [UIFakeSwitch buttonWithType:UIButtonTypeSystem];
-}
-
--(instancetype)initWithFrame:(CGRect)frame {
-    return [super initWithFrame:frame];
-}
-
-- (instancetype)initWithCoder:(id)coder {
-    return [super initWithCoder:coder];
+    UIFakeSwitch *new = [UIFakeSwitch buttonWithType:UIButtonTypeSystem];
+    [new initDefaults];
+    return new;
 }
 
 @end
 
-@implementation UIFakeSlider
-
-- (void)setValue:(float)value animated:(BOOL)animated {
-    
-}
-
-- (void)setThumbImage:(nullable UIImage *)image forState:(UIControlState)state {
-    
-}
-- (void)setMinimumTrackImage:(nullable UIImage *)image forState:(UIControlState)state {
-    
-}
-- (void)setMaximumTrackImage:(nullable UIImage *)image forState:(UIControlState)state {
-    
-}
-
-- (nullable UIImage *)thumbImageForState:(UIControlState)state {
-    return nil;
-}
-- (nullable UIImage *)minimumTrackImageForState:(UIControlState)state {
-    return nil;
-}
-- (nullable UIImage *)maximumTrackImageForState:(UIControlState)state {
-    return nil;
-}
-
-- (CGRect)minimumValueImageRectForBounds:(CGRect)bounds {
-    return CGRectZero;
-}
-- (CGRect)maximumValueImageRectForBounds:(CGRect)bounds {
-    return CGRectZero;
-}
-- (CGRect)trackRectForBounds:(CGRect)bounds {
-    return CGRectZero;
-}
-- (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value {
-    return CGRectZero;
-}
-
-@end