Last active
June 3, 2019 11:18
-
-
Save tilltue/e5068387d047c774a6bbe2013560e3b8 to your computer and use it in GitHub Desktop.
Currency Selected ViewModel
This file contains 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 CurrencySelectedViewModel { | |
let currencyCellViewModels = BehaviorRelay<[CurrencyCellViewModel]>(value: []) | |
func selected(cellViewModel: CurrencyCellViewModel) { | |
} | |
func cancel() { | |
} | |
} | |
//Presentation Logic | |
extension CurrencySelectedViewModel { | |
var listOfCurrencyDatasource: Observable<[AnimatableSectionModel<String,CurrencyCellViewModel>]> { | |
return self.currencyCellViewModels.map({ (viewModels) -> [AnimatableSectionModel<String,CurrencyCellViewModel>] in | |
let items = viewModels.map{ viewModel -> CurrencyCellViewModel in | |
var viewModel = viewModel | |
viewModel.isSelected = viewModel.currency == self.selected.value | |
return viewModel | |
} | |
return [AnimatableSectionModel(model: "section\(0)", items: items)] | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment