-
Notifications
You must be signed in to change notification settings - Fork 2
/
AppFlow.swift
61 lines (52 loc) · 1.49 KB
/
AppFlow.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
//===----------------------------------------------------------------------===//
//
// AppFlow.swift
//
// Created by Steven Grosmark on 11/21/19.
//
//
// This source file is part of the Lasso open source project
//
// https://github.com/ww-tech/lasso
//
// Copyright © 2019-2020 WW International, Inc.
//
//===----------------------------------------------------------------------===//
import UIKit
import Lasso
///
/// AppFlow is a simple class used to direct the high-level flow of the app.
///
/// Login -> Tutorial -> Content
///
final class AppFlow {
@discardableResult
func start(in window: UIWindow) -> AppFlow {
LoginScreenModule
.createScreen()
.observeOutput { [weak self] output in
switch output {
case .userDidLogin:
self?.showTutorial()
}
}
.place(with: root(of: window))
return self
}
private func showTutorial() {
TutorialFlow()
.observeOutput { [weak self] output in
switch output {
case .didFinish, .didPressSkip:
self?.showAppContent()
}
}
.start(with: rootOfApplicationWindow(using: .push)?.withNavigationEmbedding())
}
private func showAppContent() {
ContentScreenModule
.createScreen()
.place(with: rootOfApplicationWindow(using: .push))
}
}