diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/buttons/HorizontalActionChips.kt b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/HorizontalActionChips.kt new file mode 100644 index 0000000000..1646791082 --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/components/buttons/HorizontalActionChips.kt @@ -0,0 +1,88 @@ +package com.tangem.core.ui.components.buttons + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.items +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewParameter +import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider +import androidx.compose.ui.unit.dp +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.res.TangemTheme +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.persistentListOf + +@Composable +fun HorizontalActionChips( + buttons: ImmutableList, + modifier: Modifier = Modifier, + contentPadding: PaddingValues = PaddingValues(0.dp), +) { + LazyRow( + modifier = modifier + .background(color = TangemTheme.colors.background.secondary) + .fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing8), + verticalAlignment = Alignment.CenterVertically, + contentPadding = contentPadding, + ) { + items( + items = buttons, + key = { it.text }, + itemContent = { ActionButton(config = it) }, + ) + } +} + +@Preview +@Composable +private fun Preview_HorizontalActionChips_Light( + @PreviewParameter(ActionButtonConfigProvider::class) buttons: ImmutableList, +) { + TangemTheme(isDark = false) { + HorizontalActionChips(buttons = buttons) + } +} + +@Preview +@Composable +private fun Preview_HorizontalActionChips_Dark( + @PreviewParameter(ActionButtonConfigProvider::class) buttons: ImmutableList, +) { + TangemTheme(isDark = true) { + HorizontalActionChips(buttons = buttons) + } +} + +private class ActionButtonConfigProvider : CollectionPreviewParameterProvider( + collection = persistentListOf( + ActionButtonConfig( + text = "Buy", + iconResId = R.drawable.ic_plus_24, + onClick = {}, + ), + ActionButtonConfig( + text = "Send", + iconResId = R.drawable.ic_arrow_up_24, + onClick = {}, + ), + ActionButtonConfig( + text = "Receive", + iconResId = R.drawable.ic_arrow_down_24, + onClick = {}, + ), + ActionButtonConfig( + text = "Exchange", + iconResId = R.drawable.ic_exchange_vertical_24, + onClick = {}, + ), + ), +) \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt index dab4813f30..f535f5d114 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt @@ -200,7 +200,7 @@ internal object WalletPreviewData { ), ) - val manageButtons = persistentListOf( + private val manageButtons = persistentListOf( WalletManageButton.Buy(onClick = {}), WalletManageButton.Send(onClick = {}), WalletManageButton.Receive(onClick = {}), @@ -294,7 +294,7 @@ internal object WalletPreviewData { ), ), notifications = persistentListOf(WalletNotification.LikeTangemApp(onClick = {})), - buttons = manageButtons, + buttons = manageButtons.map(WalletManageButton::config).toPersistentList(), marketPriceBlockState = MarketPriceBlockState.Content( currencyName = "BTC", price = "98900.12$", diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletStateHolder.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletStateHolder.kt index b9b216a198..12fb96d14e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletStateHolder.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletStateHolder.kt @@ -1,5 +1,6 @@ package com.tangem.feature.wallet.presentation.wallet.state +import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.core.ui.components.marketprice.MarketPriceBlockState import kotlinx.collections.immutable.ImmutableList @@ -58,7 +59,7 @@ internal sealed class WalletStateHolder( override val walletsListConfig: WalletsListConfig, override val contentItems: ImmutableList, override val notifications: ImmutableList, - val buttons: ImmutableList, + val buttons: ImmutableList, val marketPriceBlockState: MarketPriceBlockState, ) : WalletStateHolder(onBackClick, topBarConfig, walletsListConfig, contentItems, notifications) } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt index b89486d90e..e281fb492e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt @@ -18,6 +18,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.components.buttons.actions.ActionButtonConfig import com.tangem.core.ui.components.buttons.actions.RoundedActionButton +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.components.transactions.Transaction @@ -33,7 +34,6 @@ 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.singlecurrency.TransactionsBlockGroupTitle import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.TransactionsBlockTitle -import com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency.WalletManageButtons import com.tangem.feature.wallet.presentation.wallet.ui.decorations.walletContentItemDecoration import com.tangem.feature.wallet.presentation.wallet.ui.utils.changeWalletAnimator @@ -73,9 +73,11 @@ internal fun WalletScreen(state: WalletStateHolder) { if (state is WalletStateHolder.SingleCurrencyContent) { item { - WalletManageButtons( + HorizontalActionChips( buttons = state.buttons, - modifier = changeableItemModifier.padding(top = TangemTheme.dimens.spacing14), + modifier = changeableItemModifier + .padding(top = TangemTheme.dimens.spacing14), + contentPadding = PaddingValues(horizontal = TangemTheme.dimens.spacing16), ) } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletManageButtons.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletManageButtons.kt deleted file mode 100644 index 19b1a57045..0000000000 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/WalletManageButtons.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.foundation.lazy.items -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -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.res.TangemTheme -import com.tangem.feature.wallet.presentation.common.WalletPreviewData -import com.tangem.feature.wallet.presentation.wallet.state.WalletManageButton -import kotlinx.collections.immutable.ImmutableList - -/** - * Wallet manage buttons - * - * @param buttons manage buttons - * @param modifier modifier - * -[REDACTED_AUTHOR] - */ -@Composable -internal fun WalletManageButtons(buttons: ImmutableList, modifier: Modifier = Modifier) { - LazyRow( - modifier = modifier - .background(color = TangemTheme.colors.background.secondary) - .fillMaxWidth(), - contentPadding = PaddingValues(horizontal = TangemTheme.dimens.spacing16), - horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing8), - verticalAlignment = Alignment.CenterVertically, - ) { - items( - items = buttons, - key = { it.config.text }, - itemContent = { ActionButton(config = it.config) }, - ) - } -} - -@Preview -@Composable -private fun Preview_WalletManageButtons_Light( - @PreviewParameter(WalletManageButtonProvider::class) buttons: ImmutableList, -) { - TangemTheme(isDark = false) { - WalletManageButtons(buttons = buttons) - } -} - -@Preview -@Composable -private fun Preview_WalletManageButtons_Dark( - @PreviewParameter(WalletManageButtonProvider::class) buttons: ImmutableList, -) { - TangemTheme(isDark = true) { - WalletManageButtons(buttons = buttons) - } -} - -private class WalletManageButtonProvider : CollectionPreviewParameterProvider>( - collection = listOf(WalletPreviewData.manageButtons), -) \ No newline at end of file