2021-10-09 07:36:58 -07:00
|
|
|
package cash.z.ecc.ui
|
2021-09-14 14:02:06 -07:00
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import androidx.activity.ComponentActivity
|
|
|
|
import androidx.activity.compose.setContent
|
2021-10-09 07:37:03 -07:00
|
|
|
import androidx.activity.viewModels
|
2021-11-12 04:09:30 -08:00
|
|
|
import androidx.compose.runtime.collectAsState
|
|
|
|
import cash.z.ecc.ui.screen.home.view.Home
|
|
|
|
import cash.z.ecc.ui.screen.home.viewmodel.WalletViewModel
|
2021-10-09 07:37:03 -07:00
|
|
|
import cash.z.ecc.ui.screen.onboarding.view.Onboarding
|
|
|
|
import cash.z.ecc.ui.screen.onboarding.viewmodel.OnboardingViewModel
|
2021-10-31 10:36:51 -07:00
|
|
|
import cash.z.ecc.ui.theme.ZcashTheme
|
2021-09-14 14:02:06 -07:00
|
|
|
|
|
|
|
class MainActivity : ComponentActivity() {
|
2021-10-09 07:37:03 -07:00
|
|
|
|
2021-11-12 04:09:30 -08:00
|
|
|
private val walletViewModel by viewModels<WalletViewModel>()
|
|
|
|
|
2021-10-09 07:37:03 -07:00
|
|
|
private val onboardingViewModel by viewModels<OnboardingViewModel>()
|
|
|
|
|
2021-09-14 14:02:06 -07:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContent {
|
2021-10-31 10:36:51 -07:00
|
|
|
ZcashTheme {
|
2021-11-12 04:09:30 -08:00
|
|
|
if (null == walletViewModel.persistableWallet.collectAsState(null).value) {
|
|
|
|
// Optimized path to get to onboarding as quickly as possible
|
|
|
|
Onboarding(
|
|
|
|
onboardingState = onboardingViewModel.onboardingState,
|
|
|
|
onImportWallet = { TODO("Implement wallet import") },
|
|
|
|
onCreateWallet = { TODO("Implement wallet create") }
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
if (null == walletViewModel.synchronizer.collectAsState(null).value) {
|
|
|
|
// Continue displaying splash screen
|
|
|
|
} else {
|
|
|
|
Home()
|
|
|
|
}
|
|
|
|
}
|
2021-09-14 14:02:06 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|