Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sn-2950 #224

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -207,7 +206,6 @@ class PincodeFragment : SoraBaseFragment<PinCodeViewModel>() {
viewModel.onResume()
}

@OptIn(ExperimentalAnimationApi::class)
override fun NavGraphBuilder.content(
scrollState: ScrollState,
navController: NavHostController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,6 +97,7 @@ class AccountDetailsFragment : SoraBaseFragment<AccountDetailsViewModel>() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(activity as BottomBarController).hideBottomBar()
viewModel.consentExceptionHandler.observe {
consentHandlerLauncher.launch(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -125,6 +126,7 @@ class CardsHubFragment : SoraBaseFragment<CardsHubViewModel>() {
onQrClick = onQrClick,
onAssetClick = viewModel::onAssetClick,
onPoolClick = viewModel::onPoolClick,
onOpenFullCardClick = viewModel::onOpenFullCard,
onSoraCardClick = viewModel::onCardStateClicked,
onSoraCardClose = viewModel::onRemoveSoraCard,
onBuyXorClick = viewModel::onBuyCrypto,
Expand All @@ -147,6 +149,7 @@ private fun CardsMainScreen(
onQrClick: () -> Unit,
onAssetClick: (String) -> Unit,
onPoolClick: (StringPair) -> Unit,
onOpenFullCardClick: (AssetCardState) -> Unit,
onSoraCardClick: () -> Unit,
onSoraCardClose: () -> Unit,
onBuyXorClick: () -> Unit,
Expand Down Expand Up @@ -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
) {
Expand Down Expand Up @@ -256,7 +259,7 @@ private fun PreviewCardsMainScreen() {
BuyXorState, ReferralState, BackupWalletState,
),
),
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -183,9 +183,8 @@ fun CommonHubCard(
text = stringResource(id = R.string.common_expand),
size = Size.ExtraSmall,
order = Order.PRIMARY,
) {
onExpandClick?.invoke()
}
onClick = onOpenFullCardClick,
)
}
}
}
Expand All @@ -198,6 +197,7 @@ private fun PreviewCommonHubCard() {
title = R.string.common_ok,
amount = "123.123",
collapseState = false,
onOpenFullCardClick = {},
onCollapseClick = {}
) {
Text(text = "text1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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(),
Expand All @@ -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
Expand All @@ -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 }
Expand All @@ -177,7 +181,7 @@ class CardsHubViewModel @Inject constructor(
)
}
.onStart {
this.emit(
if (indexed.index == 0) this.emit(
cardHub to SoraCardState(
success = false,
kycStatus = null,
Expand Down Expand Up @@ -322,7 +326,6 @@ class CardsHubViewModel @Inject constructor(
collapsedState = collapsed,
onCollapseClick = { collapseCardToggle(CardHubType.ASSETS.hubName, !collapsed) },
loading = false,
onExpandClick = ::expandAssetsCard,
)
}

Expand All @@ -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
Expand All @@ -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() {
Expand Down