Parcourir la source

a bit of macro cleanup where possible, this is likely the best and cleanest that can be done while maintaining support on iOS and tvOS

Kevin Bradley il y a 5 ans
Parent
commit
02258fa9ef

+ 1 - 3
Classes/Editing/ArgumentInputViews/FLEXArgumentInputTextView.m

@@ -31,6 +31,7 @@
         self.inputTextView = [[KBSelectableTextView alloc] initWithFrame:CGRectZero];
         #else
         self.inputTextView = [UITextView new];
+        self.inputTextView.inputAccessoryView = [self createToolBar];
         #endif
         self.inputTextView.font = [[self class] inputFont];
         self.inputTextView.backgroundColor = FLEXColor.secondaryGroupedBackgroundColor;
@@ -39,9 +40,6 @@
         self.inputTextView.autocapitalizationType = UITextAutocapitalizationTypeNone;
         self.inputTextView.autocorrectionType = UITextAutocorrectionTypeNo;
         self.inputTextView.delegate = self;
-        #if !TARGET_OS_TV
-        self.inputTextView.inputAccessoryView = [self createToolBar];
-        #endif
         if (@available(iOS 11, *)) {
             [self.inputTextView.layer setValue:@YES forKey:@"continuousCorners"];
         } else {

+ 1 - 1
Classes/Editing/FLEXFieldEditorViewController.m

@@ -92,7 +92,7 @@
     // Don't show a "set" button for switches; we mutate when the switch is flipped
     if ([inputView isKindOfClass:[FLEXArgumentInputSwitchView class]]) {
         self.actionButton.enabled = NO;
-#if !TARGET_OS_TV
+        #if !TARGET_OS_TV
         self.actionButton.title = @"Flip the switch to call the setter";
         // Put getter button before setter button
         self.toolbarItems = @[

+ 10 - 13
Classes/ExplorerInterface/FLEXExplorerViewController.m

@@ -65,16 +65,16 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 /// A colored transparent overlay to indicate that the view is selected.
 @property (nonatomic) UIView *selectedViewOverlay;
 
-#if !TARGET_OS_TV
-/// Used to actuate changes in view selection on iOS 10+
-@property (nonatomic, readonly) UISelectionFeedbackGenerator *selectionFBG API_AVAILABLE(ios(10.0));
-#endif
 /// self.view.window as a \c FLEXWindow
 @property (nonatomic, readonly) FLEXWindow *window;
 
 /// All views that we're KVOing. Used to help us clean up properly.
 @property (nonatomic) NSMutableSet<UIView *> *observedViews;
+
 #if !TARGET_OS_TV
+/// Used to actuate changes in view selection on iOS 10+
+@property (nonatomic, readonly) UISelectionFeedbackGenerator *selectionFBG API_AVAILABLE(ios(10.0));
+
 /// Used to preserve the target app's UIMenuController items.
 @property (nonatomic) NSArray<UIMenuItem *> *appMenuItems;
 #endif
@@ -107,7 +107,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
         return;
     }
     CGPoint point = [self.view convertPoint:cursorView.frame.origin toView:nil];
-    NSLog(@"[FLEXInjected] clicked point: %@", NSStringFromCGPoint(point));
+    FXLog(@"clicked point: %@", NSStringFromCGPoint(point));
     if (self.currentMode == FLEXExplorerModeSelect){
         [self updateOutlineViewsForSelectionPoint:point];
     }
@@ -219,8 +219,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     if (@available(iOS 10.0, *)) {
         _selectionFBG = [UISelectionFeedbackGenerator new];
     }
-#endif
-#if TARGET_OS_TV
+#else
     cursorView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];
     cursorView.center = CGPointMake(CGRectGetMidX([UIScreen mainScreen].bounds), CGRectGetMidY([UIScreen mainScreen].bounds));
     cursorView.image = [FLEXResources cursorImage];
@@ -244,7 +243,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 - (void)doubleTap:(UITapGestureRecognizer *)gesture {
     if (gesture.state == UIGestureRecognizerStateEnded) {
         if (self.currentMode == FLEXExplorerModeSelect || self.currentMode == FLEXExplorerModeMove){
-            NSLog(@"[FLEXInjected] doubleTap: toggle views tool!");
+            FXLog(@"doubleTap: toggle views tool!");
             [self showTVOSOptionsAlert];
             
         }
@@ -254,7 +253,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 
 - (void)showObjectControllerForSelectedView {
     FLEXObjectExplorerViewController *viewExplorer = [FLEXObjectExplorerFactory explorerViewControllerForObject:self.selectedView];
-    NSLog(@"[FLEXInjected] showObjectControllerForSelectedView: %@", viewExplorer);
+    FXLog(@"showObjectControllerForSelectedView: %@", viewExplorer);
     if (!viewExplorer) return;
     if ([self presentedViewController]){
         FLEXHierarchyViewController *vc = (FLEXHierarchyViewController*)[self presentedViewController];
@@ -1101,13 +1100,11 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     UIMenuController.sharedMenuController.menuItems = self.appMenuItems;
     [UIMenuController.sharedMenuController update];
     self.appMenuItems = nil;
-    #endif
     // Restore the status bar window's normal window level.
     // We want it above FLEX while a modal is presented for
     // scroll to top, but below FLEX otherwise for exploration.
-#if !TARGET_OS_TV
     [self statusWindow].windowLevel = UIWindowLevelStatusBar;
-#endif
+    #endif
     
     [self updateButtonStates];
     
@@ -1175,7 +1172,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 - (void)toggleViewsToolWithCompletion:(void(^)(void))completion {
     [self toggleToolWithViewControllerProvider:^UINavigationController *{
         if (self.selectedView) {
-            NSLog(@"[FLEXInjected] we have a selected view still: %@", self.selectedView);
+            FXLog(@"we have a selected view still: %@", self.selectedView);
             return [FLEXHierarchyViewController
                 delegate:self
                 viewsAtTap:self.viewsAtTapPoint

+ 1 - 1
Classes/Manager/FLEXManager.m

@@ -58,7 +58,7 @@
 }
 
 - (void)tripleTap:(UITapGestureRecognizer *)tapRecognizer {
-    NSLog(@"[FLEXInjected] triple tap!");
+    FXLog(@"triple tap!");
     [self showExplorer];
 }
 

+ 0 - 62
Classes/ObjectExplorers/FLEXObjectExplorerViewController.m

@@ -136,7 +136,6 @@
     }
 #if TARGET_OS_TV
     [self addlongPressGestureRecognizer];
-    //[self addSwipeGestureRecognizers];
 #endif
 }
 
@@ -147,67 +146,6 @@
     
 }
 
-- (void)swipedLeft {
-    NSLog(@"[FLEXInjected] swipedLeft!");
-    //go to previous carousel item if possible
-    NSInteger currentIndex = self.carousel.selectedIndex;
-    if (currentIndex == 0) return;
-    if (self.selectedScope > 0) {
-        self.selectedScope -= 1;
-    }
-    NSInteger newIndex = currentIndex - 1;
-    [self.carousel setSelectedIndex:newIndex];
-}
-
-- (void)swipedRight {
-    NSLog(@"[FLEXInjected] swipedRight!");
-    //go to next carousel item if possible
-       NSInteger currentIndex = self.carousel.selectedIndex;
-       NSInteger newIndex = currentIndex + 1;
-    if (newIndex <= self.carousel.items.count - 1){
-        if (self.selectedScope != self.explorer.classHierarchy.count - 1) {
-            self.selectedScope += 1;
-        }
-        NSLog(@"[FLEXInjected] count: %lu new index: %lu", self.carousel.items.count, currentIndex);
-       [self.carousel setSelectedIndex:newIndex];
-        }
-}
-
-- (void)swipeGestureRecognized:(UISwipeGestureRecognizer *)gestureRecognizer{
-    NSLog(@"[FLEXInjected] gesture recognized: %lu", gestureRecognizer.direction);
-    switch (gestureRecognizer.direction) {
-        case UISwipeGestureRecognizerDirectionLeft:
-            
-            [self swipedLeft];
-            break;
-            
-        case UISwipeGestureRecognizerDirectionRight:
-            
-            [self swipedRight];
-            break;
-                    
-        default:
-            break;
-    }
-    
-}
-
-- (void)addSwipeGestureRecognizers {
-    if (_addedSwipeGestures == YES) return;
-    UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGestureRecognized:)];
-    swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
-    [self.view addGestureRecognizer:swipeLeft];
-    self.view.userInteractionEnabled = YES;
-    swipeLeft.delegate = self;
-    
-    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGestureRecognized:)];
-    swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
-    [self.view addGestureRecognizer:swipeRight];
-    self.view.userInteractionEnabled = YES;
-    swipeRight.delegate = self;
-    _addedSwipeGestures = YES;
-}
-
 - (void)longPress:(UILongPressGestureRecognizer*)gesture {
     if ( gesture.state == UIGestureRecognizerStateEnded) {
         NSLog(@"do something different for long press!");

+ 0 - 3
Classes/Utility/FLEXUtility.m

@@ -175,9 +175,6 @@ BOOL FLEXConstructorsShouldRun() {
 }
 
 + (UIColor *)hierarchyIndentPatternColor {
-//#if TARGET_OS_TV
-  //  return [UIColor colorWithPatternImage:FLEXResources.hierarchyIndentPattern];
-//#endif
     static UIColor *patternColor = nil;
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{