Contents

recouse/valuepicker

> [!Warning]

Installation

Xcode Package Dependency

From Xcode menu: File > Swift Packages > Add Package Dependency

https://github.com/Recouse/ValuePicker
Swift Package Manager

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.

Package Metadata

Repository: recouse/valuepicker

Default branch: main

README: README.md