目录

ios swift

Feedback

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

Building useful libraries like these, takes time away from my family. I build these tools in my spare time because I feel its important to give back to the community. Please consider Sponsoring me as it helps keep me working on useful libraries like these 😬

You can also give me a follow and a ‘thanks’ anytime.

Twitter

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"))

关于
47.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号