Skip to content

Latest commit

 

History

History
84 lines (60 loc) · 2.57 KB

README.md

File metadata and controls

84 lines (60 loc) · 2.57 KB

ValuePicker

Customizable (soon) value picker for SwiftUI.

ValuePicker Demo

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)

Installation

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

Usage

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()
    }
}

Compatibility

  • iOS 15.0+
  • macOS 12.0+
  • visionOS 1.0+

Dependencies

No dependencies.

Contributing

Contributions to are always welcomed! If you'd like to contribute, please fork this repository and submit a pull request with your changes.

License

ValuePicker is released under the MIT License. See LICENSE for more information.