Code Monkey home page Code Monkey logo

hapticfeedbackkit's Introduction

HapticFeedbackKit

Swift Package Manager GitHub stars GitHub forks GitHub contributors Pull Requests Badge Issues Badge

Description

HapticFeedbackKit is a SwiftUI library for managing haptic feedback.
The primary purpose of this package is to provide users with the ability to enable or disable haptic feedback within the application.


Requirements

  • iOS: 17.0 or later.
  • macOS: 14.0 or later.

Installation

You can install HapticFeedbackKit using the Swift Package Manager.

  1. In Xcode, select "File" > "Add Package Dependencies".
  2. Copy & paste the following into the "Search or Enter Package URL" search bar.
https://github.com/JamesSedlacek/HapticFeedbackKit.git
  1. Xcode will fetch the repository & the "HapticFeedbackKit" library will be added to your project.

Usage

  1. Use .hapticFeedback() instead of .sensoryFeedback().
import HapticFeedbackKit
import SwiftUI

struct ContentView: View {
    @State private var taskIsComplete = false

    var body: some View {
        Button("Mark Complete") {
            taskIsComplete = true
        }
        .hapticFeedback(.success, trigger: taskIsComplete)
    }
}

  1. Use a HapticFeedbackToggle() in the settings screen in your project.
import HapticFeedbackKit
import SwiftUI

struct SettingsView {
    var body: some View {
        VStack {
            HapticFeedbackToggle()
        }
    }
}

Author

James Sedlacek, find me on X/Twitter or LinkedIn

hapticfeedbackkit's People

Contributors

jamessedlacek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sisoje

hapticfeedbackkit's Issues

Programmatically trigger haptic feedback

import SwiftUI

protocol HapticFeedbackServiceable {
    func perform(_ feedback: SensoryFeedback)
}

I'm imaging we would create a service to handle this and be able to inject it into views/viewModels.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.