Build one reusable SwiftUI view with state-driven animations, configurable parameters and Reduce Motion and VoiceOver handling.
Act as a SwiftUI developer. Build one reusable animated view for the use case below. ## Inputs Use case and where the view appears: [USE_CASE] Minimum iOS/macOS deployment target and Swift version: [PLATFORM] Animations wanted and what triggers each (tap, drag, appear, state change): [ANIMATIONS] Values the caller must be able to configure (colors, sizes, durations, content): [PARAMETERS] Existing design tokens or code conventions: [CONVENTIONS] ## Instructions 1. Model the animation with explicit state (for example an enum such as idle, running, completed) and drive the visual changes from that state, not from timers scattered across the view. 2. Implement the requested effects (for example scale, opacity, rotation, spring, matched geometry) with SwiftUI animation APIs such as `withAnimation`, `.animation(_:value:)` or transitions. Only use APIs available on the stated deployment target; if an API needs a newer OS, add an availability check or say so. 3. Expose the configurable values as initializer parameters with sensible defaults. 4. Read `accessibilityReduceMotion` from the environment and replace large motion (scaling, rotation, sliding) with a fade or an instant change when it is on. 5. Give interactive elements accessibility labels and traits, keep text in Dynamic Type, and make the layout work in compact and regular size classes and both orientations. 6. Keep the view self-contained: no network calls or global singletons unless the use case requires them. ## Return 1. One Swift file containing the view struct conforming to `View`, with short comments on non-obvious animation logic. 2. A `#Preview` (or PreviewProvider for older targets) showing default and customized configurations. 3. A table of each animation: trigger, property animated, curve/duration, Reduce Motion behavior. 4. Manual test steps: VoiceOver, Reduce Motion on/off, largest Dynamic Type size, rotation. 5. Assumptions and any APIs that need a newer OS than requested. ## Acceptance checks The file should compile for the stated target; state that you did not compile it unless you did. Do not claim a frame rate or performance result. Do not invent design tokens that were not supplied.
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
Use case: a Save button in a settings form that confirms success inline Platform: iOS 17, Swift 5.10 Animations: on tap the button scales slightly, a checkmark fades in and rotates once, label changes from "Save" to "Saved" Parameters: title, tint color, animation duration, action closure Conventions: no third-party packages; use system colors
A single `ConfirmButton: View` with `title`, `tint`, `duration` and `action` parameters; a state value that toggles inside `withAnimation`; scale, opacity and rotation applied from that state; an `@Environment(\.accessibilityReduceMotion)` branch that drops the scale and rotation; an accessibility label that changes to "Saved"; a preview; and an animation table plus manual VoiceOver/Reduce Motion test steps. Illustrative expectation, not a recorded model run. A reference implementation with these properties was type-checked locally (see report).
Ask questions or share concrete improvements.
No comments yet.
Sign in to join the discussion.
Guides for adapting and checking prompts: