2019-12-19 17:32:49 +00:00
|
|
|
/*
|
2023-04-06 09:44:16 +00:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2019-12-19 17:32:49 +00:00
|
|
|
*
|
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-09-07 22:37:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
|
|
@UIApplicationMain
|
|
|
|
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
|
|
|
|
2023-07-20 05:08:21 +00:00
|
|
|
var isLaunched = false
|
2016-09-07 22:37:59 +00:00
|
|
|
var window: UIWindow?
|
|
|
|
|
|
2017-05-16 14:30:08 +00:00
|
|
|
func application(_ application: UIApplication,
|
2019-12-19 05:50:02 +00:00
|
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
2023-07-20 05:08:21 +00:00
|
|
|
|
|
|
|
|
let demosViewController = DemosViewController()
|
|
|
|
|
let splitViewController = UISplitViewController()
|
|
|
|
|
splitViewController.delegate = self
|
|
|
|
|
splitViewController.viewControllers = [UINavigationController(rootViewController: demosViewController)]
|
|
|
|
|
splitViewController.preferredDisplayMode = .oneBesideSecondary
|
|
|
|
|
|
2016-09-07 22:37:59 +00:00
|
|
|
window = UIWindow(frame: UIScreen.main.bounds)
|
2023-07-20 05:08:21 +00:00
|
|
|
window?.rootViewController = splitViewController
|
2016-09-07 22:37:59 +00:00
|
|
|
window?.makeKeyAndVisible()
|
2020-10-03 08:37:52 +00:00
|
|
|
UICollectionView.appearance().backgroundColor = UIColor.background
|
2023-07-20 05:08:21 +00:00
|
|
|
|
2016-09-07 22:37:59 +00:00
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-20 05:08:21 +00:00
|
|
|
|
|
|
|
|
extension AppDelegate: UISplitViewControllerDelegate {
|
|
|
|
|
func splitViewController(_ splitViewController: UISplitViewController,
|
|
|
|
|
collapseSecondary secondaryViewController: UIViewController,
|
|
|
|
|
onto primaryViewController: UIViewController) -> Bool {
|
|
|
|
|
// We set up 2 view controllers on launch to enable the split view controller when launching on iPad.
|
|
|
|
|
// However, for iPhone, discard the second view controller so the Demos view controller is visible at launch.
|
|
|
|
|
if !isLaunched {
|
|
|
|
|
isLaunched = true
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|