This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func configureKeyboardListeners() { | |
| NotificationCenter.default.addObserver(forName: Notification.Name.UIKeyboardWillShow, object: nil, queue: nil) { notification in | |
| let keyboardFrame = notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! CGRect | |
| let keyboardHeight: CGFloat = keyboardFrame.height | |
| self.scrollView.contentInset.bottom = keyboardHeight | |
| self.scrollView.scrollIndicatorInsets.bottom = keyboardHeight | |
| } | |
| NotificationCenter.default.addObserver(forName: Notification.Name.UIKeyboardWillHide, object: nil, queue: nil) { notification in | |
| self.scrollView.contentInset.bottom = 0 | |
| self.scrollView.scrollIndicatorInsets.bottom = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func bindKeyboardEvents() -> Disposable { | |
| let observable = | |
| Observable.from([ | |
| NotificationCenter.default.rx.notification(Notification.Name.UIKeyboardWillShow) .map { notification in | |
| let keyboardFrame = notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! CGRect | |
| let keyboardHeight: CGFloat = keyboardFrame.height | |
| return keyboardHeight | |
| }, | |
| NotificationCenter.default.rx.notification(Notification.Name.UIKeyboardWillHide) .map { _ in CGFloat(0) }]) | |
| .merge() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func viewDidLoad() { | |
| super.viewDidLoad() | |
| scrollView.bindKeyboardEvents().disposed(by: disposeBag) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension UIScrollView { | |
| func loadNextPageObservable() -> Observable<Void> { | |
| return rx.contentOffset | |
| .skipWhile { | |
| $0.y < self.frame.size.height | |
| }.map { contentOffset -> Bool in | |
| let padding = CGFloat(20.0) | |
| return contentOffset.y + self.frame.size.height + padding > self.contentSize.height | |
| }.distinctUntilChanged().map { shouldLoad in | |
| if shouldLoad { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scrollView.loadNextPageObservable().subscribe(onNext: { | |
| //Code that calls network service to perform specific request | |
| }).disposed(by: disposeBag) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func configureDateTextField() { | |
| let datePickerView:UIDatePicker = UIDatePicker() | |
| datePickerView.datePickerMode = UIDatePickerMode.Date | |
| dateTextField.inputView = datePickerView | |
| datePickerView.addTarget(self, action: #selector(ViewController.datePickerValueChanged), forControlEvents: UIControlEvents.ValueChanged) | |
| } | |
| func datePickerValueChanged(sender: UIDatePicker) { | |
| let dateFormatter = NSDateFormatter() | |
| dateFormatter.dateStyle = medium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DateTextField: UITextField { | |
| var selectedDate: Date? | |
| private let disposeBag = DisposeBag() | |
| override func awakeFromNib() { | |
| super.awakeFromNib() | |
| let datePicker = UIDatePicker() | |
| inputView = datePicker | |
| datePicker.rx.value.asObservable().subscribe(onNext: { date in | |
| self.selectedDate = date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| view.rx | |
| .anyGesture(.tap(), .swipe([.up, .down])) | |
| .when(.recognized) | |
| .subscribe(onNext: { _ in | |
| //dismiss presented photo | |
| }) | |
| .disposed(by: disposeBag) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CustomExtensions.swift | |
| // Pods-AARxSwiftExtensions | |
| // | |
| // Created by Arlind on 8/12/18. | |
| // | |
| import UIKit | |
| import RxSwift | |
| import CoreLocation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typealias Memento = NSDictionary | |
| protocol MementoConvertible { | |
| var memento: Memento { get } | |
| init?(memento: Memento) | |
| } | |
| struct FormState { | |
| private enum Keys { | |
| static let name = "mainForm.name" |