-
Notifications
You must be signed in to change notification settings - Fork 30
added support for UIPageControl #148
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
f286189
da9a071
9d8f662
3f948b7
ecc76a0
82c6fd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // | ||
| // UIPageControl.swift | ||
| // Rex | ||
| // | ||
| // Created by Torsten Curdt on 7/24/16. | ||
| // Copyright (c) 2015 Torsten Curdt. All rights reserved. | ||
| // | ||
|
|
||
| import ReactiveCocoa | ||
| import UIKit | ||
|
|
||
| extension UIPageControl { | ||
|
|
||
| /// Wraps a page control's `numberOfPages` value in a bindable property. | ||
| public var rex_numberOfPages: MutableProperty<Int> { | ||
| return associatedProperty(self, key: &numberOfPagesKey, initial: { $0.numberOfPages }, setter: { $0.numberOfPages = $1 }) | ||
| } | ||
|
|
||
| /// Wraps a page control's `currentPage` value in a bindable property. | ||
| public var rex_currentPage: MutableProperty<Int> { | ||
| return associatedProperty(self, key: ¤tPageKey, initial: { $0.currentPage }, setter: { $0.currentPage = $1 }) | ||
|
||
| } | ||
| } | ||
|
|
||
| private var numberOfPagesKey: UInt8 = 0 | ||
| private var currentPageKey: UInt8 = 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // | ||
| // UIPageControl.swift | ||
| // Rex | ||
| // | ||
| // Created by Torsten Curdt on 7/24/16. | ||
| // Copyright (c) 2015 Torsten Curdt. All rights reserved. | ||
| // | ||
|
|
||
| import XCTest | ||
| import ReactiveCocoa | ||
| import Result | ||
|
|
||
| class UIPageControlTests: XCTestCase { | ||
|
|
||
| weak var _pageControl: UIPageControl? | ||
|
|
||
| override func tearDown() { | ||
| XCTAssert(_pageControl == nil, "Retain cycle detected in UIPageControl properties") | ||
| super.tearDown() | ||
| } | ||
|
|
||
| func testNumberOfPages() { | ||
| let pageControl = UIPageControl(frame: CGRectZero) | ||
| _pageControl = pageControl | ||
|
|
||
| let (pipeSignal, observer) = Signal<Int, NoError>.pipe() | ||
| pageControl.rex_numberOfPages <~ SignalProducer(signal: pipeSignal) | ||
|
|
||
| observer.sendNext(1) | ||
| XCTAssertTrue(pageControl.numberOfPages == 1) | ||
| observer.sendNext(2) | ||
| XCTAssertTrue(pageControl.numberOfPages == 2) | ||
| } | ||
|
|
||
| func testNumberOfPages() { | ||
| let pageControl = UIPageControl(frame: CGRectZero) | ||
| _pageControl = pageControl | ||
|
|
||
| let (pipeSignal, observer) = Signal<Int, NoError>.pipe() | ||
| pageControl.rex_currentPage <~ SignalProducer(signal: pipeSignal) | ||
|
|
||
| observer.sendNext(1) | ||
| XCTAssertTrue(pageControl.currentPage == 1) | ||
| observer.sendNext(2) | ||
| XCTAssertTrue(pageControl.currentPage == 2) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
labeland notpageControl