ChatApp.swift 968 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // ChatApp.swift
  3. // Shared
  4. //
  5. // Created by Sergey Tarasov on 24.07.2022.
  6. //
  7. import SwiftUI
  8. @main
  9. struct ChatApp: App {
  10. var body: some Scene {
  11. WindowGroup {
  12. ContentView()
  13. .onAppear(perform: UIApplication.shared.addTapGestureRecognizer)
  14. }
  15. }
  16. }
  17. extension UIApplication {
  18. func addTapGestureRecognizer() {
  19. guard let window = windows.first else { return }
  20. let tapGesture = UITapGestureRecognizer(target: window, action: #selector(UIView.endEditing))
  21. tapGesture.requiresExclusiveTouchType = false
  22. tapGesture.cancelsTouchesInView = false
  23. tapGesture.delegate = self
  24. window.addGestureRecognizer(tapGesture)
  25. }
  26. }
  27. extension UIApplication: UIGestureRecognizerDelegate {
  28. public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
  29. return false
  30. }
  31. }