Просмотр исходного кода

Add a clear global entries method for FLEXManager

matrush лет назад: 5
Родитель
Сommit
9412f6eccf
2 измененных файлов с 23 добавлено и 15 удалено
  1. 3 0
      Classes/Manager/FLEXManager+Extensibility.h
  2. 20 15
      Classes/Manager/FLEXManager+Extensibility.m

+ 3 - 0
Classes/Manager/FLEXManager+Extensibility.h

@@ -38,6 +38,9 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)registerGlobalEntryWithName:(NSString *)entryName
 - (void)registerGlobalEntryWithName:(NSString *)entryName
           viewControllerFutureBlock:(UIViewController * (^)(void))viewControllerFutureBlock;
           viewControllerFutureBlock:(UIViewController * (^)(void))viewControllerFutureBlock;
 
 
+/// Removes all registered global entries.
+- (void)clearGlobalEntries;
+
 #pragma mark - Simulator Shortcuts
 #pragma mark - Simulator Shortcuts
 
 
 /// Simulator keyboard shortcuts are enabled by default.
 /// Simulator keyboard shortcuts are enabled by default.

+ 20 - 15
Classes/Manager/FLEXManager+Extensibility.m

@@ -58,6 +58,11 @@
     [self.userGlobalEntries addObject:entry];
     [self.userGlobalEntries addObject:entry];
 }
 }
 
 
+- (void)clearGlobalEntries
+{
+  [self.userGlobalEntries removeAllObjects];
+}
+
 
 
 #pragma mark - Simulator Shortcuts
 #pragma mark - Simulator Shortcuts
 
 
@@ -95,60 +100,60 @@
     [self registerDefaultSimulatorShortcutWithKey:@"f" modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"f" modifiers:0 action:^{
         [self toggleExplorer];
         [self toggleExplorer];
     } description:@"Toggle FLEX toolbar"];
     } description:@"Toggle FLEX toolbar"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:@"g" modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"g" modifiers:0 action:^{
         [self showExplorerIfNeeded];
         [self showExplorerIfNeeded];
         [self.explorerViewController toggleMenuTool];
         [self.explorerViewController toggleMenuTool];
     } description:@"Toggle FLEX globals menu"];
     } description:@"Toggle FLEX globals menu"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:@"v" modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"v" modifiers:0 action:^{
         [self showExplorerIfNeeded];
         [self showExplorerIfNeeded];
         [self.explorerViewController toggleViewsTool];
         [self.explorerViewController toggleViewsTool];
     } description:@"Toggle view hierarchy menu"];
     } description:@"Toggle view hierarchy menu"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:@"s" modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"s" modifiers:0 action:^{
         [self showExplorerIfNeeded];
         [self showExplorerIfNeeded];
         [self.explorerViewController toggleSelectTool];
         [self.explorerViewController toggleSelectTool];
     } description:@"Toggle select tool"];
     } description:@"Toggle select tool"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:@"m" modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"m" modifiers:0 action:^{
         [self showExplorerIfNeeded];
         [self showExplorerIfNeeded];
         [self.explorerViewController toggleMoveTool];
         [self.explorerViewController toggleMoveTool];
     } description:@"Toggle move tool"];
     } description:@"Toggle move tool"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:@"n" modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"n" modifiers:0 action:^{
         [self toggleTopViewControllerOfClass:[FLEXNetworkMITMViewController class]];
         [self toggleTopViewControllerOfClass:[FLEXNetworkMITMViewController class]];
     } description:@"Toggle network history view"];
     } description:@"Toggle network history view"];
-    
+
     // 't' is for testing: quickly present an object explorer for debugging
     // 't' is for testing: quickly present an object explorer for debugging
     [self registerDefaultSimulatorShortcutWithKey:@"t" modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"t" modifiers:0 action:^{
         [self showExplorerIfNeeded];
         [self showExplorerIfNeeded];
-        
+
         [self.explorerViewController toggleToolWithViewControllerProvider:^UINavigationController *{
         [self.explorerViewController toggleToolWithViewControllerProvider:^UINavigationController *{
             return [FLEXNavigationController withRootViewController:[FLEXObjectExplorerFactory
             return [FLEXNavigationController withRootViewController:[FLEXObjectExplorerFactory
                 explorerViewControllerForObject:NSBundle.mainBundle
                 explorerViewControllerForObject:NSBundle.mainBundle
             ]];
             ]];
         } completion:nil];
         } completion:nil];
     } description:@"Present an object explorer for debugging"];
     } description:@"Present an object explorer for debugging"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputDownArrow modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputDownArrow modifiers:0 action:^{
         if (self.isHidden || ![self.explorerViewController handleDownArrowKeyPressed]) {
         if (self.isHidden || ![self.explorerViewController handleDownArrowKeyPressed]) {
             [self tryScrollDown];
             [self tryScrollDown];
         }
         }
     } description:@"Cycle view selection\n\t\tMove view down\n\t\tScroll down"];
     } description:@"Cycle view selection\n\t\tMove view down\n\t\tScroll down"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputUpArrow modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputUpArrow modifiers:0 action:^{
         if (self.isHidden || ![self.explorerViewController handleUpArrowKeyPressed]) {
         if (self.isHidden || ![self.explorerViewController handleUpArrowKeyPressed]) {
             [self tryScrollUp];
             [self tryScrollUp];
         }
         }
     } description:@"Cycle view selection\n\t\tMove view up\n\t\tScroll up"];
     } description:@"Cycle view selection\n\t\tMove view up\n\t\tScroll up"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputRightArrow modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputRightArrow modifiers:0 action:^{
         if (!self.isHidden) {
         if (!self.isHidden) {
             [self.explorerViewController handleRightArrowKeyPressed];
             [self.explorerViewController handleRightArrowKeyPressed];
         }
         }
     } description:@"Move selected view right"];
     } description:@"Move selected view right"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputLeftArrow modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputLeftArrow modifiers:0 action:^{
         if (self.isHidden) {
         if (self.isHidden) {
             [self tryGoBack];
             [self tryGoBack];
@@ -156,15 +161,15 @@
             [self.explorerViewController handleLeftArrowKeyPressed];
             [self.explorerViewController handleLeftArrowKeyPressed];
         }
         }
     } description:@"Move selected view left"];
     } description:@"Move selected view left"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:@"?" modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"?" modifiers:0 action:^{
         [self toggleTopViewControllerOfClass:[FLEXKeyboardHelpViewController class]];
         [self toggleTopViewControllerOfClass:[FLEXKeyboardHelpViewController class]];
     } description:@"Toggle (this) help menu"];
     } description:@"Toggle (this) help menu"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputEscape modifiers:0 action:^{
     [self registerDefaultSimulatorShortcutWithKey:UIKeyInputEscape modifiers:0 action:^{
         [[self.topViewController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
         [[self.topViewController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
     } description:@"End editing text\n\t\tDismiss top view controller"];
     } description:@"End editing text\n\t\tDismiss top view controller"];
-    
+
     [self registerDefaultSimulatorShortcutWithKey:@"o" modifiers:UIKeyModifierCommand|UIKeyModifierShift action:^{
     [self registerDefaultSimulatorShortcutWithKey:@"o" modifiers:UIKeyModifierCommand|UIKeyModifierShift action:^{
         [self toggleTopViewControllerOfClass:[FLEXFileBrowserController class]];
         [self toggleTopViewControllerOfClass:[FLEXFileBrowserController class]];
     } description:@"Toggle file browser menu"];
     } description:@"Toggle file browser menu"];
@@ -183,7 +188,7 @@
     if (@available(iOS 11, *)) {
     if (@available(iOS 11, *)) {
         return scrollView.adjustedContentInset;
         return scrollView.adjustedContentInset;
     }
     }
-    
+
     return scrollView.contentInset;
     return scrollView.contentInset;
 }
 }