Skip to content

Instantly share code, notes, and snippets.

View charlag's full-sized avatar

Willow charlag

View GitHub Profile
enum AuthCellType: String {
case Headline
case EmailTextField
case NameTextField
case PasswordTextField
case LoginButton
case Separator
}
extension AuthCellType: IdentifiableType {
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
tableView.estimatedRowHeight = 44
enum LoginScreenState {
case ShowLogIn
case ShowSignUp
var cells: [AuthCellType] {
switch self {
case .ShowLogIn:
return [
.Headline,
.Separator,
let screenState = Variable(LoginScreenState.ShowLogIn)
let footerButton = UIButton()
footerButton.rx_tap
.asObservable()
.withLatestFrom(screenState.asObservable())
.map { state -> LoginScreenState in
switch state {
case .ShowLogIn:
return .ShowSignUp
case .ShowSignUp:
return .ShowLogIn
}
screenState.asObservable()
.map { $0.cells }
.map { [AuthSection(model: 0, items: $0)] }
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
.addDisposableTo(disposeBag)
dataSource.animationConfiguration = AnimationConfiguration(insertAnimation: .Fade,
reloadAnimation: .Fade,
deleteAnimation: .Fade)
enum LoginScreenState {
case ShowLogIn
case ShowSignUp
var buttonTitle: String {
switch self {
case .ShowLogIn:
return "Don't have an account?"
case .ShowSignUp:
return "Already have an account?"
@charlag
charlag / di.swift
Last active October 1, 2016 15:26
Dependency injection prototyping
protocol CatalogViewModelFactory {
func create(parameters: String) -> CatalogViewModel
}
struct CatalogViewModelFactoryImpl: CatalogViewModelFactory {
func create(parameters: String) -> CatalogViewModel {
return CatalogViewModelImpl(something: parameters,
productFactory: ProductViewModelFactoryImpl()) // should be resolved for this factory

Keybase proof

I hereby claim:

  • I am charlag on github.
  • I am charlag (https://keybase.io/charlag) on keybase.
  • I have a public key ASDCJQpk-E_YkHH9ltpAb2RTm9TKgTdwWl33Ohjb2VwNcQo

To claim this, I am signing this object: