Updated on 2026-08-14
This commit is contained in:
parent
06b13f2227
commit
ff985dec4e
16 changed files with 246 additions and 159 deletions
|
|
@ -14,6 +14,7 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter
|
|||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButton
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -30,11 +31,7 @@ fun HorizontalActionChips(
|
|||
verticalAlignment = Alignment.CenterVertically,
|
||||
contentPadding = contentPadding,
|
||||
) {
|
||||
items(
|
||||
items = buttons,
|
||||
key = { it.text },
|
||||
itemContent = { ActionButton(config = it) },
|
||||
)
|
||||
items(items = buttons, itemContent = { ActionButton(config = it) })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,22 +58,22 @@ private fun Preview_HorizontalActionChips_Dark(
|
|||
private class ActionButtonConfigProvider : CollectionPreviewParameterProvider<ActionButtonConfig>(
|
||||
collection = persistentListOf(
|
||||
ActionButtonConfig(
|
||||
text = "Buy",
|
||||
text = TextReference.Str(value = "Buy"),
|
||||
iconResId = R.drawable.ic_plus_24,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = "Send",
|
||||
text = TextReference.Str(value = "Send"),
|
||||
iconResId = R.drawable.ic_arrow_up_24,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = "Receive",
|
||||
text = TextReference.Str(value = "Receive"),
|
||||
iconResId = R.drawable.ic_arrow_down_24,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = "Exchange",
|
||||
text = TextReference.Str(value = "Exchange"),
|
||||
iconResId = R.drawable.ic_exchange_vertical_24,
|
||||
onClick = {},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.core.ui.components.buttons.actions
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
||||
/**
|
||||
* Action button config
|
||||
|
|
@ -13,7 +14,7 @@ import androidx.annotation.DrawableRes
|
|||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
data class ActionButtonConfig(
|
||||
val text: String,
|
||||
val text: TextReference,
|
||||
@DrawableRes val iconResId: Int,
|
||||
val onClick: () -> Unit,
|
||||
val enabled: Boolean = true,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter
|
|||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.SpacerW8
|
||||
import com.tangem.core.ui.components.buttons.common.*
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
||||
/**
|
||||
|
|
@ -103,7 +105,7 @@ private fun Button(
|
|||
SpacerW8()
|
||||
|
||||
Text(
|
||||
text = config.text,
|
||||
text = config.text.resolveReference(),
|
||||
color = if (config.enabled) TangemTheme.colors.text.primary1 else TangemTheme.colors.text.disabled,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
|
|
@ -146,7 +148,17 @@ private fun Preview_ActionButton_Dark(@PreviewParameter(ActionStateProvider::cla
|
|||
|
||||
private class ActionStateProvider : CollectionPreviewParameterProvider<ActionButtonConfig>(
|
||||
collection = listOf(
|
||||
ActionButtonConfig(text = "Enabled", iconResId = R.drawable.ic_arrow_up_24, enabled = true, onClick = {}),
|
||||
ActionButtonConfig(text = "Disabled", iconResId = R.drawable.ic_arrow_down_24, enabled = false, onClick = {}),
|
||||
ActionButtonConfig(
|
||||
text = TextReference.Str(value = "Enabled"),
|
||||
iconResId = R.drawable.ic_arrow_up_24,
|
||||
enabled = true,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = TextReference.Str(value = "Disabled"),
|
||||
iconResId = R.drawable.ic_arrow_down_24,
|
||||
enabled = false,
|
||||
onClick = {},
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
@ -14,11 +14,15 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButton
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.R
|
||||
|
||||
/**
|
||||
* Placeholder for transaction's block without content
|
||||
*
|
||||
* @param state component state
|
||||
* @param modifier modifier
|
||||
*/
|
||||
@Composable
|
||||
fun EmptyTransactionBlock(state: EmptyTransactionsBlockState, modifier: Modifier = Modifier) {
|
||||
Column(
|
||||
|
|
@ -34,6 +38,7 @@ fun EmptyTransactionBlock(state: EmptyTransactionsBlockState, modifier: Modifier
|
|||
painter = painterResource(id = state.iconRes),
|
||||
contentDescription = null,
|
||||
)
|
||||
|
||||
Text(
|
||||
modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing32),
|
||||
textAlign = TextAlign.Center,
|
||||
|
|
@ -41,6 +46,7 @@ fun EmptyTransactionBlock(state: EmptyTransactionsBlockState, modifier: Modifier
|
|||
style = TangemTheme.typography.body2,
|
||||
color = TangemTheme.colors.text.secondary,
|
||||
)
|
||||
|
||||
ActionButton(config = state.actionButtonConfig)
|
||||
}
|
||||
}
|
||||
|
|
@ -67,26 +73,8 @@ private fun EmptyTransactionBlock_Dark(
|
|||
|
||||
private class EmptyTransactionBlockStateProvider : CollectionPreviewParameterProvider<EmptyTransactionsBlockState>(
|
||||
collection = listOf(
|
||||
EmptyTransactionsBlockState.Empty(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = "Buy",
|
||||
iconResId = R.drawable.ic_plus_24,
|
||||
onClick = {},
|
||||
),
|
||||
),
|
||||
EmptyTransactionsBlockState.FailedToLoad(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = "Reload",
|
||||
iconResId = R.drawable.ic_refresh_24,
|
||||
onClick = {},
|
||||
),
|
||||
),
|
||||
EmptyTransactionsBlockState.NotImplemented(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = "Explore transaction history",
|
||||
iconResId = R.drawable.ic_arrow_top_right_24,
|
||||
onClick = {},
|
||||
),
|
||||
),
|
||||
EmptyTransactionsBlockState.Empty(onClick = {}),
|
||||
EmptyTransactionsBlockState.FailedToLoad(onClick = {}),
|
||||
EmptyTransactionsBlockState.NotImplemented(onClick = {}),
|
||||
),
|
||||
)
|
||||
|
|
@ -1,37 +1,45 @@
|
|||
package com.tangem.core.ui.components.transactions.empty
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
||||
sealed class EmptyTransactionsBlockState {
|
||||
sealed class EmptyTransactionsBlockState(
|
||||
val iconRes: Int,
|
||||
val text: TextReference,
|
||||
val actionButtonConfig: ActionButtonConfig,
|
||||
) {
|
||||
|
||||
@get:DrawableRes
|
||||
abstract val iconRes: Int
|
||||
class FailedToLoad(onClick: () -> Unit) : EmptyTransactionsBlockState(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_reload),
|
||||
iconResId = R.drawable.ic_refresh_24,
|
||||
onClick = onClick,
|
||||
enabled = true,
|
||||
),
|
||||
iconRes = R.drawable.ic_alert_history_64,
|
||||
text = TextReference.Res(R.string.transaction_history_error_failed_to_load),
|
||||
)
|
||||
|
||||
abstract val text: TextReference
|
||||
class Empty(onClick: (() -> Unit)?) : EmptyTransactionsBlockState(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_buy),
|
||||
iconResId = R.drawable.ic_plus_24,
|
||||
onClick = onClick ?: {},
|
||||
enabled = onClick != null,
|
||||
),
|
||||
iconRes = R.drawable.img_coin_64,
|
||||
text = TextReference.Res(R.string.transaction_history_empty_transactions),
|
||||
)
|
||||
|
||||
abstract val actionButtonConfig: ActionButtonConfig
|
||||
|
||||
data class FailedToLoad(
|
||||
override val actionButtonConfig: ActionButtonConfig,
|
||||
) : EmptyTransactionsBlockState() {
|
||||
override val iconRes: Int = R.drawable.ic_alert_history_64
|
||||
override val text: TextReference = TextReference.Res(R.string.transaction_history_error_failed_to_load)
|
||||
}
|
||||
|
||||
data class Empty(
|
||||
override val actionButtonConfig: ActionButtonConfig,
|
||||
) : EmptyTransactionsBlockState() {
|
||||
override val iconRes: Int = R.drawable.img_coin_64
|
||||
override val text: TextReference = TextReference.Res(R.string.transaction_history_empty_transactions)
|
||||
}
|
||||
|
||||
data class NotImplemented(
|
||||
override val actionButtonConfig: ActionButtonConfig,
|
||||
) : EmptyTransactionsBlockState() {
|
||||
override val iconRes: Int = R.drawable.ic_compass_64
|
||||
override val text: TextReference = TextReference.Res(R.string.transaction_history_not_supported_description)
|
||||
}
|
||||
class NotImplemented(onClick: () -> Unit) : EmptyTransactionsBlockState(
|
||||
actionButtonConfig = ActionButtonConfig(
|
||||
text = TextReference.Res(R.string.common_explore_transaction_history),
|
||||
iconResId = R.drawable.ic_arrow_top_right_24,
|
||||
onClick = onClick,
|
||||
enabled = true,
|
||||
),
|
||||
iconRes = R.drawable.ic_compass_64,
|
||||
text = TextReference.Res(R.string.transaction_history_not_supported_description),
|
||||
)
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.feature.tokendetails.presentation.tokendetails
|
|||
import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsBalanceBlockState
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsTopAppBarConfig
|
||||
|
|
@ -42,22 +43,22 @@ internal object TokenDetailsPreviewData {
|
|||
|
||||
private val actionButtons = persistentListOf(
|
||||
ActionButtonConfig(
|
||||
text = "Buy",
|
||||
text = TextReference.Str(value = "Buy"),
|
||||
iconResId = R.drawable.ic_plus_24,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = "Send",
|
||||
text = TextReference.Str(value = "Send"),
|
||||
iconResId = R.drawable.ic_arrow_up_24,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = "Receive",
|
||||
text = TextReference.Str(value = "Receive"),
|
||||
iconResId = R.drawable.ic_arrow_down_24,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = "Exchange",
|
||||
text = TextReference.Str(value = "Exchange"),
|
||||
iconResId = R.drawable.ic_exchange_vertical_24,
|
||||
onClick = {},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.tangem.core.ui.components.PrimaryButton
|
|||
import com.tangem.core.ui.components.SecondaryButton
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
||||
import com.tangem.core.ui.components.buttons.actions.RoundedActionButton
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.common.WalletPreviewData
|
||||
|
|
@ -208,7 +209,7 @@ private fun TopBar(
|
|||
) {
|
||||
RoundedActionButton(
|
||||
config = ActionButtonConfig(
|
||||
text = stringResource(id = R.string.organize_tokens_sort_by_balance),
|
||||
text = TextReference.Res(id = R.string.organize_tokens_sort_by_balance),
|
||||
iconResId = R.drawable.ic_sort_24,
|
||||
onClick = config.onSortByBalanceClick,
|
||||
),
|
||||
|
|
@ -217,7 +218,7 @@ private fun TopBar(
|
|||
)
|
||||
RoundedActionButton(
|
||||
config = ActionButtonConfig(
|
||||
text = stringResource(id = R.string.organize_tokens_group),
|
||||
text = TextReference.Res(id = R.string.organize_tokens_group),
|
||||
iconResId = R.drawable.ic_group_24,
|
||||
onClick = config.onGroupByNetworkClick,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -90,6 +90,10 @@ internal class DefaultWalletRouter(private val navigationStateHolder: Navigation
|
|||
navigationStateHolder.navigate(action = NavigationAction.NavigateTo(AppScreen.OnboardingWallet))
|
||||
}
|
||||
|
||||
override fun openTxHistoryWebsite(url: String) {
|
||||
navigationStateHolder.navigate(action = NavigationAction.OpenUrl(url))
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val BACKSTACK_ENTRY_COUNT_TO_CLOSE_WALLET_SCREEN = 2
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,4 +37,7 @@ internal interface InnerWalletRouter : WalletRouter {
|
|||
|
||||
/** Open onboarding screen */
|
||||
fun openOnboardingScreen()
|
||||
|
||||
/** Open transaction history website by [url] */
|
||||
fun openTxHistoryWebsite(url: String)
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state
|
||||
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
|
||||
/**
|
||||
|
|
@ -19,7 +20,7 @@ sealed class WalletManageButton(val config: ActionButtonConfig) {
|
|||
*/
|
||||
data class Buy(val onClick: () -> Unit) : WalletManageButton(
|
||||
config = ActionButtonConfig(
|
||||
text = "Buy",
|
||||
text = TextReference.Res(id = R.string.common_buy),
|
||||
iconResId = R.drawable.ic_plus_24,
|
||||
onClick = onClick,
|
||||
),
|
||||
|
|
@ -32,7 +33,7 @@ sealed class WalletManageButton(val config: ActionButtonConfig) {
|
|||
*/
|
||||
data class Send(val onClick: () -> Unit) : WalletManageButton(
|
||||
config = ActionButtonConfig(
|
||||
text = "Send",
|
||||
text = TextReference.Res(id = R.string.common_send),
|
||||
iconResId = R.drawable.ic_arrow_up_24,
|
||||
onClick = onClick,
|
||||
),
|
||||
|
|
@ -45,7 +46,7 @@ sealed class WalletManageButton(val config: ActionButtonConfig) {
|
|||
*/
|
||||
data class Receive(val onClick: () -> Unit) : WalletManageButton(
|
||||
config = ActionButtonConfig(
|
||||
text = "Receive",
|
||||
text = TextReference.Res(id = R.string.common_receive),
|
||||
iconResId = R.drawable.ic_arrow_down_24,
|
||||
onClick = onClick,
|
||||
),
|
||||
|
|
@ -58,7 +59,7 @@ sealed class WalletManageButton(val config: ActionButtonConfig) {
|
|||
*/
|
||||
data class Exchange(val onClick: () -> Unit) : WalletManageButton(
|
||||
config = ActionButtonConfig(
|
||||
text = "Exchange",
|
||||
text = TextReference.Res(id = R.string.common_exchange),
|
||||
iconResId = R.drawable.ic_exchange_vertical_24,
|
||||
onClick = onClick,
|
||||
),
|
||||
|
|
@ -71,7 +72,7 @@ sealed class WalletManageButton(val config: ActionButtonConfig) {
|
|||
*/
|
||||
data class CopyAddress(val onClick: () -> Unit) : WalletManageButton(
|
||||
config = ActionButtonConfig(
|
||||
text = "Copy address",
|
||||
text = TextReference.Res(id = R.string.common_copy_address),
|
||||
iconResId = R.drawable.ic_copy_24,
|
||||
onClick = onClick,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -17,14 +17,32 @@ internal sealed interface WalletTxHistoryState {
|
|||
*
|
||||
* @property items content items
|
||||
*/
|
||||
sealed class ContentItemsState(open val items: Flow<PagingData<TxHistoryItemState>>) : WalletTxHistoryState
|
||||
sealed class ContentState(open val items: Flow<PagingData<TxHistoryItemState>>) : WalletTxHistoryState
|
||||
|
||||
/**
|
||||
* Content state
|
||||
*
|
||||
* @property items content items
|
||||
*/
|
||||
data class Content(override val items: Flow<PagingData<TxHistoryItemState>>) : ContentItemsState(items)
|
||||
data class Content(override val items: Flow<PagingData<TxHistoryItemState>>) : ContentState(items)
|
||||
|
||||
/**
|
||||
* Locked state
|
||||
*
|
||||
* @property onExploreClick lambda be invoke when explore button was clicked
|
||||
*/
|
||||
data class Locked(val onExploreClick: () -> Unit) :
|
||||
ContentState(
|
||||
items = flowOf(
|
||||
PagingData.from(
|
||||
listOf(
|
||||
TxHistoryItemState.Title(onExploreClick = onExploreClick),
|
||||
TxHistoryItemState.Transaction(state = TransactionState.Loading),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
WalletLockedContentState
|
||||
|
||||
/**
|
||||
* Empty state
|
||||
|
|
@ -47,24 +65,6 @@ internal sealed interface WalletTxHistoryState {
|
|||
*/
|
||||
data class Error(val onReloadClick: () -> Unit) : WalletTxHistoryState
|
||||
|
||||
/**
|
||||
* Locked state
|
||||
*
|
||||
* @property onExploreClick lambda be invoke when explore button was clicked
|
||||
*/
|
||||
data class Locked(val onExploreClick: () -> Unit) :
|
||||
ContentItemsState(
|
||||
items = flowOf(
|
||||
PagingData.from(
|
||||
listOf(
|
||||
TxHistoryItemState.Title(onExploreClick = onExploreClick),
|
||||
TxHistoryItemState.Transaction(state = TransactionState.Loading),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
WalletLockedContentState
|
||||
|
||||
/** Transactions history item state */
|
||||
sealed interface TxHistoryItemState {
|
||||
|
||||
|
|
|
|||
|
|
@ -19,22 +19,19 @@ import androidx.compose.ui.tooling.preview.PreviewParameter
|
|||
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
||||
import androidx.paging.compose.LazyPagingItems
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import androidx.paging.compose.itemsIndexed
|
||||
import com.tangem.core.ui.components.buttons.HorizontalActionChips
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlock
|
||||
import com.tangem.core.ui.components.notifications.Notification
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.presentation.common.WalletPreviewData
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.content.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.content.WalletTxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.WalletBottomSheet
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.WalletTopBar
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.WalletsList
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency.MultiCurrencyContentItem
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency.OrganizeTokensButton
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.SingleCurrencyContentItem
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletContentItemDecoration
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency.tokensListItems
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.txHistoryItems
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.utils.ScrollOffsetCollector
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.utils.changeWalletAnimator
|
||||
|
||||
|
|
@ -69,7 +66,7 @@ internal fun WalletScreen(state: WalletStateHolder) {
|
|||
.pullRefresh(pullRefreshState),
|
||||
) {
|
||||
val txHistoryItems = if (state is WalletStateHolder.SingleCurrencyContent) {
|
||||
if (state.txHistoryState is WalletTxHistoryState.ContentItemsState) {
|
||||
if (state.txHistoryState is WalletTxHistoryState.ContentState) {
|
||||
state.txHistoryState.items.collectAsLazyPagingItems()
|
||||
} else {
|
||||
null
|
||||
|
|
@ -177,52 +174,6 @@ private fun LazyListScope.contentItems(
|
|||
}
|
||||
}
|
||||
|
||||
private fun LazyListScope.tokensListItems(state: WalletTokensListState, modifier: Modifier = Modifier) {
|
||||
itemsIndexed(
|
||||
items = state.items,
|
||||
key = { index, _ -> index },
|
||||
itemContent = { index, item ->
|
||||
MultiCurrencyContentItem(
|
||||
state = item,
|
||||
modifier = modifier.walletContentItemDecoration(
|
||||
currentIndex = index,
|
||||
lastIndex = state.items.lastIndex,
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
private fun LazyListScope.txHistoryItems(
|
||||
state: WalletTxHistoryState,
|
||||
txHistoryItems: LazyPagingItems<WalletTxHistoryState.TxHistoryItemState>?,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
when (state) {
|
||||
is WalletTxHistoryState.ContentItemsState -> {
|
||||
checkNotNull(txHistoryItems)
|
||||
itemsIndexed(
|
||||
items = txHistoryItems,
|
||||
key = { index, _ -> index },
|
||||
itemContent = { index, item ->
|
||||
if (item == null) return@itemsIndexed
|
||||
|
||||
SingleCurrencyContentItem(
|
||||
state = item,
|
||||
modifier = modifier.walletContentItemDecoration(
|
||||
currentIndex = index,
|
||||
lastIndex = txHistoryItems.itemCount,
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
is WalletTxHistoryState.Empty -> TODO("[REDACTED_JIRA]")
|
||||
is WalletTxHistoryState.Error -> TODO("[REDACTED_JIRA]")
|
||||
is WalletTxHistoryState.NotSupported -> TODO("[REDACTED_JIRA]")
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
private fun PullToRefreshIndicator(isRefreshing: Boolean, state: PullRefreshState, modifier: Modifier = Modifier) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrency
|
||||
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.content.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletContentItemDecoration
|
||||
|
||||
/**
|
||||
* LazyList extension for [WalletTokensListState]
|
||||
*
|
||||
* @param state state
|
||||
* @param modifier modifier
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal fun LazyListScope.tokensListItems(state: WalletTokensListState, modifier: Modifier = Modifier) {
|
||||
itemsIndexed(
|
||||
items = state.items,
|
||||
key = { index, _ -> index },
|
||||
itemContent = { index, item ->
|
||||
MultiCurrencyContentItem(
|
||||
state = item,
|
||||
modifier = modifier.walletContentItemDecoration(
|
||||
currentIndex = index,
|
||||
lastIndex = state.items.lastIndex,
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.multicurrenc
|
|||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig
|
||||
import com.tangem.core.ui.components.buttons.actions.RoundedActionButton
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
|
||||
/**
|
||||
|
|
@ -19,7 +19,7 @@ import com.tangem.feature.wallet.impl.R
|
|||
internal fun OrganizeTokensButton(onClick: (() -> Unit)?, modifier: Modifier = Modifier) {
|
||||
RoundedActionButton(
|
||||
config = ActionButtonConfig(
|
||||
text = stringResource(id = R.string.organize_tokens_title),
|
||||
text = TextReference.Res(id = R.string.organize_tokens_title),
|
||||
iconResId = R.drawable.ic_filter_24,
|
||||
onClick = onClick ?: {},
|
||||
enabled = onClick != null,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.paging.compose.LazyPagingItems
|
||||
import androidx.paging.compose.itemsIndexed
|
||||
import com.tangem.core.ui.components.transactions.empty.EmptyTransactionBlock
|
||||
import com.tangem.core.ui.components.transactions.empty.EmptyTransactionsBlockState
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.content.WalletTxHistoryState
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletContentItemDecoration
|
||||
|
||||
/**
|
||||
* LazyList extension for transactions history [WalletTxHistoryState]
|
||||
*
|
||||
* @param state state
|
||||
* @param txHistoryItems transactions
|
||||
* @param modifier modifier
|
||||
*/
|
||||
internal fun LazyListScope.txHistoryItems(
|
||||
state: WalletTxHistoryState,
|
||||
txHistoryItems: LazyPagingItems<WalletTxHistoryState.TxHistoryItemState>?,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
when (state) {
|
||||
is WalletTxHistoryState.ContentState -> {
|
||||
contentItems(
|
||||
txHistoryItems = requireNotNull(txHistoryItems),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
is WalletTxHistoryState.Empty -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.Empty(onClick = state.onBuyClick),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
is WalletTxHistoryState.Error -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.FailedToLoad(onClick = state.onReloadClick),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
is WalletTxHistoryState.NotSupported -> {
|
||||
nonContentItem(
|
||||
state = EmptyTransactionsBlockState.NotImplemented(onClick = state.onExploreClick),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun LazyListScope.contentItems(
|
||||
txHistoryItems: LazyPagingItems<WalletTxHistoryState.TxHistoryItemState>,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
itemsIndexed(
|
||||
items = txHistoryItems,
|
||||
key = { index, _ -> index },
|
||||
itemContent = { index, item ->
|
||||
if (item == null) return@itemsIndexed
|
||||
|
||||
SingleCurrencyContentItem(
|
||||
state = item,
|
||||
modifier = modifier.walletContentItemDecoration(
|
||||
currentIndex = index,
|
||||
lastIndex = txHistoryItems.itemSnapshotList.lastIndex,
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
private fun LazyListScope.nonContentItem(state: EmptyTransactionsBlockState, modifier: Modifier = Modifier) {
|
||||
item {
|
||||
EmptyTransactionBlock(
|
||||
state = state,
|
||||
modifier = modifier
|
||||
.padding(horizontal = TangemTheme.dimens.spacing16, vertical = TangemTheme.dimens.spacing12)
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.*
|
||||
import androidx.paging.cachedIn
|
||||
import com.tangem.blockchain.common.DerivationStyle
|
||||
import com.tangem.common.Provider
|
||||
import com.tangem.common.doOnFailure
|
||||
|
|
@ -125,22 +126,24 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
private fun updateByTxHistory(index: Int) {
|
||||
viewModelScope.launch(dispatchers.io) {
|
||||
val wallet = getWallet(index)
|
||||
val blockchain = wallet.scanResponse.cardTypesResolver.getBlockchain()
|
||||
uiState = stateFactory.getLoadingTxHistoryState(
|
||||
itemsCountEither = txHistoryItemsCountUseCase(
|
||||
networkId = blockchain.id,
|
||||
derivationPath = requireNotNull(blockchain.derivationPath(style = DerivationStyle.LEGACY)).rawPath,
|
||||
),
|
||||
val blockchain = getWallet(index).scanResponse.cardTypesResolver.getBlockchain()
|
||||
|
||||
val txHistoryItemsCountEither = txHistoryItemsCountUseCase(
|
||||
networkId = blockchain.id,
|
||||
derivationPath = requireNotNull(blockchain.derivationPath(style = DerivationStyle.LEGACY)).rawPath,
|
||||
)
|
||||
|
||||
updateTxHistory(networkId = blockchain.id)
|
||||
uiState = stateFactory.getLoadingTxHistoryState(itemsCountEither = txHistoryItemsCountEither)
|
||||
|
||||
txHistoryItemsCountEither.onRight { updateTxHistory(networkId = blockchain.id) }
|
||||
updateNotifications(index)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTxHistory(networkId: String) {
|
||||
uiState = stateFactory.getLoadedTxHistoryState(txHistoryEither = txHistoryItemsUseCase(networkId))
|
||||
uiState = stateFactory.getLoadedTxHistoryState(
|
||||
txHistoryEither = txHistoryItemsUseCase(networkId = networkId).map { it.cachedIn(viewModelScope) },
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateNotifications(index: Int, tokenList: TokenList? = null) {
|
||||
|
|
@ -255,10 +258,11 @@ internal class WalletViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onReloadClick() {
|
||||
// TODO: [REDACTED_JIRA]
|
||||
uiState = stateFactory.getStateAfterContentRefreshing()
|
||||
updateByTxHistory(index = uiState.walletsListConfig.selectedWalletIndex)
|
||||
}
|
||||
|
||||
override fun onExploreClick() {
|
||||
// TODO: [REDACTED_JIRA]
|
||||
router.openTxHistoryWebsite(url = "") // TODO
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue