1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //
- // ChatApp.swift
- // Shared
- //
- // Created by Sergey Tarasov on 24.07.2022.
- //
- import SwiftUI
- import XMPPFramework
- @main
- struct ChatApp: App {
- @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
- var body: some Scene {
- WindowGroup {
- ContentView()
- .onAppear(perform: UIApplication.shared.addTapGestureRecognizer)
- }
- }
- }
- class AppDelegate: NSObject, UIApplicationDelegate {
- func application(
- _ application: UIApplication,
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
- ) -> Bool {
- DDLog.add(DDOSLogger.sharedInstance, with: DDLogLevel.all)
- return true
- }
- }
- extension UIApplication {
- func addTapGestureRecognizer() {
- let scenes = UIApplication.shared.connectedScenes
- let windowScene = scenes.first as? UIWindowScene
- guard let window = windowScene?.windows.first else { return }
- let tapGesture = UITapGestureRecognizer(target: window, action: #selector(UIView.endEditing))
- tapGesture.requiresExclusiveTouchType = false
- tapGesture.cancelsTouchesInView = false
- tapGesture.delegate = self
- window.addGestureRecognizer(tapGesture)
- }
- }
- extension UIApplication: UIGestureRecognizerDelegate {
- public func gestureRecognizer(
- _ gestureRecognizer: UIGestureRecognizer,
- shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer
- ) -> Bool {
- return false
- }
- }
|