ChatApp.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // ChatApp.swift
  3. // Shared
  4. //
  5. // Created by Sergey Tarasov on 24.07.2022.
  6. //
  7. import SwiftUI
  8. import XMPPFramework
  9. @main
  10. struct ChatApp: App {
  11. var body: some Scene {
  12. WindowGroup {
  13. ContentView()
  14. .onAppear(perform: UIApplication.shared.addTapGestureRecognizer)
  15. }
  16. }
  17. }
  18. class AppDelegate: NSObject, UIApplicationDelegate {
  19. func application(
  20. _ application: UIApplication,
  21. didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
  22. ) -> Bool {
  23. DDLog.add(DDTTYLogger.sharedInstance!, with: DDLogLevel.all)
  24. return true
  25. }
  26. }
  27. extension UIApplication {
  28. func addTapGestureRecognizer() {
  29. guard let window = windows.first else { return }
  30. let tapGesture = UITapGestureRecognizer(target: window, action: #selector(UIView.endEditing))
  31. tapGesture.requiresExclusiveTouchType = false
  32. tapGesture.cancelsTouchesInView = false
  33. tapGesture.delegate = self
  34. window.addGestureRecognizer(tapGesture)
  35. }
  36. }
  37. extension UIApplication: UIGestureRecognizerDelegate {
  38. public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
  39. return false
  40. }
  41. }