diff --git a/iOS/FolderTemplate@2x.png b/iOS/FolderTemplate@2x.png new file mode 100644 index 0000000..b868fcb Binary files /dev/null and b/iOS/FolderTemplate@2x.png differ diff --git a/iOS/FolderTemplate@3x.png b/iOS/FolderTemplate@3x.png new file mode 100644 index 0000000..c24e7f6 Binary files /dev/null and b/iOS/FolderTemplate@3x.png differ diff --git a/iOS/GBHubViewController.m b/iOS/GBHubViewController.m index 7cabe24..25f8e69 100644 --- a/iOS/GBHubViewController.m +++ b/iOS/GBHubViewController.m @@ -14,6 +14,7 @@ NSArray *_results; NSString *_resultsTitle; bool _showingAllGames; + bool _appear; } - (instancetype)init @@ -25,10 +26,18 @@ object:nil]; _imageCache = [NSMutableDictionary dictionary]; self.tableView.rowHeight = UITableViewAutomaticDimension; - [GBHub.sharedHub refresh]; return self; } +- (void)viewDidAppear:(BOOL)animated +{ + if (!_appear) { + _appear = true; + [GBHub.sharedHub refresh]; + } + [super viewDidAppear:animated]; +} + - (void)viewDidLoad { [super viewDidLoad]; diff --git a/iOS/GBLibraryViewController.h b/iOS/GBLibraryViewController.h new file mode 100644 index 0000000..c2e85e7 --- /dev/null +++ b/iOS/GBLibraryViewController.h @@ -0,0 +1,6 @@ +#import + +@interface GBLibraryViewController : UITabBarController + +@end + diff --git a/iOS/GBLibraryViewController.m b/iOS/GBLibraryViewController.m new file mode 100644 index 0000000..988a4fe --- /dev/null +++ b/iOS/GBLibraryViewController.m @@ -0,0 +1,53 @@ +#import "GBLibraryViewController.h" +#import "GBLoadROMTableViewController.h" +#import "GBHubViewController.h" +#import "GBViewController.h" + +@implementation GBLibraryViewController + ++ (UIViewController *)wrapViewController:(UIViewController *)controller +{ + UINavigationController *ret = [[UINavigationController alloc] initWithRootViewController:controller]; + UIBarButtonItem *close = [[UIBarButtonItem alloc] initWithTitle:@"Close" + style:UIBarButtonItemStylePlain + target:[UIApplication sharedApplication].delegate + action:@selector(dismissViewController)]; + [ret.visibleViewController.navigationItem setLeftBarButtonItem:close]; + return ret; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + self.viewControllers = @[ + [self.class wrapViewController:[[GBLoadROMTableViewController alloc] init]], + [self.class wrapViewController:[[GBHubViewController alloc] init]], + ]; + if (@available(iOS 13.0, *)) { + UIEdgeInsets insets = [UIApplication sharedApplication].keyWindow.safeAreaInsets; + bool hasHomeButton = insets.bottom == 0; + bool isPad = [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad; + NSString *symbol = isPad? @"ipad" : @"iphone"; + if (hasHomeButton) { + symbol = [symbol stringByAppendingString:@".homebutton"]; + } + else if (!isPad) { + if (@available(iOS 16.1, *)) { + if (MAX(insets.left, MAX(insets.right, MAX(insets.top, insets.bottom))) > 51) { + symbol = @"iphone.gen3"; + } + else { + symbol = @"iphone.gen2"; + } + } + } + self.viewControllers[0].tabBarItem.image = [UIImage systemImageNamed:symbol] ?: [UIImage systemImageNamed:@"folder.fill"]; + self.viewControllers[1].tabBarItem.image = [UIImage systemImageNamed:@"globe"]; + } + else { + self.viewControllers[0].tabBarItem.image = [UIImage imageNamed:@"FolderTemplate"]; + self.viewControllers[1].tabBarItem.image = [UIImage imageNamed:@"GlobeTemplate"]; + } +} + +@end diff --git a/iOS/GBLoadROMTableViewController.m b/iOS/GBLoadROMTableViewController.m index b6d074e..126985f 100644 --- a/iOS/GBLoadROMTableViewController.m +++ b/iOS/GBLoadROMTableViewController.m @@ -1,7 +1,6 @@ #import "GBLoadROMTableViewController.h" #import "GBROMManager.h" #import "GBViewController.h" -#import "GBHubViewController.h" #import #import @@ -33,7 +32,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if (section == 1) return 3; + if (section == 1) return 2; return [GBROMManager sharedManager].allROMs.count; } @@ -43,8 +42,7 @@ UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; switch (indexPath.item) { case 0: cell.textLabel.text = @"Import ROM files"; break; - case 1: cell.textLabel.text = @"Browse Homebrew Hub"; break; - case 2: cell.textLabel.text = @"Show Library in Files"; break; + case 1: cell.textLabel.text = @"Show Library in Files"; break; } return cell; } @@ -81,7 +79,7 @@ - (NSString *)title { - return @"ROM Library"; + return @"Local Library"; } - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section @@ -143,11 +141,6 @@ return; } case 1: { - [self.navigationController pushViewController:[[GBHubViewController alloc] init] - animated:true]; - return; - } - case 2: { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"shareddocuments://%@", NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true).firstObject]] options:nil completionHandler:nil]; diff --git a/iOS/GBMenuViewController.m b/iOS/GBMenuViewController.m index 5ab2099..55219db 100644 --- a/iOS/GBMenuViewController.m +++ b/iOS/GBMenuViewController.m @@ -61,7 +61,7 @@ static NSString *const tips[] = { {@"Connect", @"LinkCableTemplate", SelectorString(openConnectMenu), true}, {@"Model", @"ModelTemplate", SelectorString(changeModel)}, {@"States", @"square.stack", SelectorString(openStates), true}, - {@"Cheats", @"CheatsTemplate", SelectorString(openCheats), true}, // TODO + {@"Cheats", @"CheatsTemplate", SelectorString(openCheats), true}, {@"Settings", @"gear", SelectorString(openSettings)}, {@"About", @"info.circle", SelectorString(showAbout)}, }; diff --git a/iOS/GBViewController.h b/iOS/GBViewController.h index 487bab4..caef898 100644 --- a/iOS/GBViewController.h +++ b/iOS/GBViewController.h @@ -28,5 +28,6 @@ typedef enum { - (void)saveStateToFile:(NSString *)file; - (bool)loadStateFromFile:(NSString *)file; - (bool)handleOpenURLs:(NSArray *)urls openInPlace:(bool)inPlace; +- (void)dismissViewController; @property (nonatomic) GBRunMode runMode; @end diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m index 66a7045..4708e7a 100644 --- a/iOS/GBViewController.m +++ b/iOS/GBViewController.m @@ -4,7 +4,7 @@ #import "GBViewMetal.h" #import "GBAudioClient.h" #import "GBROMManager.h" -#import "GBLoadROMTableViewController.h" +#import "GBLibraryViewController.h" #import "GBBackgroundView.h" #import "GBHapticManager.h" #import "GBMenuViewController.h" @@ -723,13 +723,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) - (void)openLibrary { - UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:[[GBLoadROMTableViewController alloc] init]]; - UIBarButtonItem *close = [[UIBarButtonItem alloc] initWithTitle:@"Close" - style:UIBarButtonItemStylePlain - target:self - action:@selector(dismissViewController)]; - [controller.visibleViewController.navigationItem setLeftBarButtonItem:close]; - [self presentViewController:controller + [self presentViewController:[[GBLibraryViewController alloc] init] animated:true completion:nil]; } diff --git a/iOS/GlobeTemplate@2x.png b/iOS/GlobeTemplate@2x.png new file mode 100644 index 0000000..e6a8302 Binary files /dev/null and b/iOS/GlobeTemplate@2x.png differ diff --git a/iOS/GlobeTemplate@3x.png b/iOS/GlobeTemplate@3x.png new file mode 100644 index 0000000..e82e9de Binary files /dev/null and b/iOS/GlobeTemplate@3x.png differ