Simplify the integration of haptic feedback in your SwiftUI applications with HapticEase. Trigger various haptic feedback types and custom patterns effortlessly.
HapticEase
is a lightweight Swift library that simplifies the integration of haptic feedback in your SwiftUI applications. Whether you’re looking to add a simple vibration or a complex pattern, HapticEase
provides an easy-to-use interface to enhance your app’s user experience with tactile feedback.
To integrate HapticEase
into your project using Swift Package Manager, add it to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/emreeilhan/HapticEase.git", from: "1.0.0")
]
Or, you can add the package directly within Xcode by going to:
File > Swift Packages > Add Package Dependency...
and enter the repository URL:
https://github.com/emreeilhan/HapticEase.git
To use basic haptic feedback, create an instance of HapticFeedback
and call the desired method:
import HapticEase
let haptic = HapticFeedback()
haptic.success() // Triggers a success haptic feedback
HapticEase
also allows you to create custom haptic patterns:
let haptic = HapticFeedback()
haptic.customLightPattern() // Triggers a custom light pattern
You can use HapticFeedbackModifier
to easily integrate haptic feedback into any SwiftUI view:
import SwiftUI
import HapticEase
struct ContentView: View {
@State private var triggerHaptic = false
var body: some View {
Button("Trigger Success Haptic") {
triggerHaptic.toggle()
}
.hapticFeedback(trigger: triggerHaptic, type: .success)
}
}
Comprehensive documentation is available here.
Contributions are welcome! If you’d like to contribute, please fork the repository and use a feature branch. Pull requests should be made against the main
branch.
git checkout -b feature/AmazingFeature
).git commit -m 'Add some AmazingFeature'
).git push origin feature/AmazingFeature
).HapticEase
is available under the MIT license. See the LICENSE file for more information.