Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Reselecting item #50

Open
xxtesaxx opened this issue May 27, 2017 · 0 comments
Open

Feature Request: Reselecting item #50

xxtesaxx opened this issue May 27, 2017 · 0 comments

Comments

@xxtesaxx
Copy link

I use Segmentio together with a UICollectionView. I use the UIScrollViewDelegate to calculate if I want to "snap" to a given cell. I then pass the value to Segmentios selectedItemIndex to let it handle all my UI updating like setting the navigation bar title.

If the "new value" is the same as the selected value though, valueDidChange does not get fired because obviously the value did not change. I instead call segmentio.valueDidChange?(segmentio, segmentio.selectedSegmentioIndex) which seems a little bit unnecessary to me.

How about a SegmentioSelectionCallback for "valueSelected" as well?

How should it look like?

    open var valueSelected: SegmentioSelectionCallback?
    open var selectedSegmentioIndex = -1 {
        didSet {
            if selectedSegmentioIndex != oldValue {
                reloadSegmentio()
                valueDidChange?(self, selectedSegmentioIndex)
            }
            valueSelected?(self, selectedSegmentioIndex)
        }
    }

...

segmentio.valueSelected = { segmentio, index in ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants