diff --git a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/CardState.kt b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/CardState.kt index 810cd3a84..fa901333a 100644 --- a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/CardState.kt +++ b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/CardState.kt @@ -68,7 +68,6 @@ data class TitledAmountCardState( val state: AssetCardState, val collapsedState: Boolean = false, val onCollapseClick: () -> Unit, - val onExpandClick: (() -> Unit)? = null, override val loading: Boolean, ) : CardState(loading) diff --git a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/pincode/PincodeFragment.kt b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/pincode/PincodeFragment.kt index 7e689156b..21f621e87 100644 --- a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/pincode/PincodeFragment.kt +++ b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/pincode/PincodeFragment.kt @@ -39,7 +39,6 @@ import android.widget.TextView import android.widget.Toast import androidx.biometric.BiometricManager import androidx.biometric.BiometricPrompt -import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.foundation.ScrollState import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalLayoutDirection @@ -207,7 +206,6 @@ class PincodeFragment : SoraBaseFragment() { viewModel.onResume() } - @OptIn(ExperimentalAnimationApi::class) override fun NavGraphBuilder.content( scrollState: ScrollState, navController: NavHostController diff --git a/feature_multiaccount_impl/src/main/java/jp/co/soramitsu/feature_multiaccount_impl/presentation/export_account/account_details/AccountDetailsFragment.kt b/feature_multiaccount_impl/src/main/java/jp/co/soramitsu/feature_multiaccount_impl/presentation/export_account/account_details/AccountDetailsFragment.kt index e2e4fefb7..5e286d8f3 100644 --- a/feature_multiaccount_impl/src/main/java/jp/co/soramitsu/feature_multiaccount_impl/presentation/export_account/account_details/AccountDetailsFragment.kt +++ b/feature_multiaccount_impl/src/main/java/jp/co/soramitsu/feature_multiaccount_impl/presentation/export_account/account_details/AccountDetailsFragment.kt @@ -56,6 +56,7 @@ import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject import jp.co.soramitsu.common.R import jp.co.soramitsu.common.base.SoraBaseFragment +import jp.co.soramitsu.common.domain.BottomBarController import jp.co.soramitsu.common.domain.ResponseCode import jp.co.soramitsu.common.domain.SoraException import jp.co.soramitsu.common.presentation.args.address @@ -96,6 +97,7 @@ class AccountDetailsFragment : SoraBaseFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + (activity as BottomBarController).hideBottomBar() viewModel.consentExceptionHandler.observe { consentHandlerLauncher.launch(it) } diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubFragment.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubFragment.kt index 23f429afa..ea451a3c3 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubFragment.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubFragment.kt @@ -66,6 +66,7 @@ import jp.co.soramitsu.common.base.theOnlyRoute import jp.co.soramitsu.common.domain.BottomBarController import jp.co.soramitsu.common.util.StringPair import jp.co.soramitsu.common_wallet.presentation.compose.components.PoolsList +import jp.co.soramitsu.common_wallet.presentation.compose.states.AssetCardState import jp.co.soramitsu.common_wallet.presentation.compose.states.BackupWalletState import jp.co.soramitsu.common_wallet.presentation.compose.states.BasicBannerCardState import jp.co.soramitsu.common_wallet.presentation.compose.states.BuyXorState @@ -125,6 +126,7 @@ class CardsHubFragment : SoraBaseFragment() { onQrClick = onQrClick, onAssetClick = viewModel::onAssetClick, onPoolClick = viewModel::onPoolClick, + onOpenFullCardClick = viewModel::onOpenFullCard, onSoraCardClick = viewModel::onCardStateClicked, onSoraCardClose = viewModel::onRemoveSoraCard, onBuyXorClick = viewModel::onBuyCrypto, @@ -147,6 +149,7 @@ private fun CardsMainScreen( onQrClick: () -> Unit, onAssetClick: (String) -> Unit, onPoolClick: (StringPair) -> Unit, + onOpenFullCardClick: (AssetCardState) -> Unit, onSoraCardClick: () -> Unit, onSoraCardClose: () -> Unit, onBuyXorClick: () -> Unit, @@ -180,7 +183,7 @@ private fun CardsMainScreen( CommonHubCard( title = cardState.title, amount = cardState.amount, - onExpandClick = cardState.onExpandClick, + onOpenFullCardClick = { onOpenFullCardClick.invoke(cardState.state) }, collapseState = cardState.collapsedState, onCollapseClick = cardState.onCollapseClick ) { @@ -256,7 +259,7 @@ private fun PreviewCardsMainScreen() { BuyXorState, ReferralState, BackupWalletState, ), ), - {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} + {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ) } } diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubScreen.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubScreen.kt index d71218754..f44faf556 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubScreen.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubScreen.kt @@ -126,13 +126,13 @@ fun CommonHubCard( @StringRes title: Int, amount: String, collapseState: Boolean, - onExpandClick: (() -> Unit)? = null, + onOpenFullCardClick: () -> Unit, onCollapseClick: () -> Unit, content: @Composable (ColumnScope) -> Unit ) { ContentCard( modifier = Modifier.padding(top = Dimens.x1_5), - onClick = onExpandClick + onClick = onOpenFullCardClick ) { Column( modifier = Modifier @@ -183,9 +183,8 @@ fun CommonHubCard( text = stringResource(id = R.string.common_expand), size = Size.ExtraSmall, order = Order.PRIMARY, - ) { - onExpandClick?.invoke() - } + onClick = onOpenFullCardClick, + ) } } } @@ -198,6 +197,7 @@ private fun PreviewCommonHubCard() { title = R.string.common_ok, amount = "123.123", collapseState = false, + onOpenFullCardClick = {}, onCollapseClick = {} ) { Text(text = "text1") diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt index cd6079ca0..67a7c9df6 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt @@ -52,6 +52,7 @@ import jp.co.soramitsu.common.util.StringPair import jp.co.soramitsu.common.util.ext.safeCast import jp.co.soramitsu.common_wallet.domain.model.CommonUserPoolData import jp.co.soramitsu.common_wallet.domain.model.fiatSymbol +import jp.co.soramitsu.common_wallet.presentation.compose.states.AssetCardState import jp.co.soramitsu.common_wallet.presentation.compose.states.BackupWalletState import jp.co.soramitsu.common_wallet.presentation.compose.states.BuyXorState import jp.co.soramitsu.common_wallet.presentation.compose.states.CardState @@ -91,6 +92,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onStart +import kotlinx.coroutines.flow.withIndex import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -137,7 +139,9 @@ class CardsHubViewModel @Inject constructor( .subscribeVisibleCardsHubList() .catch { onError(it) } .distinctUntilChanged() - .flatMapLatest { data -> + .withIndex() + .flatMapLatest { indexed -> + val data = indexed.value _state.value = _state.value.copy( accountAddress = data.first.substrateAddress, curAccount = data.first.accountTitle(), @@ -148,7 +152,7 @@ class CardsHubViewModel @Inject constructor( CardHubType.ASSETS -> { assetsInteractor.subscribeAssetsFavoriteOfAccount(data.first) .onStart { - this.emit(emptyList()) + if (indexed.index == 0) this.emit(emptyList()) } .map { cardHub to it @@ -158,7 +162,7 @@ class CardsHubViewModel @Inject constructor( CardHubType.POOLS -> { poolsInteractor.subscribePoolsCacheOfAccount(data.first) .onStart { - this.emit(emptyList()) + if (indexed.index == 0) this.emit(emptyList()) } .map { list -> cardHub to list.filter { it.user.favorite } @@ -177,7 +181,7 @@ class CardsHubViewModel @Inject constructor( ) } .onStart { - this.emit( + if (indexed.index == 0) this.emit( cardHub to SoraCardState( success = false, kycStatus = null, @@ -322,7 +326,6 @@ class CardsHubViewModel @Inject constructor( collapsedState = collapsed, onCollapseClick = { collapseCardToggle(CardHubType.ASSETS.hubName, !collapsed) }, loading = false, - onExpandClick = ::expandAssetsCard, ) } @@ -334,7 +337,6 @@ class CardsHubViewModel @Inject constructor( state = FavoritePoolsCardState( state = data.first ), - onExpandClick = ::expandPoolsCard, loading = false, onCollapseClick = { collapseCardToggle(CardHubType.POOLS.hubName, !collapsed) }, collapsedState = collapsed @@ -350,12 +352,15 @@ class CardsHubViewModel @Inject constructor( } } - private fun expandAssetsCard() { - router.showAssetSettings() - } - - private fun expandPoolsCard() { - polkaswapRouter.showPoolSettings() + fun onOpenFullCard(state: AssetCardState) { + when (state) { + is FavoriteAssetsCardState -> { + router.showAssetSettings() + } + is FavoritePoolsCardState -> { + polkaswapRouter.showPoolSettings() + } + } } fun onCardStateClicked() {