From 392bc8c0d9b86a07eef73c24b32fb2c88767242e Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 7 Sep 2024 17:39:38 +0300 Subject: [PATCH] Move HomeBrew Hub to a tab bar --- iOS/FolderTemplate@2x.png | Bin 0 -> 224 bytes iOS/FolderTemplate@3x.png | Bin 0 -> 289 bytes iOS/GBHubViewController.m | 11 +++++- iOS/GBLibraryViewController.h | 6 ++++ iOS/GBLibraryViewController.m | 53 +++++++++++++++++++++++++++++ iOS/GBLoadROMTableViewController.m | 13 ++----- iOS/GBMenuViewController.m | 2 +- iOS/GBViewController.h | 1 + iOS/GBViewController.m | 10 ++---- iOS/GlobeTemplate@2x.png | Bin 0 -> 1158 bytes iOS/GlobeTemplate@3x.png | Bin 0 -> 1833 bytes 11 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 iOS/FolderTemplate@2x.png create mode 100644 iOS/FolderTemplate@3x.png create mode 100644 iOS/GBLibraryViewController.h create mode 100644 iOS/GBLibraryViewController.m create mode 100644 iOS/GlobeTemplate@2x.png create mode 100644 iOS/GlobeTemplate@3x.png diff --git a/iOS/FolderTemplate@2x.png b/iOS/FolderTemplate@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b868fcb024dcca24f413192f38ce37944db26aa3 GIT binary patch literal 224 zcmV<603ZK}P)0-=>o?h@y4;r!%dQgWpcK-H%_dfARv<~ z8#x?~k~jtw|1mBa-4?|aS6p$${~GsVwl|Do_-NRR;Rmo>-u@!L((`=oR5T3uud$wi ah6*M>47w1QMDWc30000trRYfjsTZCujv*0;-`+IjI%FVm^kaQj z6^}aW$`_`4`Ymo84c53Zx#M}kRi#I)EYqXBWvpH-Nb+7Rc(1znP`|#S_X3aUtky+u zPCv_;dHGM9aA#lABxI?zQB$V4K3 zGJC!2RN=L#aI$1uW3zA#udSI$9p6qPh8a~Kz6**fIfwlEzu{ck8H4YPtw&Ur#Jep~ eInu)VkZq6G;gcI04&MR#nZeW5&t;ucLK6UN^l~Kt literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..e6a83027120979f14b4d34ab371574327543a176 GIT binary patch literal 1158 zcmV;11bO?3P)c8hxlFv#aZIBIfcWPoNVb2GiiAk2}{Y(S&+^Fe47W@k5ip;~t{D?KnaA7r0! zOqDa4fO{IOR%wHhitV>lgP=VCvA)lU0zFfYJ~cP8dm&G;X9#T zSWDYKQH5fV@xmVo zD=ZX_b6uF45OP--(IdzR;cmhTQ-$mNEeuZxxi7rbBgo6b{e%_DgunDUr=R9|F(A)> zyY9T87ym+z@J?avQzzqZ-6!J(XIN!u5OA zQd=DGt7dKf5yBlUE;{3&Eta|}yx!CGTZ%}G_Muu$z0T<-wW^KITVq@Pk$O`~NBRYs zVuSNiIh3fudW*ens*#2Xp-j0qykoKT8geL6%6S`-C{dc+{h-R}9CEkD3^lzZcQdTX zA$Py1aPVN4*lJ2MUDg$Gs7z=}p@sgzvKwd!S}1a}p%> zzygWAr)P;>XcmmgF$>BP&4MvmvtUWzY>&FE?J+-Ndz>~R3o_hK8QWui*7m6Do9&Tq z)3XLnn002t}1ONa4l1H*(000K?NklG;|sEMZ!b26FvX6BojFH2MCnU^nfw}0lId+z`K?}6B@ z6JuFLK1DpBj7o$`$|#|T0#-4WPSmTlU=n$hAihrtc}${3T?1-F8oMY90Lc23v70m+ z)eWS0rf|(R+)J+LuRAQ#UyHb-zpnDqR{I)Lh_CIhG}RnV5H7Hk!A#%-g0P-M&=N>w z9fI(I2@GZl7cA}WFtzr+S}G^Zj!VfQ6@U&rM-Y~3ttwamOA&rhrooCv~0Xo}CKB5Gnk^z=?c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