Skip to content

Commit

Permalink
Merge pull request #859 from radixdlt/fix/ABW-3107-toggle-visibility-…
Browse files Browse the repository at this point in the history
…when-click-on-balance

[ABW-3107] Toggle visibility when click on balance
  • Loading branch information
giannis-rdx authored Apr 2, 2024
2 parents cca66dd + d7c124b commit 5d2a0e2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ fun AssetsContent(
contentColor = RadixTheme.colors.white,
shimmeringColor = RadixTheme.colors.defaultBackground.copy(alpha = 0.6f),
formattedContentStyle = RadixTheme.typography.header,
onVisibilityToggle = onShowHideBalanceToggle,
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = onShowHideBalanceToggle)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fun TotalFiatBalanceView(
contentStyle: TextStyle = RadixTheme.typography.title,
formattedContentStyle: TextStyle = contentStyle,
shimmeringColor: Color? = null,
onVisibilityToggle: (isVisible: Boolean) -> Unit,
trailingContent: (@Composable () -> Unit)? = null
) {
if (isLoading) {
Expand All @@ -57,6 +58,7 @@ fun TotalFiatBalanceView(
contentStyle = contentStyle,
currency = currency,
formattedContentStyle = formattedContentStyle,
onVisibilityToggle = onVisibilityToggle,
trailingContent = trailingContent
)
}
Expand Down Expand Up @@ -89,6 +91,7 @@ private fun TotalBalanceContent(
hiddenContentColor: Color,
contentStyle: TextStyle,
formattedContentStyle: TextStyle,
onVisibilityToggle: (isVisible: Boolean) -> Unit,
trailingContent: (@Composable () -> Unit)?
) {
val isPriceVisible = LocalBalanceVisibility.current
Expand Down Expand Up @@ -125,7 +128,10 @@ private fun TotalBalanceContent(
}

Row(
modifier = modifier,
modifier = modifier
.clickable {
onVisibilityToggle(!isPriceVisible)
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
Expand Down Expand Up @@ -170,7 +176,7 @@ fun TotalFiatBalanceViewToggle(

@Preview(showBackground = true)
@Composable
fun TotalBalanceZeroPreview() {
fun TotalFiatBalanceZeroPreview() {
RadixWalletTheme {
TotalFiatBalanceView(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -180,6 +186,7 @@ fun TotalBalanceZeroPreview() {
),
currency = SupportedCurrency.USD,
isLoading = false,
onVisibilityToggle = {},
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = {})
}
Expand All @@ -189,7 +196,7 @@ fun TotalBalanceZeroPreview() {

@Preview(showBackground = true)
@Composable
fun TotalBalancePreview() {
fun TotalFiatBalancePreview() {
RadixWalletTheme {
TotalFiatBalanceView(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -199,6 +206,7 @@ fun TotalBalancePreview() {
),
currency = SupportedCurrency.USD,
isLoading = false,
onVisibilityToggle = {},
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = {})
}
Expand All @@ -208,7 +216,7 @@ fun TotalBalancePreview() {

@Preview(showBackground = true)
@Composable
fun TotalBalanceWithValueLessThanOnePreview() {
fun TotalFiatBalanceWithValueLessThanOnePreview() {
RadixWalletTheme {
TotalFiatBalanceView(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -218,6 +226,7 @@ fun TotalBalanceWithValueLessThanOnePreview() {
),
currency = SupportedCurrency.USD,
isLoading = false,
onVisibilityToggle = {},
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = {})
}
Expand All @@ -227,7 +236,7 @@ fun TotalBalanceWithValueLessThanOnePreview() {

@Preview(showBackground = true)
@Composable
fun TotalBalanceWithVerySmallValuePreview() {
fun TotalFiatBalanceWithVerySmallValuePreview() {
RadixWalletTheme {
TotalFiatBalanceView(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -237,6 +246,7 @@ fun TotalBalanceWithVerySmallValuePreview() {
),
currency = SupportedCurrency.USD,
isLoading = false,
onVisibilityToggle = {},
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = {})
}
Expand All @@ -247,7 +257,7 @@ fun TotalBalanceWithVerySmallValuePreview() {
@Preview(showBackground = true)
@Preview("large font", fontScale = 2f, showBackground = true)
@Composable
fun TotalBalanceWithLongValuePreview() {
fun TotalFiatBalanceWithLongValuePreview() {
RadixWalletTheme {
TotalFiatBalanceView(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -257,6 +267,7 @@ fun TotalBalanceWithLongValuePreview() {
),
currency = SupportedCurrency.USD,
isLoading = false,
onVisibilityToggle = {},
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = {})
}
Expand All @@ -266,13 +277,14 @@ fun TotalBalanceWithLongValuePreview() {

@Preview(showBackground = true)
@Composable
fun TotalBalanceErrorPreview() {
fun TotalFiatBalanceErrorPreview() {
RadixWalletTheme {
TotalFiatBalanceView(
modifier = Modifier.fillMaxWidth(),
fiatPrice = null,
currency = SupportedCurrency.USD,
isLoading = false,
onVisibilityToggle = {},
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = {})
}
Expand All @@ -282,7 +294,7 @@ fun TotalBalanceErrorPreview() {

@Preview(showBackground = true)
@Composable
fun TotalBalanceHiddenPreview() {
fun TotalFiatBalanceHiddenPreview() {
RadixWalletTheme {
CompositionLocalProvider(value = LocalBalanceVisibility.provides(false)) {
TotalFiatBalanceView(
Expand All @@ -293,6 +305,7 @@ fun TotalBalanceHiddenPreview() {
),
currency = SupportedCurrency.USD,
isLoading = false,
onVisibilityToggle = {},
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = {})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ fun AccountCardView(
isLoading = false,
contentColor = RadixTheme.colors.white,
hiddenContentColor = RadixTheme.colors.white.copy(alpha = 0.6f),
onVisibilityToggle = {},
contentStyle = RadixTheme.typography.body1Header
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ private fun WalletAccountList(
isLoading = state.isWalletBalanceLoading,
currency = SupportedCurrency.USD,
formattedContentStyle = RadixTheme.typography.header,
onVisibilityToggle = onShowHideBalanceToggle,
trailingContent = {
TotalFiatBalanceViewToggle(onToggle = onShowHideBalanceToggle)
}
Expand Down

0 comments on commit 5d2a0e2

Please sign in to comment.