mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-06 15:08:50 +00:00
Summary: Adds additional polish and refinement to the initial Demos view controller. * Adds SF Symbols to each section. * Correctly selects and deselects cells when in and out split view mode. * Fixes demo table view cell to adapt to safe area insets correctly. Reviewed By: fabiomassimo Differential Revision: D45686668 fbshipit-source-id: 5e24120a0aab5cb3fb9c33b0b0d7c087a56d6304
46 lines
1.7 KiB
Swift
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
|
|
|
|
@UIApplicationMain
|
|
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
|
|
}
|
|
}
|