Skip to content

Commit 44c9327

Browse files
committed
style(flipcash/balance): crossfade balance changes
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent fbb5d8a commit 44c9327

3 files changed

Lines changed: 32 additions & 23 deletions

File tree

  • apps/flipcash
  • ui/components/src/main/kotlin/com/getcode/ui/components/text

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fun AmountWithKeypad(
5757
uiModel = amountAnimatedModel,
5858
isAnimated = true,
5959
isClickable = isClickable,
60-
onClick = { onAmountClicked?.invoke() },
60+
onClick = { onAmountClicked.invoke() },
6161
networkState = networkState,
6262
textStyle = CodeTheme.typography.displayLarge,
6363
)

apps/flipcash/features/balance/src/main/kotlin/com/flipcash/app/balance/internal/components/BalanceHeader.kt

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package com.flipcash.app.balance.internal.components
22

3+
import androidx.compose.animation.AnimatedContent
4+
import androidx.compose.animation.Crossfade
5+
import androidx.compose.animation.core.tween
6+
import androidx.compose.animation.fadeIn
7+
import androidx.compose.animation.fadeOut
8+
import androidx.compose.animation.slideInVertically
9+
import androidx.compose.animation.slideOutVertically
10+
import androidx.compose.animation.togetherWith
311
import androidx.compose.foundation.layout.Box
412
import androidx.compose.foundation.layout.Column
513
import androidx.compose.foundation.layout.fillMaxWidth
@@ -33,25 +41,28 @@ internal fun BalanceHeader(
3341
CodeCircularProgressIndicator()
3442
}
3543
} else {
36-
val isUsd = balance.converted.currencyCode.takeIf {
37-
it == CurrencyCode.USD
38-
} != null
39-
AmountArea(
40-
amountText = balance.converted.formatted(
41-
suffix = balance.converted.currencyCode.takeIf {
42-
it != CurrencyCode.USD
43-
}?.let {
44-
stringResource(R.string.subtitle_ofUsdSuffix)
45-
}
46-
),
47-
isAltCaption = false,
48-
isAltCaptionKinIcon = false,
49-
captionText = stringResource(R.string.subtitle_balanceIsHeldInUsd).takeIf { !isUsd },
50-
currencyResId = exchange.getFlagByCurrency(balance.converted.currencyCode.name),
51-
isClickable = true,
52-
textStyle = CodeTheme.typography.displayLarge,
53-
onClick = onClick
54-
)
44+
Crossfade(balance.converted) { amount ->
45+
val isUsd = amount.currencyCode.takeIf {
46+
it == CurrencyCode.USD
47+
} != null
48+
49+
AmountArea(
50+
amountText = amount.formatted(
51+
suffix = amount.currencyCode.takeIf {
52+
it != CurrencyCode.USD
53+
}?.let {
54+
stringResource(R.string.subtitle_ofUsdSuffix)
55+
}
56+
),
57+
isAltCaption = false,
58+
isAltCaptionKinIcon = false,
59+
captionText = stringResource(R.string.subtitle_balanceIsHeldInUsd).takeIf { !isUsd },
60+
currencyResId = exchange.getFlagByCurrency(amount.currencyCode.name),
61+
isClickable = true,
62+
textStyle = CodeTheme.typography.displayLarge,
63+
onClick = onClick
64+
)
65+
}
5566
}
5667
}
5768
}

ui/components/src/main/kotlin/com/getcode/ui/components/text/AmountArea.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ fun AmountPreview() {
138138
amountSuffix = "suffix",
139139
captionText = "The value of kin fluctuates",
140140
currencyResId = R.drawable.ic_flag_ca,
141-
isAnimated = false,
142-
networkState = networkStateValues.last()
141+
networkState = networkStateValues.last(),
143142
)
144143
}
145144

@@ -153,6 +152,5 @@ fun AmountPreviewDisconnected() {
153152
captionText = "The value of kin fluctuates",
154153
currencyResId = R.drawable.ic_flag_ca,
155154
networkState = networkStateValues.first(),
156-
isAnimated = false
157155
)
158156
}

0 commit comments

Comments
 (0)