Issue #364
AppFlowController.swift
import UIKit
import GoogleMaps
import Stripe
final class AppFlowController: UIViewController {
private lazy var window = UIWindow(frame: UIScreen.main.bounds)
func configure() {
GMSServices.provideAPIKey(Constant.googleMapsApiKey)
STPPaymentConfiguration.shared().publishableKey = Constant.stripeKey
}
func start() {
if Deps.onboardingHandler.hasOnboarded {
startMain()
} else {
startOnboarding()
}
window.makeKeyAndVisible()
}
func startOnboarding() {
let controller = OnboardingController()
controller.delegate = self
window.rootViewController = controller
}
func startMain() {
let controller = MainFlowController()
window.rootViewController = controller
controller.start()
}
}
extension AppFlowController: OnboardingControllerDelegate {
func onboardingControllerDidFinish(_ controller: OnboardingController) {
Deps.onboardingHandler.hasOnboarded = true
startMain()
}
}
AppDelegate.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
private let appFlowController = AppFlowController()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
appFlowController.configure()
appFlowController.start()
UIApplication.shared.registerForRemoteNotifications()
FirebaseApp.configure()
return true
}
}