Contents

shaps80/feedback

A SwiftUI library for conveniently adding haptic, audio and other feedback to your view's and state changes.

Features

  • Familiar API (follow transition and animation API styles)
  • Haptics
  • Audio
  • Screen flash

Usage

Imperative feedback

struct ContentView: View {
    var body: some View {
        Button {
            withFeedback(
                .haptic(.selection)
                .combined(
                    .audio(.keyboardPress)
                )
            ) {
                // state change
            }
        } label: {
            Text("Submit")
        }
    }
}

State observation

struct ContentView: View {
    @State private var toggle: Bool = false
    
    var body: some View {
        Toggle("Toggle", isOn: $toggle.feedback(.haptic(.selection)))
    }
}

Installation

You can install manually (by copying the files in the Sources directory) or using Swift Package Manager (preferred)

To install using Swift Package Manager, add this to the dependencies section of your Package.swift file:

.package(url: "https://github.com/shaps80/Feedback.git", .upToNextMinor(from: "1.0.0"))

Package Metadata

Repository: shaps80/feedback

Default branch: main

README: README.md