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

added support for UIPageControl #148

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

added support for UIPageControl #148

wants to merge 6 commits into from

Conversation

tcurdt
Copy link

@tcurdt tcurdt commented Jul 24, 2016

No description provided.

@tcurdt
Copy link
Author

tcurdt commented Jul 24, 2016

Still need to add a test. But before I do please let me know if it's otherwise OK.

extension UIPageControl {

/// Wraps a label's `numberOfPages` value in a bindable property.
public var rex_numberOfPages: MutableProperty<Int> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why label and not pageControl

@RuiAAPeres
Copy link
Member

@tcurdt Tests and it's good to go!


/// Wraps a page control's `currentPage` value in a bindable property.
public var rex_currentPage: MutableProperty<Int> {
return associatedProperty(self, key: &currentPageKey, initial: { $0.currentPage }, setter: { $0.currentPage = $1 })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use UIControl's rex_value for this purpose, that way we can keep this property up-to-date since we will process each UIControlEventValueChanged event triggered from any user interaction.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I am not objecting I am not sure I can follow the argument. What do you mean by "keep this property up-to-date"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will keep currentPage and rex_currentPage in sync. Right now we can control UIPageControl's currentPage but if the user interacts with the page control changing to a certain page manually, triggering a UIControlEventValueChanged event, our bindable property will not be updated with the new index.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tcurdt can you please change it to:

public var rex_currentPage: MutableProperty<Int> {
    return UIControl.rex_value(self, getter: { $0.currentPage }, setter: { $0.currentPage = $1 })
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@dmcrodrigues
Copy link
Contributor

👍

@dmcrodrigues
Copy link
Contributor

@tcurdt please don't forget to add this new files in each target, iOS and tvOS.

@tcurdt
Copy link
Author

tcurdt commented Jul 24, 2016

The tests are passing now.

I might not have enough insights into the rex_value discussion. Feel free to adjust as it fits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants