IGListKit/Examples/Examples-iOS/IGListKitExamples/AppDelegate.swift
Adam Cmiel 86dcc6efe5 enable upcoming feature DeprecateApplicationMain
Summary:
Context: https://fb.workplace.com/groups/pikacompilertalk/permalink/1922686104918501/

SE: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md

This one is pretty straightforward. Let's make Swift 5 act like Swift 6

Reviewed By: ebgraham

Differential Revision: D66391294

fbshipit-source-id: c8aaf9f9904c29ab9955c34f564df9b150d81129
2024-12-05 19:43:28 -08:00

46 lines
1.7 KiB
Swift

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var isLaunched = false
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let demosViewController = DemosViewController()
let splitViewController = UISplitViewController()
splitViewController.delegate = self
splitViewController.viewControllers = [UINavigationController(rootViewController: demosViewController)]
splitViewController.preferredDisplayMode = .oneBesideSecondary
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = splitViewController
window?.makeKeyAndVisible()
UICollectionView.appearance().backgroundColor = UIColor.background
return true
}
}
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
}
}