Path: blob/main/Natives/LauncherSplitViewController.m
589 views
#import "LauncherSplitViewController.h"1#import "LauncherMenuViewController.h"2#import "LauncherNewsViewController.h"3#import "LauncherNavigationController.h"4#import "LauncherPreferences.h"5#import "utils.h"67extern NSMutableDictionary *prefDict;89@interface LauncherSplitViewController ()<UISplitViewControllerDelegate>{10}11@end1213@implementation LauncherSplitViewController1415- (void)viewDidLoad {16[super viewDidLoad];17self.view.backgroundColor = UIColor.systemBackgroundColor;18if ([getPrefObject(@"control.control_safe_area") length] == 0) {19setPrefObject(@"control.control_safe_area", NSStringFromUIEdgeInsets(getDefaultSafeArea()));20}2122self.delegate = self;2324UINavigationController *masterVc = [[UINavigationController alloc] initWithRootViewController:[[LauncherMenuViewController alloc] init]];25LauncherNavigationController *detailVc = [[LauncherNavigationController alloc] initWithRootViewController:[[LauncherNewsViewController alloc] init]];26detailVc.toolbarHidden = NO;2728self.viewControllers = @[masterVc, detailVc];29[self changeDisplayModeForSize:self.view.frame.size];3031self.maximumPrimaryColumnWidth = self.view.bounds.size.width * 0.95;32}3334- (void)splitViewController:(UISplitViewController *)svc willChangeToDisplayMode:(UISplitViewControllerDisplayMode)displayMode {35if (self.preferredDisplayMode != displayMode && self.displayMode != UISplitViewControllerDisplayModeSecondaryOnly) {36dispatch_async(dispatch_get_main_queue(), ^{37self.preferredDisplayMode = UISplitViewControllerDisplayModeSecondaryOnly;38});39}40}4142- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator43{44[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];45[self changeDisplayModeForSize:size];46}4748- (void)changeDisplayModeForSize:(CGSize)size {49BOOL isPortrait = size.height > size.width;50if (self.preferredDisplayMode == 0 || self.displayMode != UISplitViewControllerDisplayModeSecondaryOnly) {51if(!getPrefBool(@"general.hidden_sidebar")) {52self.preferredDisplayMode = isPortrait ?53UISplitViewControllerDisplayModeOneOverSecondary :54UISplitViewControllerDisplayModeOneBesideSecondary;55} else {56self.preferredDisplayMode = UISplitViewControllerDisplayModeSecondaryOnly;57}58}59self.preferredSplitBehavior = isPortrait ?60UISplitViewControllerSplitBehaviorOverlay :61UISplitViewControllerSplitBehaviorTile;62}6364- (void)dismissViewController {65[self dismissViewControllerAnimated:YES completion:nil];66}6768@end697071