A small SwiftUI project demonstrating a custom ViewModifier that detects device shake events using .onDeviceShake(isActive:action:).
Detects physical device shakes and triggers a custom action in SwiftUI views without needing to subclass UIKit components.
.onDeviceShake(isActive: true) {
// Handle shake
}DeviceShakeViewModifier.swift– reusable modifierShakeView.swift– demo UI with animated responseShakeViewModel.swift– simple view model for state handling
Drop the DeviceShakeViewModifier into your SwiftUI project and call .onDeviceShake(...) on any view to handle shakes.
This modifier is part of NnSwiftUIKit, a collection of custom SwiftUI view modifiers and utilities.
