Dragger - A Customizable Drag Slider swiftUI view

Related tags

Slider Dragger
Overview

Dragger

A customizable SwiftUI Dragger view.

Installation

In Xcode add https://github.com/kwiessle/Dragger.git in your package dependencies.

Usage

import SwiftUI
import Dragger

struct ContentView: View {
    
    @State var isComplete: Bool = false
    
    var body: some View {
        Dragger(isComplete: $isComplete)
    }
    
}

Create your own style

By default the Dragger style mimics the iOS Toggle's design, but you can create your own !
A Dragger view is represented by three components: Body, Track and Thumb

1 - Create a struct and make it conforms to the DraggerStyle protocol
2 - Provide layout constants for insets, thumbSize and trackHeigth
3 - Provide your own view implementation for each component

struct MyCustomStyle: DraggerStyle {
    
    var insets: CGFloat = 5
    
    var thumbSize: CGSize = CGSize(width: 46, height: 46)
    
    var trackHeight: CGFloat = 50
    
    func makeBody(configuration: Configuration) -> some View {
        Capsule().fill(.gray)
    }
    
    func makeTrack(configuration: Configuration) -> some View {
        LinearGradient(colors: [.pink, .purple, .blue], startPoint: .topLeading, endPoint: .bottomTrailing)
            .clipShape(Capsule())
            .opacity(3 * configuration.fractionComplete)
    }
    
    func makeThumb(configuration: Configuration) -> some View {
        Circle()
            .fill(.white)
        Image(systemName:"star.fill")
            .rotationEffect(.radians(2 * .pi * configuration.fractionComplete))
            .foregroundColor(configuration.isComplete ? .green : .red)
    }
    
}

DraggerStyleConfiguration

Provides real time access of Dragger's state values

  • configuration.isComplete: The current state of the dragger
  • configuration.fractionComplete: The current progress amount of the thumb
  • configuration.isHoldingThumb: Tells if the user is holding the thumb

4 - Pass your style to the dragger using .dragerStyle() modifier.

    var body: some View {
        Dragger(isComplete: $isComplete)
            .draggerStyle(MyCustomStyle())
    }

Layout overview

Notes

  • The final heigth of the dragger view is computed from the configuration's .insets and .trackHeight.
  • If the provided thumb size height lower than the track height the Dragger will add horizontal padding in order to center the thumb.
You might also like...
This is an iOS Tweak that modifies the brightness slider in the Control Center.
This is an iOS Tweak that modifies the brightness slider in the Control Center.

AdvancedBrightnessSlider Tweak This is an iOS Tweak that modifies the brightness slider in the Control Center. Even with dark mode toggled on, I found

Use UIResponder to imitate an iOS slider.
Use UIResponder to imitate an iOS slider.

WWSlider Use UIResponder to imitate an iOS slider. 使用UIResponder仿造一個iOS的滑桿. Installation with Swift Package Manager dependencies: [ .package(url:

VolumeControl is a custom volume control for iPhone featuring a well-designed round slider.
VolumeControl is a custom volume control for iPhone featuring a well-designed round slider.

#VolumeControl VolumeControl is a custom volume control for iPhone featuring a well-designed round slider. Preview Usage // Include VolumeControl.h in

Simple and light weight slider with chapter management
Simple and light weight slider with chapter management

Simple and light weight slider with chapter management Demo Installation CocoaPods WESlider is available through CocoaPods. To install it, simply add

IntervalSlider is a slider library like ReutersTV app. written in pure swift.
IntervalSlider is a slider library like ReutersTV app. written in pure swift.

IntervalSlider Description and appetize.io`s DEMO To run the example project, clone the repo, and run pod install from the Example directory first. Re

A simple range slider made in Swift
A simple range slider made in Swift

RangeSlider Summary A simple range slider made in Swift. Screenshot Use This control is IBDesignable and uses the target-action pattern for change not

CircleSlider is a Circular slider library. written in pure Swift.
CircleSlider is a Circular slider library. written in pure Swift.

CircleSlider Description and appetize.io`s DEMO Usage To run the example project, clone the repo, and run pod install from the Example directory first

A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range.
A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range.

TTRangeSlider A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range. Installation TTRangeSlider is availabl

StepSlider its custom implementation of slider such as UISlider for preset integer values.
StepSlider its custom implementation of slider such as UISlider for preset integer values.

StepSlider StepSlider its custom implementation of slider such as UISlider for preset values. Behind the scenes StepSlider manipulate integer indexes.

Comments
  • Reste to default state

    Reste to default state

    How can I reset to the default state?

    Imagin after swiping full do a calculation and if the result is less than 100 I need to reset or animate swipe back to zero posioion

    opened by Albinzr 0
Owner
Kiefer Wiessler
Only creation combined with passion matters.
Kiefer Wiessler
A custom reusable slider control with 2 thumbs (range slider).

MARKRangeSlider A custom reusable slider control with 2 thumbs (range slider). Values range is between minimumValue and maximumValue (from 0 to 1 by d

Vadym Markov 181 Nov 21, 2022
Customizable animated slider for iOS

MMSegmentSlider MMSegmentSlider is an easy-to-use IBDesignable animated slider for iOS 7+ written in Objective-C. Installation From CocoaPods CocoaPod

Max Medvedev 48 Jul 26, 2022
RangeSeedSlider provides a customizable range slider like a UISlider.

RangeSeekSlider Overview RangeSeekSlider provides a customizable range slider like a UISlider. This library is based on TomThorpe/TTRangeSlider (Objec

WorldDownTown 644 Dec 12, 2022
VerticalSlider - An animatable and customizable vertical slider written in Swift 4

VerticalSlider An animatable and customizable vertical slider written in Swift 4. Quick Start VerticalSliderPlayground Clone Repo Open VSVerticalSlide

Vincent Smithers 13 Apr 26, 2022
Customizable animated slider for iOS

MMSegmentSlider MMSegmentSlider is an easy-to-use IBDesignable animated slider for iOS 7+ written in Objective-C. Installation From CocoaPods CocoaPod

Max Medvedev 48 Jul 26, 2022
A reusable Slider View made with SwiftUI

ZSlider A reusable Slider View made with SwiftUI. Installation: Minimum version iOS 13 In Xcode go to File -> Swift Packages -> Add Package Dependency

null 7 Dec 15, 2022
A UISlider subclass that displays the slider value in a popup view

ASValueTrackingSlider ###What is it? A UISlider subclass that displays live values in an easy to customize popup view. ![screenshot] (http://alskipp.g

Al Skipp 1.8k Dec 16, 2022
TriggerSlider is a simple SwiftUI trigger slider

TriggerSlider is a simple SwiftUI trigger slider which can be used instead of a button, e.g. in a situation where the

Dominik Butz 4 Dec 16, 2022
🎚️ STDiscreteSlider – slider which allows user to choose value only from predefined set of data.

STDiscreteSlider – slider which allows user to choose value only from predefined set of data. Slider may receive any types of options, you may pass set of integers or strings, or any other type. Written using SwiftUI.

Tamerlan Satualdypov 15 Apr 3, 2022
Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle!

iLabeledSeekSlider Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle! Minimum iOS v

Edgar Žigis 9 Aug 16, 2022