Skip to content
Snippets Groups Projects
AppDelegate.swift 1.14 KiB
Newer Older
Bruno Muniz's avatar
Bruno Muniz committed
import UIKit
Bruno Muniz's avatar
Bruno Muniz committed
import Defaults
Ahmed Shehata's avatar
Ahmed Shehata committed
import LaunchFeature
Bruno Muniz's avatar
Bruno Muniz committed
public class AppDelegate: UIResponder, UIApplicationDelegate {
Bruno Muniz's avatar
Bruno Muniz committed
  public var coverView: UIView?
Bruno Muniz's avatar
Bruno Muniz committed
  public var window: UIWindow?

Bruno Muniz's avatar
Bruno Muniz committed
  @KeyObject(.hideAppList, defaultValue: false) var shouldHideAppInAppList

Bruno Muniz's avatar
Bruno Muniz committed
  public func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    let navController = UINavigationController(rootViewController: LaunchController())
    window = UIWindow(frame: UIScreen.main.bounds)
    window?.rootViewController = RootViewController(navController)
    window?.makeKeyAndVisible()
Bruno Muniz's avatar
Bruno Muniz committed
    return true
  }
Bruno Muniz's avatar
Bruno Muniz committed

  public func applicationWillResignActive(_ application: UIApplication) {
    if shouldHideAppInAppList {
      coverView?.removeFromSuperview()
      coverView = UIVisualEffectView(effect: UIBlurEffect(style: .regular))
      coverView?.frame = window?.bounds ?? .zero
      window?.addSubview(coverView!)
    }
  }

  public func applicationDidBecomeActive(_ application: UIApplication) {
    application.applicationIconBadgeNumber = 0
    coverView?.removeFromSuperview()
  }