Customizable (soon) value picker for SwiftUI.
Note
Please note that this is a work in progress. Planned features include, but are not limited to:
- Haptic feedback
- Custom styles
- More platforms (macOS, tvOS, watchOS, visionOS)
From Xcode menu: File
> Swift Packages
> Add Package Dependency
https://github.com/Recouse/ValuePicker
In your Package.swift
file, first add the following to the package dependencies
:
.package(url: "https://github.com/Recouse/ValuePicker.git"),
And then, include "ValuePicker" as a dependency for your target:
.target(name: "<target>", dependencies: [
.product(name: "ValuePicker", package: "ValuePicker"),
]),
The API is designed to resemble SwiftUI's Picker. Instead of using tag()
, you should use valuePickerTag()
, which also accepts any Hashable
value.
import SwiftUI
import ValuePicker
struct ContentView: View {
@State private var revenueSelection: String = "Weekly"
var body: some View {
VStack(alignment: .leading) {
Text("Revenue")
.font(.title)
ValuePicker(selection: $revenueSelection) {
ForEach(["Weekly", "Monthly", "Quarterly", "Yearly"], id: \.self) { option in
Text(option)
.valuePickerTag(option)
}
}
}
.padding()
}
}
- iOS 15.0+
- macOS 12.0+
- visionOS 1.0+
No dependencies.
Contributions to are always welcomed! If you'd like to contribute, please fork this repository and submit a pull request with your changes.
ValuePicker is released under the MIT License. See LICENSE for more information.