Coordinate your app

52d6b8fd288036707ddd50eb6f595cb7?s=47 Aydar
February 27, 2018

Coordinate your app

Introduction to Coordinator's approach for resolving navigation in iOS applications.
Presented on internal tech talks at Freeletics.

52d6b8fd288036707ddd50eb6f595cb7?s=128

Aydar

February 27, 2018
Tweet

Transcript

  1. 2.

    • Intro to iOS navigation • Problems • Classic solution

    • Solution with Coordinators • Demo Agenda
  2. 3.

    • Intro to iOS navigation • Problems • Classic solution

    • Solution with Coordinators • Demo
  3. 7.

    • Intro to iOS navigation • Problems • Classic solution

    • Solution with Coordinators • Demo
  4. 9.

    E new D E new new D C Problems A

    B C visible Push next A B visible +1 +n
  5. 10.

    D E C E D Problems A B C visible

    Go back A B visible -1 -n
  6. 12.

    • Intro to iOS navigation • Problems • Classic solution

    • Solution with Coordinators • Demo
  7. 17.

    D Classic solution ... func showNext() { let vc: UIViewController

    if isOneFlow { vc = E() } else { vc = P() } push(vc) } ... Chained navigation
  8. 23.

    • Intro to iOS navigation • Problems • Classic solution

    • Solution with Coordinators • Demo
  9. 26.

    Solution with Coordinators E D A B C Coordinator 1.

    done 2. init push 3. done 4. init push
  10. 27.

    Solution with Coordinators E D A B C Coordinator 1.

    done 2. init push 3. done 4. init push
  11. 28.

    Solution with Coordinators B Coordinator private let onDone: () ->

    () ... func donePressed() { onDone() } ... private func configuredA() -> A { let a = A(onDone: { self.navigationController? .push(configuredB()) }) return a } private func configuredB() -> B { let b = B(onDone: { self.navigationController? .push(configuredC()) }) return b } …
  12. 32.

    Solution with Coordinators Coordinator Child coordinator private func startChildCoordinator() {

    let coord = ChildCoordinator(onFinish: { self.navigationController?.dismiss() }) navigationController?.present(coord.start()) } init(onFinish: @escaping () -> ()) { self.onFinish = onFinish } ... private func configuredI() -> I { let i = I(onDone: { self.onFinish() }) return i }
  13. 36.

    Solution with Coordinators +1 +n E D A B C

    Coord A onDone() push(e) visible -1
  14. 38.
  15. 42.

    Solution with Coordinators Coordinator private func startChildCoordinator() { let topVC

    = navigationController!.topViewController let coord = ChildCoordinator(onFinish: { self.navigationController?.pop(to: topVC) }) navigationController?.push(coord.start()) } -n
  16. 44.

    Solution with Coordinators +1 +n -1 -n Chained navigation Coordinators

    OK, but dependencies OK, but dependencies OK NOT OK OK OK OK OK
  17. 45.

    • Intro to iOS navigation • Problems • Classic solution

    • Solution with Coordinators • Demo