Code Monkey home page Code Monkey logo

multislider's People

Contributors

benjaminfischer avatar hroland avatar joeypatino avatar maxcan avatar sluzhynskyi avatar yonat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multislider's Issues

keepsDistanceBetweenThumbs not working in different screen size

Description of the problem:
I have a slider with two thumbs. When I set keepsDistanceBetweenThumbs = true and distanceBetweenThumbs = 0 both thumbs overlaps but the slider value maintains a distance. And also this problem only occurs when we run the app greater than regular size iPhone. It also occurs when keepsDistanceBetweenThumbs = false.

Snap of my Code:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        slider()
    }
    
    func slider() {
        var slider = MultiSlider()
        slider.translatesAutoresizingMaskIntoConstraints = false
        self.view.addSubview(slider)
        slider.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 200).isActive = true
        slider.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 50).isActive = true
        slider.widthAnchor.constraint(equalToConstant: 200).isActive = true
        slider.heightAnchor.constraint(equalToConstant: 100).isActive = true
        slider.orientation = .horizontal
        slider.tintColor = UIColor.red
        slider.outerTrackColor =  UIColor.green
        slider.trackWidth = 3
        slider.showsThumbImageShadow = false
        slider.maximumValue = 143148.11
        slider.minimumValue = 125728.91
        slider.value = [125728.91, 143148.11]
        slider.keepsDistanceBetweenThumbs = true
        slider.distanceBetweenThumbs = 0
        slider.addTarget(self, action: #selector(sliderChanged), for: .valueChanged)
    }
    
    @objc func sliderChanged(slider: MultiSlider) {
        print("thumb \(slider.draggedThumbIndex) moved")
        print("now thumbs are at \(slider.value)") // when overlap I get [125728.91, 125711.93] when right thumb at left most position
    }

No such module 'MiniLayout'

I'm on Xcode 8.2.1

I pulled down master branch. Ran pod install in example folder. Opened .xcworkspace file and tried to build.

Then I got this error: No such module 'MiniLayout'.

Setting different UIImageViews for each thumbImage

it just keeps crushing when trying to assign:

self.multiSlider.thumbViews = [imageView1,imageView2,imageView3]

it gives

'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view?'

I've tried adding imageviews to view hierarchy to main view and even multislider

AvailableHapticFeedback

Hello
Description of the problem:
Is it possible that the framework relies on AvailableHapticFeedback?
I get a link error in Xcode 11.3 building an ios 12 app.

I see there is an open issue from 2019 on this.

Thanks, Thomas

Layout of horizontal slider looks weird on iOS 12

Xcode 10.0 beta 3 (10L201y)

…moving the slider crashes the App: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Multiplier is not finite! That's illegal. multiplier:inf'

simulator screen shot - iphone 8 - 2018-07-16 at 21 18 34

Initial value doesnot show positiveSuffix

Description of the problem:
[description]

Minimal project that reproduces the problem (so I'll be able to figure out how to fix it):
[github repo or a zipped project]

Slider not showing inside UIStackView

Description of the problem:

I have made an instance of the slider and simply added it as and arranged subview to my stack view but the slider is shown in a very weird way. I am attaching an image where the blue line is supposed to be the slider. I have also tried to change its orientation to .horizontal but it did not help

    private var slider: MultiSlider = MultiSlider()
    stack.addArrangedSubview(slider)

Snímek obrazovky 2019-10-08 v 12 51 25

Constraint margins becoming mutable.

Unable to change the margin by which the MultiSlider sits within.
Right now that value is 32:
let margin: CGFloat = 32

Should be able to change the padding around the slider with constants that the developer is okay with.

Problems I encountered when trying to implement this myself: Had to unlock file from cocoa pods in order to change it.

setting different images to individual thumb

Hi,
I would like to assign a different image to each individual thumb. I want to have a slider that has 3 thumbs. The left and right thumbs are my start and end thumbs, while the middle thumb is a progress thumb to show the progress of an audio/video player. I would like have the start and end thumbs have a different image while the middle progress thumb will different image. Please let me know if this is already available ? or how would I implement them.

thanks,
-Vittal
email-dot-vittal-at-gmail-dot-com

Horizontal Slider?

Can I create a horizontal slider? Is this implemented yet? If not, have you considered adding this feature?

Different image for each thumb

Hello, firstly let me thank you guys for this awesome range slider component, and then let me ask you guys if you could make a feature that allows to give each thumb it's own image.

Thank you in advance

Request to access current dragging index during value changes.

Description:
Can we get the current dragging index so that we know which slider is user trying to slider / value changes?

Problems I encountered when trying to implement this myself:
The multiple slider.value is returning array of values which I'm not sure how to get the last changing value.

2 Storyboard errors

I got 2 storyboard errors when I added a slider into the storyboard. They are:

error: IB Designables: Failed to render and update auto layout status for MyViewController (X4n-4q-1cD): dlopen(MultiSlider.framework, 1): Library not loaded: @rpath/MiniLayout.framework/MiniLayout
Referenced from: MultiSlider.framework
Reason: image not found

error: IB Designables: Failed to update auto layout status: dlopen(MultiSlider.framework, 1): Library not loaded: @rpath/MiniLayout.framework/MiniLayout
Referenced from: MultiSlider.framework
Reason: image not found

It's not affecting compilation though. How can I get rid of them?

Issue when placing MultiSlider in tableview cell

Hi.

I have an issue with this slider. I'm using several MultiSliders in a tableview but when I try to scroll it, If my pan gesture starts on one of the MultiSliders, the gesture is captured by the slider and scroll doesn't work until I start panning from outside the sliders.

Is there any possibility to improve the slider to propagate the pan to superview if we needed?

Thanks.

Constraints

Hello, in UITableViewCell constraints break

Constraints breaking in SwiftUI Form

Description of the problem:
When implementing MultiSlider in SwiftUI Form, the height constraints break which causes the slider to disappear until I explicitly scroll back and forth to its position.

My Installation Process

File -> Swift Packages -> Add Package Dependency -> [URL: https://github.com/yonat/MultiSlider], [Branch: swiftui]

Code Snippet

    Form {
        Section {
            VStack {
                HStack {
                    Text("Age")
                    Spacer()
                    Text("\(Int(selectedAgeRange[0])) - \(Int(selectedAgeRange[1]))")
                }.font(.title)
                MultiValueSlider(
                    value: $selectedAgeRange,
                    minimumValue: 18,
                    maximumValue: 80,
                    snapStepSize: 1,
                    outerTrackColor: .lightGray,
                    keepsDistanceBetweenThumbs: true
                )
            }
        }
    }

Debug Log

When the slider is not visible

(
    "<NSAutoresizingMaskLayoutConstraint:0x283b505a0 h=--& v=--& multi_slider.height == 63   (active, names: multi_slider:0x137f04cb0 )>",
    "<NSLayoutConstraint:0x283b5b890 multi_slider.height == 31   (active, names: multi_slider:0x137f04cb0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283b5b890 multi_slider.height == 31   (active, names: multi_slider:0x137f04cb0 )>

When I scroll back & forth to its position & then slider appears

[Warning] Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a table view cell's content view. We're considering the collapse unintentional and using standard height instead. Cell: <SwiftUI.ListCoreCellHost: 0x13c214b00; baseClass = UITableViewCell; frame = (0 199.667; 374 0.666667); clipsToBounds = YES; autoresize = W; layer = <CALayer: 0x2818bd660>>

Option to disable haptics

Hey @yonat,

Awesome work here. It would be great to have the option to disable the haptic feedback. In our case, we want to set a step interval, but to something small (i.e. 1.0 in a slider with a range of 39.0 - 150.0). In this case, the haptic engine fires repeatedly, so we'd like to disable it.

All the best,

Ed

extra thumb issue

it shows extra thumbs (markers) when used in tableview cell.
I have given maximum value and value array but it some times shows extra thumbs. (markers)
Screen Shot 2019-05-15 at 10 38 51 AM

Need to set distance between to sliders to a minimum of 4 but can't

ageSlider.distanceBetweenThumbs = 4 causes my app to crash every time. I do not understand why or what to do to get a minimum distance of 4 between my two sliders. Crash report says the following:

2020-04-30 18:18:45.152808-0400 Revibe[14213:2645545] -[MultiSlider.MultiSlider setDistanceBetweenThumbs:]: unrecognized selector sent to instance 0x7fbedc95c820
2020-04-30 18:18:45.164995-0400 Revibe[14213:2645545] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MultiSlider.MultiSlider setDistanceBetweenThumbs:]: unrecognized selector sent to instance 0x7fbedc95c820'

Slider track gets aligned to top of UIView

I am facing an issue where the slider track gets aligned to the top of the UIView. Has anyone faced such issue? I am attaching the screenshots of the MultiSliders along with UIDebugger screenshot. TIA.

The UIView is vertically centered to UIImageView with horizontal spacing.

Screen Shot 2019-04-15 at 5 49 44 PM
Screen Shot 2019-04-15 at 5 50 11 PM
Screen Shot 2019-04-15 at 5 50 18 PM

This is the screenshot of UIDebugger.

Screen Shot 2019-04-15 at 5 53 17 PM

Set predefined value of thumbs

Is there a possibility to set a value of each thumb ?

With the UISlider module you can move the thumb to a predefined value with
slider.setValue(value, animated: true)

Vertical Programmatically

Description of the problem:

        let horizontalMultiSlider = MultiSlider()
        horizontalMultiSlider.orientation = .vertical
        horizontalMultiSlider.minimumValue = 10 / 4
        horizontalMultiSlider.maximumValue = 10 / 3
        horizontalMultiSlider.outerTrackColor = .gray
        horizontalMultiSlider.value = [2.718, 3.14]
        horizontalMultiSlider.valueLabelPosition = .top
        horizontalMultiSlider.tintColor = .purple
        horizontalMultiSlider.trackWidth = 32
        horizontalMultiSlider.showsThumbImageShadow = false
        view.addConstrainedSubview(horizontalMultiSlider, constrain: .topMargin, .leftMargin, .rightMargin, .bottomMargin)
        view.layoutMargins = UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32)

        horizontalMultiSlider.keepsDistanceBetweenThumbs = false
        horizontalMultiSlider.valueLabelFormatter.positiveSuffix = " 𝞵s"

bug when setting orientation to .vertical the UI show normally but can't slide

Minimal project that reproduces the problem (so I'll be able to figure out how to fix it):
I just try from the example in this repo

Carthage Support

Description:
You currently do not have support for Carthage.

Problems I encountered when trying to implement this myself:
I'm working in a project where we are trying to remove the cocoapods, and we've moved all our libs to Carthage.

We would like to use your lib without the need to use cocoapods.

horzontal slider

*** Assertion failure in -[NSLayoutConstraint _setMultiplier:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1562/Foundation/Layout.subproj/NSLayoutConstraint.m:196
2019-03-11 12:39:32.198830+0530 DCON[3784:1325822] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Multiplier is not finite! That's illegal. multiplier:inf'

Application crashed. ios 12 horizontal and vertical slider is not working any help

overlapping thumbs

i made a year slider with 2 thumbs indicating start year and current year but when app launch thumbs are overlapped i want year slider to be like price slider
Simulator Screen Shot - iPhone 11 Pro Max - 2020-07-22 at 03 37 19

Remove dependencies (esp. SweeterSwift)

Hey there, first of all thanks for your decent work here!

My request is to remove SweeterSwift and replace calls to it with native code.
When using Cocoapods SweeterSwift is available through all my project and is polluting my code completion box.
Certainly the stuff of SweeterSwift is super handy, but I don't want to use them to reduce dependencies from third party libraries.

Allow thumbs to cross over each other

This is a great library. I was wondering if it's possible to allow thumbs to cross over each other? Is this already a feature?
Allowing the left thumb go over the right thumb or allowing the right thumb go over the left thumb. Please let me know if this hasn't been implemented yet, thank you.

Change tint of selected range?

Thank you so much for making this library!

Is there currently any way you can think of to change the color for the highlighted range? Here's an example of what I mean:

image

Minimum value is ignored

Hi,
Thanks for this good library.

I set a minimum and a maximum value to a horizontal slider with two thumbs.
I then set values for thumbs to the minimum and the maximum.

self.slider.minimumValue = 45 self.slider.maximumValue = 250 self.slider.snapStepSize = 1 self.slider.value = [45, 250]

When I start moving the dot to set a value, it starts from 0 which breaks the slider UI (the thumb stays stuck on the left until I move to 45 and starts moving after).

Moreover it allows the user to select a value I wanted to be forbidden.

Did I misunderstood something in the doc or is it a bug ?

Thanks.

Adjusted value bug

Description of the problem:
Wrong upperBound when you snapStepSize is set
For example:
multiSlider.snapStepSize = 100.0
multiSlider.value = [40645.0, 81645.0]
This function - adjustValuesToStepAndLimits() define upperBound wrong.
For my case it will be transformed to [40645.0, 81600.0]
I expected to get the same values as input.
As a result when I get values after user selection I get cutting upper edge

Avoid extensions and sugar libs.

  1. Avoid extensions. I have a very big project and if every framework would add as many extensions as this, it would be a project-blow. I fixed it by moving all code of MultiSlider to one file and marking the extensions fileprivate.
  2. This is not a big lib. However it has 2 dependencies https://github.com/yonat/AvailableHapticFeedback and https://github.com/yonat/SweeterSwift. For example Alamofire - large framework has zero dependencies. This is not a good style to multiply them just for a few functions.

keepsDistanceBetweenThumbs is not working

Description of the problem:
I have a slider with two thumbs but i tried to set both properties and both of them are not taking effect, so they are still overlapping.

        timeSlider.keepsDistanceBetweenThumbs = true
        timeSlider.distanceBetweenThumbs = 50

Snap of my code :

        timeSlider = MultiSlider()
        timeSlider.frame = CGRect.init(x: 16, y: 0, width: UIScreen.main.bounds.width - 32, height: timeSliderContainer.frame.height)
        timeSlider.minimumValue = 00.00    // default is 0.0
        timeSlider.maximumValue = 23.5    // default is 1.0
        timeSlider.snapStepSize = 0.5
        timeSlider.value = [00.00, 23.5]
        timeSlider.thumbCount = 2
        timeSlider.outerTrackColor = AppConstants.Colors.General.cayan // outside of first and last thumbs
        timeSlider.orientation = .horizontal // default is .vertical
        timeSlider.tintColor = AppConstants.Colors.General.darkGray // color of track
        timeSlider.trackWidth = 6
        timeSlider.hasRoundTrackEnds = true
        timeSlider.valueLabelPosition = .top
        timeSlider?.showsThumbImageShadow = true
        timeSlider.keepsDistanceBetweenThumbs = true
        timeSlider.distanceBetweenThumbs = 50

        timeSlider.addTarget(self, action: #selector(sliderChanged(slider:)), for: .valueChanged) // continuous changes
        timeSlider.addTarget(self, action: #selector(sliderDragEnded(slider:)), for: . touchUpInside) // sent when drag ends
                
        timeSliderContainer.addSubview(timeSlider)
        
//        timeSliderContainer.addConstrainedSubview(timeSlider!, constrain: .leftMargin, .rightMargin, .bottomMargin)
//        timeSliderContainer.layoutMargins = UIEdgeInsets(top: 0, left: 32, bottom: 0, right: 32)

        timeSlider.thumbViews[0].image = UIImage(named: "min_time_icon")
        timeSlider.thumbViews[1].image = UIImage(named: "max_time_icon")
        timeSliderContainer.subviews.first?.removeFromSuperview()

Values become weird if the thumbs overlap

I used these settings:

2017-05-14 8 10 30

I slid all the thumbs to the bottom such that they can't be moved downwards anymore. Then I saw some weird values. From the value of the lowest thumb to the value of the highest thumb is the following values:

0.0, 0.999999999999986, 1.99009900990099, 2.98019801980197, 3.97029702970296

I would like the values to either be all 0s or rounded up to 0, 1, 2, 3, 4. Can you fix this?

More distance between thumbs

How would I add more minimum distance between two thumbs? I would like there to be a least 5 points between them when they are pushed together.

Thanks!!!

Build on Xcode 10.1

Hi @yonat ,

I'm getting the below error when I'm try to Run this project on Xcode 10.1. Even I have clean the derived data and also changed to deployment target to 11.0 instead of 9.0.

Module file's minimum deployment target is ios11.0 v11.0: /Users/ocsmobi2/Library/Developer/Xcode/DerivedData/MultiSliderDemo-heufnxwndnkrmbelfpkqwadwcxz/Build/Products/Debug-iphonesimulator/AvailableFeedback/AvailableHapticFeedback.swiftmodule/x86-64.swiftmodule

Thanks.

Gap at the end of sliders

Description of the problem:
[description]

I have added a UIImage to each thumb in the MultiSlider but when I drag either the left thumb to the most minimum value or the right thumb to the most maximum value, it leaves a gap. So I thought if I increase the image size then I would solve that issue, what actually happened is the gap became bigger on both sides

Minimal project that reproduces the problem (so I'll be able to figure out how to fix it):
[github repo or a zipped project]
Screen Shot 2020-05-14 at 11 30 56 AM
Screen Shot 2020-05-14 at 11 32 54 AM

Xcode 11 and Swift Packages

When adding MultiSlider as a Swift Package into the project, it doesn't compile because of missing import UIKit in extension files.

I changed that directly and it worked. So it would be awesome to have it on master branch.

AvailableHapticFeedback Library image not found

After installing the MultiSlider library by including pod 'MultiSlider' in my Podfile I receive the following error when attempting to set the class of a view to MultiSlider in my storyboard:

file:///Users/michellelane/ios-app/Spyderco/Spyderco/Settings/Storyboards/SettingsTermsAndConditions.storyboard: error: IB Designables: Failed to render and update auto layout status for UIViewController (sky-2X-3GA): dlopen(MultiSlider.framework, 1): Library not loaded: @rpath/AvailableHapticFeedback.framework/AvailableHapticFeedback
Referenced from: MultiSlider.framework
Reason: image not found

Any thoughts on why this might occur?

Build on xcode 9.4.1

I'm trying to run the example source code in xocde version 9.4.1 but I get errors like this " 'Attribute' is not a member type of 'NSLayoutConstraint' , 'Relation' is not a member type of 'NSLayoutConstraint' " in it's miniLayout class.

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.