diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactionInfo/TransactionInfoFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactionInfo/TransactionInfoFragment.kt index 6a3681f41d..7e2b85b0c3 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactionInfo/TransactionInfoFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactionInfo/TransactionInfoFragment.kt @@ -1,5 +1,6 @@ package io.horizontalsystems.bankwallet.modules.transactionInfo +import android.widget.Toast import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -13,6 +14,7 @@ import androidx.compose.ui.unit.dp import androidx.navigation.NavController import androidx.navigation.navGraphViewModels import io.horizontalsystems.bankwallet.R +import io.horizontalsystems.bankwallet.core.App import io.horizontalsystems.bankwallet.core.BaseComposeFragment import io.horizontalsystems.bankwallet.core.slideFromRight import io.horizontalsystems.bankwallet.core.stats.StatEntity @@ -48,11 +50,16 @@ import io.horizontalsystems.bankwallet.ui.compose.components.WarningMessageCell class TransactionInfoFragment : BaseComposeFragment() { - private val viewModelTxs by navGraphViewModels(R.id.mainFragment) { TransactionsModule.Factory() } - @Composable override fun GetContent(navController: NavController) { - val viewItem = viewModelTxs.tmpItemToShow + val viewModelTxs: TransactionsViewModel? = try { + navGraphViewModels(R.id.mainFragment) { TransactionsModule.Factory() }.value + } catch (e: IllegalStateException) { + Toast.makeText(App.instance, "ViewModel is Null", Toast.LENGTH_SHORT).show() + null + } + + val viewItem = viewModelTxs?.tmpItemToShow if (viewItem == null) { navController.popBackStack(R.id.transactionInfoFragment, true) return diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/FilterBlockchainFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/FilterBlockchainFragment.kt index 00ed7cea60..903f6de65a 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/FilterBlockchainFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/FilterBlockchainFragment.kt @@ -1,5 +1,6 @@ package io.horizontalsystems.bankwallet.modules.transactions +import android.widget.Toast import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column @@ -26,6 +27,7 @@ import androidx.navigation.NavController import androidx.navigation.navGraphViewModels import coil.compose.rememberAsyncImagePainter import io.horizontalsystems.bankwallet.R +import io.horizontalsystems.bankwallet.core.App import io.horizontalsystems.bankwallet.core.BaseComposeFragment import io.horizontalsystems.bankwallet.core.imageUrl import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme @@ -37,10 +39,20 @@ import io.horizontalsystems.marketkit.models.Blockchain class FilterBlockchainFragment : BaseComposeFragment() { - private val viewModel by navGraphViewModels(R.id.mainFragment) - @Composable override fun GetContent(navController: NavController) { + val viewModel: TransactionsViewModel? = try { + navGraphViewModels(R.id.mainFragment) { TransactionsModule.Factory() }.value + } catch (e: IllegalStateException) { + Toast.makeText(App.instance, "ViewModel is Null", Toast.LENGTH_SHORT).show() + null + } + + if (viewModel == null) { + navController.popBackStack(R.id.filterBlockchainFragment, true) + return + } + FilterBlockchainScreen(navController, viewModel) } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/FilterCoinFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/FilterCoinFragment.kt index 3763c6b2c1..e070744691 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/FilterCoinFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/FilterCoinFragment.kt @@ -1,5 +1,6 @@ package io.horizontalsystems.bankwallet.modules.transactions +import android.widget.Toast import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column @@ -27,6 +28,7 @@ import androidx.navigation.NavController import androidx.navigation.navGraphViewModels import coil.compose.rememberAsyncImagePainter import io.horizontalsystems.bankwallet.R +import io.horizontalsystems.bankwallet.core.App import io.horizontalsystems.bankwallet.core.BaseComposeFragment import io.horizontalsystems.bankwallet.core.badge import io.horizontalsystems.bankwallet.core.iconPlaceholder @@ -41,10 +43,20 @@ import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton class FilterCoinFragment : BaseComposeFragment() { - private val viewModel by navGraphViewModels(R.id.mainFragment) - @Composable override fun GetContent(navController: NavController) { + val viewModel: TransactionsViewModel? = try { + navGraphViewModels(R.id.mainFragment) { TransactionsModule.Factory() }.value + } catch (e: IllegalStateException) { + Toast.makeText(App.instance, "ViewModel is Null", Toast.LENGTH_SHORT).show() + null + } + + if (viewModel == null) { + navController.popBackStack(R.id.filterCoinFragment, true) + return + } + FilterCoinScreen(navController, viewModel) } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/TransactionsFilterFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/TransactionsFilterFragment.kt index 1ce334bf54..8fc6cd128a 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/TransactionsFilterFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/TransactionsFilterFragment.kt @@ -1,5 +1,6 @@ package io.horizontalsystems.bankwallet.modules.transactions +import android.widget.Toast import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -25,6 +26,7 @@ import androidx.compose.ui.unit.dp import androidx.navigation.NavController import androidx.navigation.navGraphViewModels import io.horizontalsystems.bankwallet.R +import io.horizontalsystems.bankwallet.core.App import io.horizontalsystems.bankwallet.core.BaseComposeFragment import io.horizontalsystems.bankwallet.core.badge import io.horizontalsystems.bankwallet.core.slideFromRight @@ -44,10 +46,20 @@ import io.horizontalsystems.bankwallet.ui.compose.components.body_leah class TransactionsFilterFragment : BaseComposeFragment() { - private val viewModel by navGraphViewModels(R.id.mainFragment) - @Composable override fun GetContent(navController: NavController) { + val viewModel: TransactionsViewModel? = try { + navGraphViewModels(R.id.mainFragment) { TransactionsModule.Factory() }.value + } catch (e: IllegalStateException) { + Toast.makeText(App.instance, "ViewModel is Null", Toast.LENGTH_SHORT).show() + null + } + + if (viewModel == null) { + navController.popBackStack(R.id.filterCoinFragment, true) + return + } + FilterScreen( navController, viewModel