AppDelegate.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // AppDelegate.swift
  3. // Chat (iOS)
  4. //
  5. // Created by Sergey Tarasov on 09.10.2022.
  6. //
  7. import UIKit
  8. import SwiftUI
  9. import XMPPFramework
  10. @main
  11. class AppDelegate: UIResponder, UIApplicationDelegate {
  12. var window: UIWindow?
  13. var rootViewController: UIViewController?
  14. func application(
  15. _ application: UIApplication,
  16. didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
  17. ) -> Bool {
  18. let loginStore: LoginStore = LoginStore { [weak self] login, password in
  19. XMPPController.shared.login(with: login, and: password)
  20. XMPPController.shared.connect()
  21. self?.rootViewController = UIHostingController(rootView: ContentView())
  22. self?.window?.rootViewController = self?.rootViewController
  23. }
  24. let loginView: LoginView = LoginView(store: loginStore)
  25. rootViewController = UIHostingController(rootView: loginView)
  26. window = UIWindow(frame: UIScreen.main.bounds)
  27. window?.rootViewController = rootViewController
  28. window?.makeKeyAndVisible()
  29. DDLog.add(DDOSLogger.sharedInstance, with: DDLogLevel.all)
  30. return true
  31. }
  32. }