|
// |
|
// AppDelegate.swift |
|
// |
|
// Copyright © 2024 Q42. All rights reserved. |
|
// |
|
|
|
import UIKit |
|
import FirebaseCore |
|
import FirebaseCrashlytics |
|
import Factory |
|
|
|
@main |
|
class AppDelegate: NSObject, UIApplicationDelegate { |
|
|
|
// MARK: App setup |
|
|
|
func application( |
|
_ application: UIApplication, |
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil |
|
) -> Bool { |
|
|
|
configureFirebase() |
|
configureCrashlytics() |
|
|
|
applyAppearance() |
|
|
|
performMigrations() |
|
performAppSetup() |
|
|
|
return true |
|
} |
|
|
|
/// Sets the global appearance of UIKit components using their appearance proxies. |
|
private func applyAppearance() { |
|
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor.brandPrimaryForeground |
|
UIPageControl.appearance().pageIndicatorTintColor = UIColor.brandTertiaryBackground |
|
|
|
let appearance = UINavigationBarAppearance() |
|
|
|
appearance.largeTitleTextAttributes = [ |
|
.foregroundColor: UIColor.brandPrimaryForeground, |
|
.font: UIFont(name: "My Cool Font Regular", size: 42)! |
|
] |
|
|
|
appearance.titleTextAttributes = [ |
|
.foregroundColor: UIColor.brandPrimaryForeground, |
|
.font: UIFont(name: "My Cool Font Regular", size: 18)! |
|
] |
|
|
|
appearance.backgroundEffect = nil |
|
appearance.backgroundColor = .brandPrimaryBackground |
|
UINavigationBar.appearance().standardAppearance = appearance |
|
} |
|
|
|
private func configureFirebase() { |
|
// Configure Firebase SDK |
|
let firebaseConfigFileName = Bundle.main.object(forInfoDictionaryKey: "FIREBASE_CONFIGURATION_FILE") as! String |
|
let firebaseConfigPath = Bundle.main.path(forResource: firebaseConfigFileName, ofType: "plist")! |
|
let firebaseOptions = FirebaseOptions(contentsOfFile: firebaseConfigPath)! |
|
FirebaseApp.configure(options: firebaseOptions) |
|
} |
|
|
|
private func configureCrashlytics() { |
|
let isSwiftUIPreview = ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" |
|
|
|
// Additional var keeps room for additional critera to be added later |
|
let crashlyticsEnabled = !isSwiftUIPreview |
|
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(crashlyticsEnabled) |
|
} |
|
|
|
/// Performs the initial app setup, if necessary (on the first launch). This includes: |
|
/// - <enter info here> |
|
private func performAppSetup() { |
|
} |
|
|
|
/// Performs data migrations from previous versions of the app, if necessary. |
|
private func performMigrations() { |
|
} |
|
|
|
// MARK: UISceneSession Lifecycle |
|
|
|
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { |
|
// Called when a new scene session is being created. |
|
// Use this method to select a configuration to create the new scene with. |
|
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) |
|
} |
|
|
|
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { |
|
// Called when the user discards a scene session. |
|
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. |
|
// Use this method to release any resources that were specific to the discarded scenes, as they will not return. |
|
} |
|
} |