feat: add haptic feedback handling #428
Merged
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.
Changes in this pull request
Checklist
CHANGELOG.mdfor any breaking changes, enhancements, or bug fixes.swiftlintin the main directory and fixed any issues.Greptile Overview
Greptile Summary
Added native haptic feedback support for paywall buttons, enabling configurable haptic types from the paywall editor.
Key Changes:
hapticFeedbackmessage type inPaywallMessageenum with proper JSON decodingtriggerHapticFeedback()method supporting 7 haptic types: light, medium, heavy, success, warning, error, and selectionImplementation Details:
#if !os(visionOS)compiler directives)UIImpactFeedbackGeneratorfor impact styles,UINotificationFeedbackGeneratorfor notifications, andUISelectionFeedbackGeneratorfor selectionsNote: Previous review thread mentioned calling
.prepare()on generators for optimal performance. This remains unaddressed but is a minor performance optimization rather than a functional issue.Confidence Score: 4/5
.prepare()calls on feedback generators, which is a minor performance optimization rather than a functional problem. All haptic types are properly handled and visionOS is correctly excluded..prepare()on haptic generators before triggeringImportant Files Changed
hapticFeedbackmessage case with proper decoding supporttriggerHapticFeedback()method supporting 7 haptic types, but missing.prepare()calls for optimal performanceSequence Diagram
sequenceDiagram participant Web as Paywall WebView participant Handler as PaywallMessageHandler participant Generator as UIFeedbackGenerator participant System as iOS Haptic Engine Web->>Handler: haptic_feedback message<br/>(haptic_type: "medium") Handler->>Handler: handle(.hapticFeedback(hapticType)) Handler->>Handler: triggerHapticFeedback("medium") alt visionOS Handler->>Handler: Skip (no haptics on visionOS) else iOS/iPadOS alt Impact Feedback (light/medium/heavy) Handler->>Generator: Create UIImpactFeedbackGenerator Generator->>System: impactOccurred() else Notification Feedback (success/warning/error) Handler->>Generator: Create UINotificationFeedbackGenerator Generator->>System: notificationOccurred() else Selection Feedback Handler->>Generator: Create UISelectionFeedbackGenerator Generator->>System: selectionChanged() else Unknown Type Handler->>Handler: No-op (default case) end System-->>Generator: Trigger haptic end