From 057f5e260e2f0baa46885687c6271b8876cfeef1 Mon Sep 17 00:00:00 2001 From: baegteun Date: Tue, 23 Apr 2024 23:24:04 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20::=20[#496]=20DEBUG=20=EC=95=B1?= =?UTF-8?q?=EC=97=90=EC=84=9C=20Shake=20=EA=B0=90=EC=A7=80=20=EC=8B=9C=20L?= =?UTF-8?q?ogHistoryViewController=20present?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../App/Sources/Application/AppDelegate.swift | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Projects/App/Sources/Application/AppDelegate.swift b/Projects/App/Sources/Application/AppDelegate.swift index e2b756e7a..88ea3a69c 100644 --- a/Projects/App/Sources/Application/AppDelegate.swift +++ b/Projects/App/Sources/Application/AppDelegate.swift @@ -103,3 +103,38 @@ private extension AppDelegate { ]) } } + +#if DEBUG + extension UIWindow { + override open func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { + super.motionEnded(motion, with: event) + switch motion { + case .motionShake: + guard let topViewController = if #available(iOS 15.0, *) { + UIApplication.shared.connectedScenes + .compactMap { $0 as? UIWindowScene } + .filter { $0.activationState == .foregroundActive } + .first? + .keyWindow? + .rootViewController + } else { + UIApplication.shared.connectedScenes + .compactMap { $0 as? UIWindowScene } + .filter { $0.activationState == .foregroundActive } + .first? + .windows + .first(where: \.isKeyWindow)? + .rootViewController + } else { break } + if let nav = topViewController as? UINavigationController { + nav.visibleViewController?.present(LogHistoryViewController(), animated: true) + } else { + topViewController.present(LogHistoryViewController(), animated: true) + } + + default: + break + } + } + } +#endif