Skip to content

Commit 1f2c4c3

Browse files
committed
refactor: Extract consts for hide balance texts
1 parent 3ccf333 commit 1f2c4c3

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

app/src/main/java/to/bitkit/ui/components/BalanceHeaderView.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import to.bitkit.ui.currencyViewModel
2828
import to.bitkit.ui.settingsViewModel
2929
import to.bitkit.ui.shared.animations.BalanceAnimations
3030
import to.bitkit.ui.shared.modifiers.swipeToHide
31+
import to.bitkit.ui.shared.UiConstants
3132
import to.bitkit.ui.shared.util.clickableAlpha
3233
import to.bitkit.ui.theme.AppThemeSurface
3334
import to.bitkit.ui.theme.Colors
@@ -205,7 +206,7 @@ fun LargeRow(
205206
transitionSpec = { BalanceAnimations.mainBalanceTransition },
206207
label = "largeRowTextAnimation"
207208
) { isHidden ->
208-
Display(text = if (isHidden) "• • • • • • • • •" else text)
209+
Display(text = if (isHidden) UiConstants.HIDE_BALANCE_LONG else text)
209210
}
210211
}
211212
}
@@ -228,7 +229,7 @@ private fun SmallRow(symbol: String?, text: String, hideBalance: Boolean = false
228229
label = "smallRowTextAnimation"
229230
) { isHidden ->
230231
Caption13Up(
231-
text = if (isHidden) "• • • • •" else text,
232+
text = if (isHidden) UiConstants.HIDE_BALANCE_SHORT else text,
232233
color = Colors.White64,
233234
)
234235
}

app/src/main/java/to/bitkit/ui/components/WalletBalanceView.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import to.bitkit.ui.LocalCurrencies
2424
import to.bitkit.ui.currencyViewModel
2525
import to.bitkit.ui.settingsViewModel
2626
import to.bitkit.ui.shared.animations.BalanceAnimations
27+
import to.bitkit.ui.shared.UiConstants
2728
import to.bitkit.ui.theme.Colors
2829

2930
@Composable
@@ -72,7 +73,7 @@ fun RowScope.WalletBalanceView(
7273
transitionSpec = { BalanceAnimations.walletBalanceTransition },
7374
label = "bitcoinBalanceAnimation"
7475
) { isHidden ->
75-
BodyMSB(text = if (isHidden) "• • • • •" else btcComponents.value)
76+
BodyMSB(text = if (isHidden) UiConstants.HIDE_BALANCE_SHORT else btcComponents.value)
7677
}
7778
} else {
7879
AnimatedContent(
@@ -85,7 +86,7 @@ fun RowScope.WalletBalanceView(
8586
horizontalArrangement = Arrangement.spacedBy(4.dp),
8687
) {
8788
BodyMSB(text = converted.symbol)
88-
BodyMSB(text = if (isHidden) "• • • • •" else converted.formatted)
89+
BodyMSB(text = if (isHidden) UiConstants.HIDE_BALANCE_SHORT else converted.formatted)
8990
}
9091
}
9192
}

app/src/main/java/to/bitkit/ui/screens/wallets/activity/components/ActivityRow.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
package to.bitkit.ui.screens.wallets.activity.components
22

33
import androidx.compose.animation.AnimatedContent
4-
import androidx.compose.animation.core.tween
5-
import androidx.compose.animation.fadeIn
6-
import androidx.compose.animation.fadeOut
7-
import androidx.compose.animation.slideInHorizontally
8-
import androidx.compose.animation.slideOutHorizontally
9-
import androidx.compose.animation.togetherWith
104
import androidx.compose.foundation.layout.Arrangement
115
import androidx.compose.foundation.layout.Column
126
import androidx.compose.foundation.layout.Row
@@ -24,6 +18,7 @@ import androidx.compose.ui.tooling.preview.Preview
2418
import androidx.compose.ui.tooling.preview.PreviewParameter
2519
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
2620
import androidx.compose.ui.unit.dp
21+
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2722
import to.bitkit.R
2823
import to.bitkit.ext.DatePattern
2924
import to.bitkit.ext.formatted
@@ -36,7 +31,9 @@ import to.bitkit.ui.components.BodyMSB
3631
import to.bitkit.ui.components.CaptionB
3732
import to.bitkit.ui.currencyViewModel
3833
import to.bitkit.ui.screens.wallets.activity.utils.previewActivityItems
34+
import to.bitkit.ui.settingsViewModel
3935
import to.bitkit.ui.shared.animations.BalanceAnimations
36+
import to.bitkit.ui.shared.UiConstants
4037
import to.bitkit.ui.shared.util.clickableAlpha
4138
import to.bitkit.ui.theme.AppThemeSurface
4239
import to.bitkit.ui.theme.Colors
@@ -46,8 +43,6 @@ import uniffi.bitkitcore.PaymentType
4643
import java.time.Instant
4744
import java.time.LocalDate
4845
import java.time.ZoneId
49-
import androidx.lifecycle.compose.collectAsStateWithLifecycle
50-
import to.bitkit.ui.settingsViewModel
5146

5247
@Composable
5348
fun ActivityRow(
@@ -229,7 +224,7 @@ private fun AmountViewContent(
229224
transitionSpec = { BalanceAnimations.activityAmountTransition },
230225
label = "titleAnimation"
231226
) { isHidden ->
232-
BodyMSB(text = if (isHidden) "• • • • •" else title)
227+
BodyMSB(text = if (isHidden) UiConstants.HIDE_BALANCE_SHORT else title)
233228
}
234229
}
235230

@@ -247,7 +242,7 @@ private fun AmountViewContent(
247242
label = "subtitleAnimation"
248243
) { isHidden ->
249244
CaptionB(
250-
text = if (isHidden) "• • • • •" else subtitle,
245+
text = if (isHidden) UiConstants.HIDE_BALANCE_SHORT else subtitle,
251246
color = Colors.White64,
252247
)
253248
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package to.bitkit.ui.shared
2+
3+
import androidx.compose.runtime.Immutable
4+
5+
@Immutable
6+
object UiConstants {
7+
const val HIDE_BALANCE_SHORT = "• • • • •"
8+
const val HIDE_BALANCE_LONG = "• • • • • • • • •"
9+
}

0 commit comments

Comments
 (0)