@@ -22,6 +22,7 @@ import androidx.compose.runtime.setValue
2222import androidx.compose.ui.Alignment
2323import androidx.compose.ui.Modifier
2424import androidx.compose.ui.graphics.graphicsLayer
25+ import androidx.compose.ui.platform.LocalDensity
2526import androidx.compose.ui.platform.testTag
2627import androidx.compose.ui.res.stringResource
2728import androidx.compose.ui.tooling.preview.Preview
@@ -42,7 +43,10 @@ import to.bitkit.ui.theme.AppThemeSurface
4243import to.bitkit.ui.theme.Colors
4344
4445private const val PAIRING_CODE_LENGTH = 6
46+ private const val PAIRING_CHAR_COLLAPSED_SCALE_X = 0.15f
47+ private const val PAIRING_CHAR_COLLAPSED_SCALE_Y = 0.85f
4548private val PAIRING_CELL_WIDTH = 32 .dp
49+ private val PAIRING_CELL_SPACING = 8 .dp
4650
4751@Composable
4852fun HwPairCodeSheet (
@@ -123,22 +127,27 @@ private fun PinInput(
123127 animationSpec = tween(durationMillis = 350 , easing = FastOutSlowInEasing ),
124128 label = " pairCodeSubmit" ,
125129 )
130+ val cellStepPx = with (LocalDensity .current) {
131+ (PAIRING_CELL_WIDTH + PAIRING_CELL_SPACING ).toPx()
132+ }
126133 Box (contentAlignment = Alignment .Center ) {
127134 // Fixed-width cells so digits replace dots without the row shifting.
128135 Row (
129- horizontalArrangement = Arrangement .spacedBy(8 .dp),
130- modifier = Modifier .graphicsLayer {
131- alpha = 1f - submitProgress
132- val cellsScale = 1f - 0.08f * submitProgress
133- scaleX = cellsScale
134- scaleY = cellsScale
135- }
136+ horizontalArrangement = Arrangement .spacedBy(PAIRING_CELL_SPACING ),
136137 ) {
137138 repeat(PAIRING_CODE_LENGTH ) { index ->
138139 val digit = code.getOrNull(index)?.toString()
140+ val centerOffset = (PAIRING_CODE_LENGTH - 1 ) / 2f - index
139141 Box (
140142 contentAlignment = Alignment .Center ,
141- modifier = Modifier .width(PAIRING_CELL_WIDTH )
143+ modifier = Modifier
144+ .width(PAIRING_CELL_WIDTH )
145+ .graphicsLayer {
146+ alpha = 1f - submitProgress
147+ translationX = centerOffset * cellStepPx * submitProgress
148+ scaleX = 1f - (1f - PAIRING_CHAR_COLLAPSED_SCALE_X ) * submitProgress
149+ scaleY = 1f - (1f - PAIRING_CHAR_COLLAPSED_SCALE_Y ) * submitProgress
150+ }
142151 ) {
143152 Display (
144153 text = digit ? : " •" ,
0 commit comments