This repository is a MVVM code base for my projects. This Project is using MVVM pattern, Coordinator pattern...
Why storyboard? Because it easy :)
Using the coordinator pattern in iOS apps lets us remove the job of app navigation from our view controllers, helping make them more manageable and more reusable, while also letting us adjust our app's flow whenever we need.
Coorinator pattern make everything look simple
@IBAction func signInButtonButton(_ sender: Any) {
coordinator?.gotoSignInViewController()
}
see more here
Instead of shoving everything into your view controller, we’re going to do a Model, View, and ViewModel.
see more here
For example you need to set titleLabel style font regular with large text and color black.
@IBOutlet weak var titleLabel: UILabel! {
didSet {
titleLabel.style.largeRegular().black()
}
}
class FavoriteCheckBox: UIButton {
// Bool property
var isChecked: Bool = false {
didSet{
self.setImage( isChecked ? #imageLiteral(resourceName: "IconFavouritesActive") : #imageLiteral(resourceName: "IconFavouritesInactive"), for: UIControl.State.normal)
}
}
var isCheckedObservable: Observable<Bool> {
return self.rx.controlEvent(UIControl.Event.touchUpInside).map { _ in
self.isChecked = !self.isChecked
return self.isChecked
}
}
func bind(value: BehaviorRelay<Bool>) -> Disposable {
return isCheckedObservable.bind(to: value)
}
}
register multiple cells
tableView.register(DocumentTypeTableViewCell.string,
TextTableViewCell.string,
UploadTableViewCell.string)
dequeue cell
let cell: DocumentTypeTableViewCell = tableView.dequeueReusableCell(for: indexPath)