Skip to content

vmalakhovskiy/data-driven-vc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Data Driven ViewController examples

This repository contains examples of data driven view controllers.

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

Important note:

Project contain 3-rd party dependencies, installed through cocoapods, so to make playgrounds work - please build DataDrivenViewControllersUI target.

  1. 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.

Simple Input.playground

  1. 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.

Input + Validation.playground

  1. 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.

Multi-state Screen.playground

  1. Animation.playground
    Shows breathing ring. View decides how to continue animation, based on previous data.

Animation.playground

The following examples has exactly the same appearance as example #3 (Multi-state Screen.playground).

  1. DataDrivenMVVM.playground - how to implement DDVC in MVVM
    Shows how to integrate data driven view controllers into MVVM

  1. DataDrivenVIPERv1.playground - how to implement DDVC in imperative VIPER
    Shows how to integrate data driven view controllers into VIPER using imperative approach, so presenter has viewOutput reference.

  1. DataDrivenVIPERv2.playground - how to implement DDVC in VIPER using observer pattern
    Shows how to integrate data driven view controllers into VIPER, so presenter has only viewModel property, and view controller observes it.

  1. DataDrivenMVC.playground - how to implement in MVC
    Shows how to integrate data driven view controllers into plain old MVC

About

Swift Data-Driven UI examples

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published