Skip to content

Commit f3974d4

Browse files
committed
fix(ui): honor the v2 amount gap, cross-fade the accessory token
The gap above the v2 amount was never rendering. heightIn(max=) only lifts the max constraint, and a bare Spacer has no intrinsic size, so it measured to the minimum and collapsed — grid.x4 and grid.x8 produced an identical 32dp, all of it AmountArea's own row. height() fixes both bounds while still coercing into the incoming constraints, so the spacer contributes its 40dp and continues to give way on a short screen. The token chip in the accessory row also cross-fades now, with a size transform to carry the width change between currency names, so returning from the picker reads as the control changing rather than a hard cut.
1 parent 38d2a07 commit f3974d4

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

apps/flipcash/core-ui/src/main/kotlin/com/flipcash/app/core/ui/AmountWithKeypad.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.Column
66
import androidx.compose.foundation.layout.Spacer
77
import androidx.compose.foundation.layout.fillMaxSize
88
import androidx.compose.foundation.layout.fillMaxWidth
9-
import androidx.compose.foundation.layout.heightIn
9+
import androidx.compose.foundation.layout.height
1010
import androidx.compose.foundation.layout.padding
1111
import androidx.compose.runtime.Composable
1212
import androidx.compose.runtime.getValue
@@ -129,13 +129,15 @@ fun LargeAmountField(
129129

130130
Column(modifier = modifier.fillMaxSize()) {
131131
// The gap below the app bar, so the amount isn't jammed against the chrome — AmountArea's
132-
// own row contributes 8dp on top of this. Capped rather than fixed: the grid keys off
133-
// screen *width*, so a hard padding would survive intact on a short screen and squeeze the
134-
// amount instead. Letting it give way keeps the 74sp digits legible on small devices.
132+
// own row contributes 8dp on top of this. height() rather than heightIn(max=): the latter
133+
// only lifts the max constraint, and a bare Spacer has no intrinsic size, so it measures to
134+
// the minimum and collapses to nothing. height() fixes both bounds, and still coerces into
135+
// the incoming constraints — so on a screen too short to grant the weighted share it gives
136+
// way rather than squeezing the 74sp digits.
135137
Spacer(
136138
modifier = Modifier
137139
.weight(1f, fill = false)
138-
.heightIn(max = CodeTheme.dimens.grid.x8)
140+
.height(CodeTheme.dimens.grid.x8)
139141
)
140142
AmountArea(
141143
modifier = Modifier

apps/flipcash/features/tokens/src/main/kotlin/com/flipcash/app/tokens/internal/TokenSelectorRow.kt

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package com.flipcash.app.tokens.internal
22

3+
import androidx.compose.animation.AnimatedContent
4+
import androidx.compose.animation.SizeTransform
5+
import androidx.compose.animation.core.tween
6+
import androidx.compose.animation.fadeIn
7+
import androidx.compose.animation.fadeOut
8+
import androidx.compose.animation.togetherWith
39
import androidx.compose.foundation.clickable
410
import androidx.compose.foundation.layout.Arrangement
511
import androidx.compose.foundation.layout.Row
@@ -52,13 +58,28 @@ private fun TokenSelectorRow(
5258
horizontalArrangement = Arrangement.spacedBy(CodeTheme.dimens.grid.x2),
5359
verticalAlignment = Alignment.CenterVertically,
5460
) {
55-
TokenIconWithName(
56-
token = selected.token,
57-
imageSize = CodeTheme.dimens.staticGrid.x6,
58-
textStyle = CodeTheme.typography.textMedium,
59-
spacing = CodeTheme.dimens.grid.x2,
60-
displayName = { selected.displayName },
61-
)
61+
// Cross-fade the chip when the picker returns a different currency, so the swap reads
62+
// as the same control changing rather than a hard cut. Keyed on the mint, not the whole
63+
// TokenWithBalance — a balance tick would otherwise re-run the transition. The size
64+
// transform carries the width change, since currency names differ in length.
65+
AnimatedContent(
66+
targetState = selected,
67+
contentKey = { it.token.address },
68+
transitionSpec = {
69+
fadeIn(tween(durationMillis = 180, delayMillis = 60))
70+
.togetherWith(fadeOut(tween(durationMillis = 120)))
71+
.using(SizeTransform(clip = false) { _, _ -> tween(durationMillis = 220) })
72+
},
73+
label = "selectedToken",
74+
) { token ->
75+
TokenIconWithName(
76+
token = token.token,
77+
imageSize = CodeTheme.dimens.staticGrid.x6,
78+
textStyle = CodeTheme.typography.textMedium,
79+
spacing = CodeTheme.dimens.grid.x2,
80+
displayName = { token.displayName },
81+
)
82+
}
6283

6384
Icon(
6485
modifier = Modifier.size(CodeTheme.dimens.staticGrid.x4),

0 commit comments

Comments
 (0)