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
| import UIKit | |
| extension UIStoryboardSegue { | |
| // MARK: View Controller Helpers | |
| func prepare<T: UIViewController>(forId id: String, viewControllerBlock: (T) -> Void) { | |
| guard self.identifier == id, let viewController = destination as? T else { return } | |
| viewControllerBlock(viewController) | |
| } | |
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
| import Foundation | |
| struct SayTag { | |
| static let indefiniteLoop = 0 | |
| enum Voice: String { | |
| case man, woman, alice | |
| } | |
| let message: String |
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
| import Moya | |
| import RxCocoa | |
| import RxSwift | |
| import UIKit | |
| func bindSwitchToTeamFetch(_ aSwitch: UISwitch) { | |
| let teamsRequest = observeAllTeams() | |
| aSwitch | |
| .rx | |
| .isOn // an Observable mirror of UISwitch.isOn |
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 APIError { | |
| var message: String { | |
| switch reasonCode { | |
| case 300: | |
| return "error_code_send_failed".localized(in: .swipeKit) | |
| case 301: | |
| return "error_code_validate_failed".localized(in: .swipeKit) | |
| default: | |
| return "error_generic".localized(in: .swipeKit) | |
| } |
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
| // | |
| // UIViewController+Additions.h | |
| // SFSCategoryKit | |
| // | |
| // Created by Dalton Claybrook on 4/6/15. | |
| // Copyright (c) 2015 Dalton Claybrook. All rights reserved. | |
| // | |
| #import <UIKit/UIKit.h> |
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 UIImage { | |
| func scaleFactorFor(maxSize: CGSize) -> CGFloat { | |
| let imageSize = self.size | |
| guard imageSize.width > maxSize.width || imageSize.height > maxSize.height else { | |
| // image is already smaller than max | |
| return 1.0 | |
| } | |
| let widthScaleFactor = maxSize.width / imageSize.width | |
| let heightScaleFactor = maxSize.height / imageSize.height |
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 ViewController: UIViewController { | |
| @IBAction func refreshButtonPressed(_ sender: Any) { | |
| self.fetchUsers() | |
| } | |
| func fetchUsers() { | |
| self.loadingView.show(in: self.view) | |
| self.apiProvider | |
| .request(.users) | |
| .asObservable() |
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
| struct ViewModel { | |
| // MARK: Public | |
| var users: Observable<[User]> { | |
| return self.usersVariable.asObservable() | |
| } | |
| var isLoading: Observable<Bool> { | |
| return self.isLoadingVariable.asObservable() | |
| } | |
| var error: Observable<Error> { |
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
| private func bindUsers(with viewModel: ViewModel) { | |
| viewModel.users | |
| .bind(to: self.tableView.rx.items(cellIdentifier: UserCellReuseID, cellType: UserCell.self)) { _, user, cell in | |
| cell.configure(with: user) | |
| } | |
| .disposed(by: self.disposeBag) | |
| } | |
| private func bindRefreshButton(with viewModel: ViewModel) { | |
| let tapObservable = self.refreshButton |