mirror of https://github.com/LIJI32/SameBoy.git
Move HomeBrew Hub to a tab bar
This commit is contained in:
parent
8e3d8c4a18
commit
392bc8c0d9
Binary file not shown.
After Width: | Height: | Size: 224 B |
Binary file not shown.
After Width: | Height: | Size: 289 B |
|
@ -14,6 +14,7 @@
|
|||
NSArray<GBHubGame *> *_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];
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GBLibraryViewController : UITabBarController
|
||||
|
||||
@end
|
||||
|
|
@ -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
|
|
@ -1,7 +1,6 @@
|
|||
#import "GBLoadROMTableViewController.h"
|
||||
#import "GBROMManager.h"
|
||||
#import "GBViewController.h"
|
||||
#import "GBHubViewController.h"
|
||||
#import <CoreServices/CoreServices.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
|
@ -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];
|
||||
|
|
|
@ -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)},
|
||||
};
|
||||
|
|
|
@ -28,5 +28,6 @@ typedef enum {
|
|||
- (void)saveStateToFile:(NSString *)file;
|
||||
- (bool)loadStateFromFile:(NSString *)file;
|
||||
- (bool)handleOpenURLs:(NSArray <NSURL *> *)urls openInPlace:(bool)inPlace;
|
||||
- (void)dismissViewController;
|
||||
@property (nonatomic) GBRunMode runMode;
|
||||
@end
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue