AppLauncher.kt 807 Bytes
Newer Older
1 2
package ru.terrakok.gitlabclient.presentation

Konstantin Tskhovrebov's avatar
Konstantin Tskhovrebov committed
3
import ru.terrakok.cicerone.Router
4
import ru.terrakok.gitlabclient.Screens
5
import ru.terrakok.gitlabclient.model.interactor.launch.LaunchInteractor
6 7 8 9 10
import javax.inject.Inject

/**
 * Created by Konstantin Tskhovrebov (aka @terrakok) on 03.09.18.
 */
11
class AppLauncher @Inject constructor(
12 13
    private val launchInteractor: LaunchInteractor,
    private val router: Router
14 15
) {

16
    fun coldStart() {
17 18
        val isSignedIn = launchInteractor.signInToSession()

19
        val rootScreen =
20
            if (isSignedIn) Screens.DrawerFlow
Konstantin Tskhovrebov's avatar
Konstantin Tskhovrebov committed
21
            else Screens.AuthFlow
22 23

        if (launchInteractor.isFirstLaunch) {
Konstantin Tskhovrebov's avatar
Konstantin Tskhovrebov committed
24
            router.newRootChain(rootScreen, Screens.PrivacyPolicy)
25 26
        } else {
            router.newRootScreen(rootScreen)
27
        }
28

29 30
    }
}