Feature: Add SwiftUI ViewModifier for shake animation#6
Open
haaakon wants to merge 4 commits into
Open
Conversation
Add ShakeModifier (and a .shake(trigger:) View extension) that mirrors the UIKit UIView shake behaviour using a GeometryEffect-based approach, including VoiceOver accessibility announcement support. Also introduce Package.swift for Swift Package Manager distribution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ShakeEffect— aGeometryEffectthat drives a sine-wave horizontal translation, matching the UIKit version's back-and-forth oscillation behaviour.ShakeModifier— aViewModifierwrappingShakeEffect. Increment itstrigger: Intto start a new shake. Accepts an optionalaccessibilityAnnouncementthat is posted viaUIAccessibilitywhen VoiceOver is active (mirrorspostAccessabilityNotificationin the UIKit version)..shake(trigger:accessibilityAnnouncement:)convenience extension onViewso usage stays a single line.Package.swiftfor Swift Package Manager distribution alongside the existing CocoaPods podspec.README.mdwith a full SwiftUI usage section (basic, VoiceOver, and full button-driven example).Usage
Test plan
swift build(requires Xcode 13+ / swift-tools-version 5.5)SingleLineShakeAnimationvia SPM in a SwiftUI project and verify.shake(trigger:)compileserrorCountand confirm the target view shakes visuallyUIView.shake(_:)API is unaffected