Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import ReactorKit
- import SkyFloatingLabelTextField
- import RxCocoa
- import RxSwift
- class ViewController: UIViewController, UITextFieldForValidation {
- internal let input = SkyFloatingLabelTextField(frame: CGRect.init(x: 50, y: 50, width: 300, height: 40))
- override func viewDidLoad() {
- super.viewDidLoad()
- input.title = "Email"
- view.addSubview(input)
- self.reactor = EmailValidationReactor()
- }
- }
- extension ViewController: View, HasDisposeBag {
- func bind(reactor: EmailValidationReactor) {
- self.bindEmailValidation(reactor: reactor)
- input.rx.text
- .map { Reactor.Action.setEmail($0) }
- .bind(to: reactor.action)
- .disposed(by: disposeBag)
- }
- }
- extension Reactive where Base: SkyFloatingLabelTextField {
- var error: Binder<ValidationResult?> {
- return Binder(self.base) { input, validation in
- switch validation {
- case .no(let error)?:
- input.errorMessage = error
- default:
- input.errorMessage = ""
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment