Swiftpack.co - yannxou/TapTempoButton as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by yannxou.
yannxou/TapTempoButton 1.0.1
SwiftUI View to easily add tap tempo functionality to music apps.
⭐️ 1
🕓 1 year ago
iOS macOS watchOS tvOS macCatalyst
.package(url: "https://github.com/yannxou/TapTempoButton.git", from: "1.0.1")

TapTempoButton

A SwiftUI View that easily brings tap tempo functionality to music apps.

How it works

The TapTempoButton takes a content closure so it can be customized. The whole view will handle the tap events automatically and calculate the tempo average (in BPM) which is sent in the onTempoChange closure on each change.

Rather than processing the touch events like a standard Button (on touch up) the view handles them on touch down so the button behaviour is more natural in a musical context.

TapTempoButtonPreview

Usage

Add the TapTempoButton to your View and customize it with the content closure.

TapTempoButton(onTempoChange: {
    self.tempo = $0
}) {
    Text("Tap")
}

It can also be customized like a regular SwiftUI Button:

.buttonBorderShape(.capsule)
.buttonStyle(.bordered)

or

.buttonStyle(MyButtonStyle())

Configuration

The following properties can be configured on initialization:

  • tempoRange: Defines the minimum and maximum tempo that can be detected.
  • timeout: Seconds of inactivity after which the ongoing detection will be restarted.
  • minTaps: Minimum number of taps required before sending values to the onTempoChange closure.
  • roundDecimals: Number of decimals to round the BPM to. Set to 0 for integer-only BPM (no decimals). Set to nil to disable rounding.

Installation

  1. From the File menu, select Add Packages...
  2. Enter package repository URL: https://github.com/yannxou/TapTempoButton
  3. Confirm the version and let Xcode resolve the package

Support

The idea for this library appeared while working on the app Vetro: Visual Metronome for iOS/macOS. If you like it you can support us by buying any of our apps.

License

This library is released under the MIT license. See LICENSE for details.

GitHub

link
Stars: 1
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.0.1
1 year ago
  • Fixed TouchDown behaviour on macOS
  • Allow using keyboardShortcut

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics