hidden sidebar no longer does anything, don't revert this because it's the only thing we can currently use that works on iPhone, iPad and iPod. breaks Apple TV but that doesn't matter atm
64 lines
2.3 KiB
Objective-C
64 lines
2.3 KiB
Objective-C
#import "LauncherSplitViewController.h"
|
|
#import "LauncherMenuViewController.h"
|
|
#import "LauncherNavigationController.h"
|
|
#import "LauncherPreferences.h"
|
|
#import "utils.h"
|
|
|
|
extern NSMutableDictionary *prefDict;
|
|
|
|
@interface LauncherSplitViewController ()<UISplitViewControllerDelegate>{
|
|
}
|
|
@end
|
|
|
|
@implementation LauncherSplitViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
UIApplication.sharedApplication.idleTimerDisabled = YES;
|
|
setViewBackgroundColor(self.view);
|
|
setDefaultValueForPref(prefDict, @"control_safe_area", NSStringFromCGRect(getDefaultSafeArea()));
|
|
|
|
self.delegate = self;
|
|
|
|
LauncherMenuViewController *masterVc = [[LauncherMenuViewController alloc] init];
|
|
LauncherNavigationController *detailVc = [[LauncherNavigationController alloc] init];
|
|
detailVc.toolbarHidden = NO;
|
|
|
|
self.viewControllers = @[[[UINavigationController alloc] initWithRootViewController:masterVc], detailVc];
|
|
[self changeDisplayModeForSize:self.view.frame.size];
|
|
}
|
|
|
|
- (void)splitViewController:(UISplitViewController *)svc willChangeToDisplayMode:(UISplitViewControllerDisplayMode)displayMode {
|
|
if (self.preferredDisplayMode != displayMode && self.displayMode != UISplitViewControllerDisplayModeSecondaryOnly) {
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
self.preferredDisplayMode = UISplitViewControllerDisplayModeSecondaryOnly;
|
|
});
|
|
}
|
|
}
|
|
|
|
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
|
{
|
|
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
|
[self changeDisplayModeForSize:size];
|
|
}
|
|
|
|
- (void)changeDisplayModeForSize:(CGSize)size {
|
|
BOOL isPortrait = size.height > size.width;
|
|
if (self.preferredDisplayMode == 0 || self.displayMode != UISplitViewControllerDisplayModeSecondaryOnly) {
|
|
//if([getPreference(@"hidden_sidebar") boolValue] == NO) {
|
|
self.preferredDisplayMode = UISplitViewControllerDisplayModeOneOverSecondary;
|
|
/*} else {
|
|
self.preferredDisplayMode = UISplitViewControllerDisplayModeSecondaryOnly;
|
|
}*/
|
|
}
|
|
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
|
self.preferredSplitBehavior = UISplitViewControllerSplitBehaviorOverlay;
|
|
}
|
|
}
|
|
|
|
- (void)dismissViewController {
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
}
|
|
|
|
@end
|