Updated on 2026-08-14
This commit is contained in:
parent
12cebc413d
commit
27031abb7d
3 changed files with 80 additions and 63 deletions
|
|
@ -1,11 +1,9 @@
|
|||
package com.tangem.features.tangempay.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -13,7 +11,6 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
|
@ -41,6 +38,7 @@ import com.tangem.core.ui.res.generated.icons.Icons
|
|||
import com.tangem.core.ui.res.generated.icons.ic_card_plus_32
|
||||
import com.tangem.features.tangempay.details.impl.R
|
||||
import com.tangem.features.tangempay.entity.TangemPayIssueAdditionalCardUM
|
||||
import com.tangem.features.tangempay.ui.components.TangemPayInsufficientFundsNotification
|
||||
|
||||
@Composable
|
||||
internal fun TangemPayIssueAdditionalCardContent(state: TangemPayIssueAdditionalCardUM) {
|
||||
|
|
@ -77,7 +75,15 @@ private fun Content(state: TangemPayIssueAdditionalCardUM) {
|
|||
Header()
|
||||
FeeBlock(state = state)
|
||||
if (state.isBalanceInsufficient) {
|
||||
InsufficientFundsNotification(state = state)
|
||||
TangemPayInsufficientFundsNotification(
|
||||
onAddFundsClick = state.onAddFundsClick,
|
||||
modifier = Modifier.padding(
|
||||
start = 16.dp,
|
||||
end = 16.dp,
|
||||
top = 8.dp,
|
||||
bottom = 16.dp,
|
||||
),
|
||||
)
|
||||
}
|
||||
IssueButton(state = state)
|
||||
}
|
||||
|
|
@ -160,53 +166,6 @@ private fun FeeBlock(state: TangemPayIssueAdditionalCardUM, modifier: Modifier =
|
|||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InsufficientFundsNotification(state: TangemPayIssueAdditionalCardUM, modifier: Modifier = Modifier) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, end = 16.dp, top = 8.dp, bottom = 16.dp)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.background(TangemTheme.colors3.bg.status.warningSubtle)
|
||||
.padding(horizontal = 14.dp, vertical = 16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.Top,
|
||||
) {
|
||||
Image(
|
||||
modifier = Modifier.size(20.dp),
|
||||
painter = painterResource(R.drawable.img_usdc_16),
|
||||
contentDescription = null,
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.weight(1f),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
Text(
|
||||
text = stringResourceSafe(R.string.tangempay_reissue_card_insufficient_funds_title),
|
||||
style = TangemTheme.typography3.subheading.medium,
|
||||
color = TangemTheme.colors3.text.primary,
|
||||
)
|
||||
Text(
|
||||
text = stringResourceSafe(R.string.tangempay_reissue_card_insufficient_funds_subtitle),
|
||||
style = TangemTheme.typography3.caption.medium,
|
||||
color = TangemTheme.colors3.text.secondary,
|
||||
)
|
||||
}
|
||||
}
|
||||
TangemButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
variant = TangemButton.Variant.Secondary,
|
||||
size = TangemButton.Size.X8,
|
||||
onClick = state.onAddFundsClick,
|
||||
text = resourceReference(R.string.tangempay_card_details_add_funds),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun IssueButton(state: TangemPayIssueAdditionalCardUM, modifier: Modifier = Modifier) {
|
||||
TangemButton(
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import com.tangem.core.ui.res.generated.icons.ic_error_28
|
|||
import com.tangem.features.tangempay.details.impl.R
|
||||
import com.tangem.features.tangempay.entity.TangemPayReissueCardError
|
||||
import com.tangem.features.tangempay.entity.TangemPayReissueCardUM
|
||||
import com.tangem.features.tangempay.ui.components.TangemPayInsufficientFundsNotification
|
||||
|
||||
@Composable
|
||||
internal fun TangemPayReissueCardContentV2(state: TangemPayReissueCardUM) {
|
||||
|
|
@ -102,6 +103,10 @@ private fun Content(state: TangemPayReissueCardUM) {
|
|||
state = state,
|
||||
appearance = appearance,
|
||||
)
|
||||
if (state.error == TangemPayReissueCardError.InsufficientFunds) {
|
||||
SpacerH(8.dp)
|
||||
TangemPayInsufficientFundsNotification(onAddFundsClick = state.onAddFundsClick)
|
||||
}
|
||||
SpacerH(8.dp)
|
||||
BottomButtonsBlock(state = state, appearance = appearance)
|
||||
}
|
||||
|
|
@ -239,17 +244,6 @@ private fun TangemPayReissueCardUM.contentAppearance(): ReissueCardContentAppear
|
|||
val warningIconBackgroundColor = TangemTheme.colors3.bg.status.warningSubtle
|
||||
|
||||
return when (error) {
|
||||
TangemPayReissueCardError.InsufficientFunds -> ReissueCardContentAppearance(
|
||||
titleRes = R.string.tangempay_reissue_card_insufficient_funds_title,
|
||||
subtitleRes = R.string.tangempay_reissue_card_insufficient_funds_subtitle,
|
||||
icon = Icons.ic_error_28,
|
||||
iconColor = warningIconColor,
|
||||
iconBackgroundColor = warningIconBackgroundColor,
|
||||
primaryButtonTextRes = R.string.tangempay_card_details_add_funds,
|
||||
primaryAction = { it.onAddFundsClick },
|
||||
shouldShowFeeBlock = true,
|
||||
shouldShowBalanceRow = true,
|
||||
)
|
||||
TangemPayReissueCardError.InitialDataLoading -> ReissueCardContentAppearance(
|
||||
titleRes = R.string.tangempay_reissue_card_fee_unreachable_error_title,
|
||||
subtitleRes = R.string.send_fee_unreachable_error_text,
|
||||
|
|
@ -261,7 +255,7 @@ private fun TangemPayReissueCardUM.contentAppearance(): ReissueCardContentAppear
|
|||
shouldShowFeeBlock = false,
|
||||
shouldShowBalanceRow = false,
|
||||
)
|
||||
null -> ReissueCardContentAppearance(
|
||||
else -> ReissueCardContentAppearance(
|
||||
titleRes = R.string.tangempay_reissue_card_title,
|
||||
subtitleRes = R.string.tangempay_reissue_card_description,
|
||||
icon = Icons.ic_arrow_refresh_32,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package com.tangem.features.tangempay.ui.components
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.core.ui.ds2.button.TangemButton
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.features.tangempay.details.impl.R
|
||||
|
||||
@Composable
|
||||
internal fun TangemPayInsufficientFundsNotification(onAddFundsClick: () -> Unit, modifier: Modifier = Modifier) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.background(TangemTheme.colors3.bg.status.warningSubtle)
|
||||
.padding(horizontal = 14.dp, vertical = 16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.Top,
|
||||
) {
|
||||
Image(
|
||||
modifier = Modifier.size(20.dp),
|
||||
painter = painterResource(R.drawable.img_usdc_16),
|
||||
contentDescription = null,
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.weight(1f),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
Text(
|
||||
text = stringResourceSafe(R.string.tangempay_reissue_card_insufficient_funds_title),
|
||||
style = TangemTheme.typography3.subheading.medium,
|
||||
color = TangemTheme.colors3.text.primary,
|
||||
)
|
||||
Text(
|
||||
text = stringResourceSafe(R.string.tangempay_reissue_card_insufficient_funds_subtitle),
|
||||
style = TangemTheme.typography3.caption.medium,
|
||||
color = TangemTheme.colors3.text.secondary,
|
||||
)
|
||||
}
|
||||
}
|
||||
TangemButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
variant = TangemButton.Variant.Secondary,
|
||||
size = TangemButton.Size.X8,
|
||||
onClick = onAddFundsClick,
|
||||
text = resourceReference(R.string.tangempay_card_details_add_funds),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue