Customizable (soon) value picker for SwiftUI.
![ValuePicker Demo](https://private-user-images.githubusercontent.com/7093328/406687348-58bf0f90-6c22-485c-9921-25012b5b9512.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMjc0NzcsIm5iZiI6MTczOTMyNzE3NywicGF0aCI6Ii83MDkzMzI4LzQwNjY4NzM0OC01OGJmMGY5MC02YzIyLTQ4NWMtOTkyMS0yNTAxMmI1Yjk1MTIuZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDIyNjE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGEzMDBjN2Y1OWUwODYyZjQ3YzdlOWM0Y2NiNmE4M2E1NDMyMjMyOWU2MTk0YjAxZGViMDgxZjU3MGZlNjEwNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.obPLqJYtlNoa2PIEuyDZRo-owNc5hliWuDKZ6x_dlhA)
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.