File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // The MIT License (MIT)
2+ //
3+ // Copyright (c) 2020-2024 Alexander Grebenyuk (github.com/kean).
4+
5+ import UIKit
6+ import SwiftUI
7+
8+ #if os(iOS)
9+
10+ extension UIViewController {
11+
12+ // swiftlint:disable:next override_in_extension
13+ open override func motionBegan( _ motion: UIEvent . EventSubtype , with event: UIEvent ? ) {
14+
15+ if #available( iOS 16 . 0 , * ) ,
16+ motion == . motionShake,
17+ UserDefaults . standard. bool ( forKey: ConsoleView . shakeToPresentIsEnableKey) {
18+
19+ let logVC = UIHostingController ( rootView: NavigationStack { ConsoleView ( ) } )
20+ present ( logVC, animated: true , completion: nil )
21+ }
22+
23+ next? . motionBegan ( motion, with: event)
24+ }
25+ }
26+
27+ extension ConsoleView {
28+ static let shakeToPresentIsEnableKey = " pulse-shake-to-present-is-enabled "
29+
30+ public static func shakeToPresent( isEnabled: Bool ) {
31+ UserDefaults . standard. set ( isEnabled, forKey: shakeToPresentIsEnableKey)
32+ }
33+ }
34+
35+ #endif
You can’t perform that action at this time.
0 commit comments