Swiftpack.co - timdubbins/Sliders as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by timdubbins.
timdubbins/Sliders 1.0.2
A collection of sliders for SwiftUI. Includes range and round sliders.
⭐️ 6
🕓 1 year ago
iOS macOS
.package(url: "https://github.com/timdubbins/Sliders.git", from: "1.0.2")

Sliders

Current version: 1.0.2 [Download]

A collection of custom sliders for SwiftUI.

  • RoundSlider gives you a slider that acts as a dial or knob.
  • RangeSlider lets you select a range using a slider with two thumbs.

me

Getting Started

To use Sliders in a project, add this descriptor to the dependencies list in your Package.swift file:

.package(url: "https://github.com/timdubbins/sliders", .exact("1.0.2")) 

Alternatively, in Xcode, go to:

File > Add Packages...

and enter

https://github.com/timdubbins/sliders

as the package URL.

Examples

RoundSlider

@State private var myValue = 30.0
@State private var isEditing = false

var body: some View {
    RoundSlider(
        "title",
        value: $myValue,
        in: 10...70,
        displayBounds: 0...10,
        color: .green) {
            isEditing = $0
        }
}

RangeSlider

@State private var lowValue = 0.0
@State private var highValue = 10.0
@State private var isEditing = false

var body: some View {
    VStack {
        RangeSlider(
            lowValue: $lowValue,
            highValue: $highValue,
            in: 0...10,
            showDifferenceOnEditing: true) {
                isEditing = $0
            }
        Text(String(isEditing))
            .foregroundColor(isEditing ? .red : .green)
    }
    .padding()
}

Happy coding!

GitHub

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

Release Notes

Sliders 1.0.2
1 year ago

The sliders now use generic binary floating point types. This means you can use them with any floating point data (Float, Double, CGFloat, etc).

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