Ver código fonte

Allow exploring objects from window/scene screen

Tanner Bennett 6 anos atrás
pai
commit
3e6d18dd8c

+ 2 - 1
Classes/Core/Controllers/FLEXNavigationController.m

@@ -66,7 +66,8 @@
 }
 }
 
 
 - (void)dismissAnimated {
 - (void)dismissAnimated {
-    // TODO tabs not closed on swipe down gesture
+    // Tabs are only closed if the done button is pressed; this
+    // allows you to leave a tab open by dragging down to dismiss
     [FLEXTabList.sharedList closeTab:self];
     [FLEXTabList.sharedList closeTab:self];
     [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
     [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
 }
 }

+ 3 - 2
Classes/ExplorerInterface/FLEXExplorerViewController.m

@@ -524,6 +524,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     // Back up the UIMenuController items since dismissViewController: will attempt to replace them
     // Back up the UIMenuController items since dismissViewController: will attempt to replace them
     self.appMenuItems = UIMenuController.sharedMenuController.menuItems;
     self.appMenuItems = UIMenuController.sharedMenuController.menuItems;
     
     
+    // Don't use FLEXNavigationController because the tab viewer itself is not a tab
     [super presentViewController:[[UINavigationController alloc]
     [super presentViewController:[[UINavigationController alloc]
         initWithRootViewController:[FLEXTabsViewController new]
         initWithRootViewController:[FLEXTabsViewController new]
     ] animated:YES completion:nil];
     ] animated:YES completion:nil];
@@ -533,8 +534,8 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     // Back up the UIMenuController items since dismissViewController: will attempt to replace them
     // Back up the UIMenuController items since dismissViewController: will attempt to replace them
     self.appMenuItems = UIMenuController.sharedMenuController.menuItems;
     self.appMenuItems = UIMenuController.sharedMenuController.menuItems;
     
     
-    [super presentViewController:[[UINavigationController alloc]
-        initWithRootViewController:[FLEXWindowManagerController new]
+    [super presentViewController:[FLEXNavigationController
+        withRootViewController:[FLEXWindowManagerController new]
     ] animated:YES completion:nil];
     ] animated:YES completion:nil];
 }
 }
 
 

+ 18 - 19
Classes/ExplorerInterface/FLEXWindowManagerController.m

@@ -9,6 +9,7 @@
 #import "FLEXWindowManagerController.h"
 #import "FLEXWindowManagerController.h"
 #import "FLEXManager+Private.h"
 #import "FLEXManager+Private.h"
 #import "FLEXUtility.h"
 #import "FLEXUtility.h"
+#import "FLEXObjectExplorerFactory.h"
 
 
 @interface FLEXWindowManagerController ()
 @interface FLEXWindowManagerController ()
 @property (nonatomic) UIWindow *keyWindow;
 @property (nonatomic) UIWindow *keyWindow;
@@ -17,6 +18,7 @@
 @property (nonatomic, copy) NSArray<NSString *> *windowSubtitles;
 @property (nonatomic, copy) NSArray<NSString *> *windowSubtitles;
 @property (nonatomic, copy) NSArray<UIScene *> *scenes API_AVAILABLE(ios(13));
 @property (nonatomic, copy) NSArray<UIScene *> *scenes API_AVAILABLE(ios(13));
 @property (nonatomic, copy) NSArray<NSString *> *sceneSubtitles;
 @property (nonatomic, copy) NSArray<NSString *> *sceneSubtitles;
+@property (nonatomic, copy) NSArray<NSArray *> *sections;
 @end
 @end
 
 
 @implementation FLEXWindowManagerController
 @implementation FLEXWindowManagerController
@@ -49,17 +51,22 @@
 - (void)reloadData {
 - (void)reloadData {
     self.keyWindow = UIApplication.sharedApplication.keyWindow;
     self.keyWindow = UIApplication.sharedApplication.keyWindow;
     self.windows = UIApplication.sharedApplication.windows;
     self.windows = UIApplication.sharedApplication.windows;
+    self.keyWindowSubtitle = self.windowSubtitles[[self.windows indexOfObject:self.keyWindow]];
     self.windowSubtitles = [self.windows flex_mapped:^id(UIWindow *window, NSUInteger idx) {
     self.windowSubtitles = [self.windows flex_mapped:^id(UIWindow *window, NSUInteger idx) {
         return [NSString stringWithFormat:@"Level: %@ — Root: %@",
         return [NSString stringWithFormat:@"Level: %@ — Root: %@",
             @(window.windowLevel), window.rootViewController
             @(window.windowLevel), window.rootViewController
         ];
         ];
     }];
     }];
-    self.keyWindowSubtitle = self.windowSubtitles[[self.windows indexOfObject:self.keyWindow]];
+    
     if (@available(iOS 13, *)) {
     if (@available(iOS 13, *)) {
         self.scenes = UIApplication.sharedApplication.connectedScenes.allObjects;
         self.scenes = UIApplication.sharedApplication.connectedScenes.allObjects;
         self.sceneSubtitles = [self.scenes flex_mapped:^id(UIScene *scene, NSUInteger idx) {
         self.sceneSubtitles = [self.scenes flex_mapped:^id(UIScene *scene, NSUInteger idx) {
             return [self sceneDescription:scene];
             return [self sceneDescription:scene];
         }];
         }];
+        
+        self.sections = @[@[self.keyWindow], self.windows, self.scenes];
+    } else {
+        self.sections = @[@[self.keyWindow], self.windows];
     }
     }
 }
 }
 
 
@@ -137,27 +144,11 @@
 #pragma mark - Table View Data Source
 #pragma mark - Table View Data Source
 
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-    if (@available(iOS 13, *)) {
-        return 3;
-    }
-    
-    return 2;
+    return self.sections.count;
 }
 }
 
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    switch (section) {
-        case 0:
-            return 1;
-        case 1:
-            return self.windows.count;
-        case 2:
-            if (@available(iOS 13, *)) {
-                return self.scenes.count;
-            }
-    }
-    
-    @throw NSInternalInconsistencyException;
-    return 0;
+    return self.sections[section].count;
 }
 }
 
 
 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
@@ -193,6 +184,8 @@
             }
             }
     }
     }
     
     
+    cell.accessoryType = UITableViewCellAccessoryDetailButton;
+    cell.textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
     cell.textLabel.text = window.description;
     cell.textLabel.text = window.description;
     cell.detailTextLabel.text = [NSString
     cell.detailTextLabel.text = [NSString
         stringWithFormat:@"Level: %@ — Root: %@", @(window.windowLevel), window.rootViewController
         stringWithFormat:@"Level: %@ — Root: %@", @(window.windowLevel), window.rootViewController
@@ -300,4 +293,10 @@
     } showFrom:self];
     } showFrom:self];
 }
 }
 
 
+- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)ip {
+    [self.navigationController pushViewController:
+        [FLEXObjectExplorerFactory explorerViewControllerForObject:self.sections[ip.section][ip.row]]
+    animated:YES];
+}
+
 @end
 @end