Giter VIP home page Giter VIP logo

rxsplitslider's Introduction

RxSplitSlider

CI Status Version License Platform Swift

Reactive extension for SplitSlider.

Customizable two way slider split in the middle. Left and right parts are independent, each can have different min, max, step, colors, etc.

Screenshot

Usage

Simply add as custom view to storyboard or create programatically. Don't forget to import SplitSlider as well.

let slider = SplitSlider()

Generic slider properties (affects both parts):

// Minimal slider value.
slider.min = 0
// Maximal slider value.
slider.max = 100
// Step value of the slider.
slider.step = 5
// Font of the value labels.
slider.labelFont = UIFont.systemFont(ofSize: 10)
// Font color of the value labels.
slider.labelTextColor = UIColor.black
// Size of the slider's thumb.
slider.thumbSize = 20
// Color of the thumb.
slider.thumbColor = UIColor.darkGray
// Track height.
slider.trackHeight = 0
// Track color.
slider.trackColor = = UIColor.lightGray
// Color of selected part of the track.
slider.trackHighlightColor = UIColor.gray
// Determines if thumb should be snapped to the closest step after the move.
slider.snapToStep = true

All above properties would affect both portions of the slider but can be set individually through either slider.left or slider.right portion.

Observing changes

// Slider portion selected - called when user selects (holds) portion of the slider. Return `nil` when no portion is being selected.
splitSlider
    .rx
    .portionSelected
    .asDriver(onErrorJustReturn: nil)
    .drive(onNext: { portion in
        let portionString = portion == self.splitSlider.left ? "left" : "right"
        NSLog("Selected part: \(portion == nil ? "none" : portionString)")
    }).disposed(by: disposeBag)
    
// Slider value changed for portion of slider.
splitSlider
    .rx
    .portionValueChanged
    .asDriver(onErrorJustReturn: (0, SplitSliderPortion()))
    .drive(onNext: { [unowned self] (value, portion) in
        let portionString = portion == self.splitSlider.left ? "left" : "right"
        NSLog("Current value: \(value) (portion: \(portionString))")
    }).disposed(by: disposeBag)

Example

To run the example project, run pod try.

Requirements

iOS 8+.

Installation

RxSplitSlider is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "RxSplitSlider"

Author

Tomas Friml, [email protected]

License

RxSplitSlider is available under the MIT license. See the LICENSE file for more info.

rxsplitslider's People

Contributors

3ph avatar

Stargazers

Carabineiro avatar

Watchers

Carabineiro avatar  avatar

Forkers

carabina

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.