-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
570216c
commit ef0be5f
Showing
1 changed file
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,61 @@ | ||
# HapticEngine | ||
|
||
HapticEngine prives a class to make easy for developers create haptics effects on SwiftUI. | ||
Haptic Engine is a wrapper of [`Core Haptics`](https://developer.apple.com/documentation/corehaptics) to make it easier to create haptic taps combinations. | ||
|
||
## Usage | ||
|
||
```swift | ||
import HapticEngine | ||
|
||
let engine = HapticsEngine() | ||
|
||
try? engine.launch(intensity: 0.2, sharpness: 0.8) | ||
|
||
|
||
``` | ||
|
||
### Integration with SwiftUI | ||
|
||
`HapticEngine` use Combine powerfull framework with `@Environment`. Create you own `engine` and pass as an environment object on root App View. Then, yo can access on any of your views Like that | ||
|
||
```swift | ||
import SwiftUI | ||
import HapticEngine | ||
|
||
@main | ||
struct ExampleApp: App { | ||
|
||
|
||
let haptics = HapticsEngine() | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
RuinNavigation() | ||
.environmentObject(haptics) | ||
} | ||
} | ||
} | ||
|
||
struct SomeView: View { | ||
|
||
|
||
@EnvironmentObject private var haptics: HapticsEngine | ||
. | ||
. | ||
. | ||
. | ||
. | ||
} | ||
``` | ||
## Installation | ||
|
||
#### SwiftPM | ||
|
||
```swift | ||
dependencies: [ | ||
.package(url: "https://github.com/josavicente/HapticEngine", from: "0.0.1") | ||
], | ||
targets: [ | ||
.target(name: "YourTarget", dependencies: ["HapticEngine"]) | ||
] | ||
``` |