@@ -2,36 +2,29 @@ package com.flipcash.app.tokens.ui
22
33import androidx.compose.foundation.Image
44import androidx.compose.foundation.layout.Arrangement
5- import androidx.compose.foundation.layout.Box
65import androidx.compose.foundation.layout.Column
7- import androidx.compose.foundation.layout.defaultMinSize
6+ import androidx.compose.foundation.layout.Row
87import androidx.compose.foundation.layout.fillMaxWidth
98import androidx.compose.foundation.layout.padding
10- import androidx.compose.foundation.text.InlineTextContent
11- import androidx.compose.foundation.text.appendInlineContent
9+ import androidx.compose.foundation.layout.size
10+ import androidx.compose.foundation.text.TextAutoSize
1211import androidx.compose.material.icons.Icons
1312import androidx.compose.material.icons.automirrored.filled.ArrowForward
1413import androidx.compose.material3.Icon
1514import androidx.compose.material3.Surface
1615import androidx.compose.material3.Text
1716import androidx.compose.runtime.Composable
18- import androidx.compose.runtime.getValue
19- import androidx.compose.runtime.mutableStateOf
20- import androidx.compose.runtime.remember
21- import androidx.compose.runtime.setValue
2217import androidx.compose.ui.Alignment
2318import androidx.compose.ui.Modifier
24- import androidx.compose.ui.layout.onSizeChanged
25- import androidx.compose.ui.platform.LocalDensity
19+ import androidx.compose.ui.layout.ContentScale
2620import androidx.compose.ui.res.painterResource
2721import androidx.compose.ui.res.stringResource
28- import androidx.compose.ui.text.Placeholder
29- import androidx.compose.ui.text.PlaceholderVerticalAlign
30- import androidx.compose.ui.text.buildAnnotatedString
3122import androidx.compose.ui.tooling.preview.Preview
3223import androidx.compose.ui.tooling.preview.PreviewWrapper
3324import androidx.compose.ui.unit.dp
25+ import androidx.compose.ui.unit.sp
3426import com.flipcash.app.theme.FlipcashThemeWrapper
27+ import com.flipcash.app.theme.MultiDevicePreview
3528import com.flipcash.shared.tokens.R
3629import com.getcode.theme.CodeTheme
3730
@@ -49,53 +42,49 @@ fun CurrencyCreatorUpsellCard(
4942 shadowElevation = 0 .dp,
5043 onClick = onClick
5144 ) {
52- Box (modifier = Modifier .fillMaxWidth()) {
53- val density = LocalDensity .current
54- var imageHeight by remember { mutableStateOf(0 .dp) }
45+ Row (
46+ modifier = Modifier .fillMaxWidth(),
47+ verticalAlignment = Alignment .Bottom
48+ ) {
49+ val screenWidth = CodeTheme .dimens.screenWidth
50+ val imageWidthFraction = when {
51+ screenWidth < 360 .dp -> 0.28f
52+ screenWidth < 420 .dp -> 0.33f
53+ else -> 0.38f
54+ }
5555
5656 Column (
5757 modifier = Modifier
58- .fillMaxWidth()
59- .defaultMinSize(minHeight = imageHeight)
58+ .weight(1f )
6059 .padding(
6160 start = CodeTheme .dimens.grid.x3,
6261 top = CodeTheme .dimens.grid.x3,
6362 bottom = CodeTheme .dimens.grid.x3,
64- ),
63+ )
64+ .align(Alignment .CenterVertically ),
6565 verticalArrangement = Arrangement .spacedBy(CodeTheme .dimens.grid.x1),
6666 ) {
67- val arrowId = " arrow"
68- val arrowSize = with (LocalDensity .current) {
69- CodeTheme .dimens.staticGrid.x4.toSp()
70- }
71- val titleText = buildAnnotatedString {
72- append(stringResource(R .string.action_createYourOwnCurrency))
73- append(" " )
74- appendInlineContent(arrowId)
75- }
76- Text (
77- text = titleText,
78- style = CodeTheme .typography.screenTitle,
79- color = CodeTheme .colors.textMain,
80- inlineContent = mapOf (
81- arrowId to InlineTextContent (
82- Placeholder (
83- width = arrowSize,
84- height = arrowSize,
85- placeholderVerticalAlign = PlaceholderVerticalAlign .Center
86- )
87- ) {
88- Icon (
89- imageVector = Icons .AutoMirrored .Default .ArrowForward ,
90- contentDescription = null ,
91- tint = CodeTheme .colors.textMain,
92- )
93- }
67+ Row (
68+ verticalAlignment = Alignment .CenterVertically ,
69+ horizontalArrangement = Arrangement .spacedBy(CodeTheme .dimens.grid.x1)
70+ ) {
71+ Text (
72+ modifier = Modifier .weight(1f , fill = false ),
73+ text = stringResource(R .string.action_createYourOwnCurrency),
74+ style = CodeTheme .typography.screenTitle,
75+ color = CodeTheme .colors.textMain,
76+ maxLines = 1 ,
77+ autoSize = TextAutoSize .StepBased (minFontSize = 11 .sp),
9478 )
95- )
79+ Icon (
80+ modifier = Modifier .size(CodeTheme .dimens.staticGrid.x4),
81+ imageVector = Icons .AutoMirrored .Default .ArrowForward ,
82+ contentDescription = null ,
83+ tint = CodeTheme .colors.textMain,
84+ )
85+ }
9686
9787 Text (
98- modifier = Modifier .fillMaxWidth(0.65f ),
9988 text = stringResource(R .string.subtitle_createYourOwnCurrency),
10089 style = CodeTheme .typography.textSmall,
10190 color = CodeTheme .colors.textSecondary,
@@ -104,20 +93,18 @@ fun CurrencyCreatorUpsellCard(
10493
10594 Image (
10695 modifier = Modifier
107- .align(Alignment .BottomEnd )
108- .onSizeChanged { size ->
109- imageHeight = with (density) { size.height.toDp() }
110- },
96+ .fillMaxWidth(imageWidthFraction),
11197 painter = painterResource(R .drawable.ic_bill_previews),
11298 contentDescription = null ,
99+ contentScale = ContentScale .FillWidth ,
113100 )
114101 }
115102 }
116103}
117104
118- @Preview
105+ @MultiDevicePreview
119106@PreviewWrapper(FlipcashThemeWrapper ::class )
120107@Composable
121108private fun Preview_CurrencyCreatorUpsellCard () {
122- CurrencyCreatorUpsellCard () { }
109+ CurrencyCreatorUpsellCard { }
123110}
0 commit comments