The main idea of data driven view controller is to separate view controller from any dependencies and provide only needed
data to represent any possible view controller state.
There is also a presentation slides, that contains more teoretical info about data driven view controllers. Link
Project contain 3-rd party dependencies, installed through cocoapods, so to make playgrounds work - please build DataDrivenViewControllersUI
target.
Simple Input.playground
Shows example of how to organize view with 3 buttons, where you can select profession you like. Also it provides you basic example of view output via optional closures, that also gives a context if action is available.
Input + Validation.playground
Shows example with 2 text fields and validation, without any reactive magic. Password field with length validation, and confirm password field that checks equality with password field - also reacts with color change, if error occurs.
Multi-state Screen.playground
Shows how to organize view controller that can represent multiple states - loading/error(description, reload button)/success(show data). Also, that example contains table-view, that reacts on selection, without revealing index path, or any other view implementation detail outside.
Animation.playground
Showsbreathing
ring. View decides how to continue animation, based on previous data.
The following examples has exactly the same appearance as example #3 (Multi-state Screen.playground
).
DataDrivenMVVM.playground
- how to implement DDVC inMVVM
Shows how to integrate data driven view controllers intoMVVM
DataDrivenVIPERv1.playground
- how to implement DDVC in imperativeVIPER
Shows how to integrate data driven view controllers intoVIPER
using imperative approach, so presenter has viewOutput reference.
DataDrivenVIPERv2.playground
- how to implement DDVC inVIPER
using observer pattern
Shows how to integrate data driven view controllers intoVIPER
, so presenter has only viewModel property, and view controller observes it.
DataDrivenMVC.playground
- how to implement inMVC
Shows how to integrate data driven view controllers into plain oldMVC