Skip to content

๐ŸŽš๏ธ STDiscreteSlider โ€“ slider which allows user to choose value only from predefined set of data.

License

Notifications You must be signed in to change notification settings

onl1ner/STDiscreteSlider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

STDiscreteSlider

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.

Table of contents

Requirements

  • SwiftUI
  • iOS 13.0 or above

Installation

STDiscreteSlider is available through CocoaPods and Swift Package Manager

CocoaPods

  • Add the following line into your Podfile:

    pod 'STDiscreteSlider'
  • Then run this command in your terminal:

    $ pod install

Swift Package Manager

  • In Xcode select:

    File > Swift Packages > Add Package Dependency...
    
  • Then paste this URL:

    https://github.com/onl1ner/STDiscreteSlider.git
    

Usage

STDiscreteSlider is highly customizable, you could use it with it's default appearance or create your own.

Quick start

To create a slider simply instantiate STDiscreteSlider class:

STDiscreteSlider(
    options: [20, 40, 60, 80, 100], // Options that is used as a data source for the slider.
    selectedItem: $mySelectedItem   // Binding to the property that will store the selected item.
)

This action will create a slider with default appearance.

Customization

Customization of a slider is not a big deal. STDiscreteSlider provides three protocols that is used to represent the components of a slider: SliderTrack, SliderTick, SliderHandle. By implementing each of the protocol you will be able to build your custom slider.

Some examples of what you can achieve by customizing slider:

Source code of these sliders provided in examples.

Contribution

If you struggle with something feel free to open an issue. Pull requests are also appreciated.

License

STDiscreteSlider is under the terms and conditions of the MIT license.

MIT License

Copyright (c) 2021 Tamerlan Satualdypov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

๐ŸŽš๏ธ STDiscreteSlider โ€“ slider which allows user to choose value only from predefined set of data.

Topics

Resources

License

Stars

Watchers

Forks