Skip to content

Commit

Permalink
✨ :: [#496] DEBUG 앱에서 Shake 감지 시 LogHistoryViewController present
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Apr 23, 2024
1 parent da290d0 commit b657457
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Projects/App/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b657457

Please sign in to comment.