make units configurable in buildconfig
This commit is contained in:
parent
9d43dcfb9b
commit
88095d1edb
3 changed files with 10 additions and 9 deletions
|
@ -23,6 +23,9 @@ android {
|
|||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
}
|
||||
|
||||
buildConfigField("String", "CURRENCY_UNIT", "\"zł\"")
|
||||
buildConfigField("String", "CURRENCY_CENT", "\"gr\"")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
@ -43,6 +46,7 @@ android {
|
|||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.5.15"
|
||||
|
|
|
@ -133,7 +133,7 @@ fun BalanceView(balance: Int) {
|
|||
fontSize = 32.sp
|
||||
)
|
||||
Text(
|
||||
text = "zł",
|
||||
text = BuildConfig.CURRENCY_UNIT,
|
||||
fontSize = 14.sp
|
||||
)
|
||||
}
|
||||
|
@ -270,10 +270,7 @@ fun AddWalletButton(
|
|||
|
||||
fun formatCurrency(units: Int): String {
|
||||
if (units < 100) {
|
||||
return "$units gr"
|
||||
return "$units ${BuildConfig.CURRENCY_CENT}"
|
||||
}
|
||||
if (units % 100 == 0) {
|
||||
return "%d zł".format(units / 100)
|
||||
}
|
||||
return "%.2f zł".format(units / 100.0)
|
||||
return "%.2f %s".format(units / 100.0, BuildConfig.CURRENCY_UNIT)
|
||||
}
|
|
@ -150,7 +150,7 @@ fun App(
|
|||
fontSize = 32.sp
|
||||
)
|
||||
Text(
|
||||
text = "zł",
|
||||
text = BuildConfig.CURRENCY_UNIT,
|
||||
fontSize = 14.sp
|
||||
)
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ fun TransactionList(viewModel: WalletViewModel) {
|
|||
items(transactions) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.width(200.dp)
|
||||
.width(250.dp)
|
||||
.padding(8.dp)
|
||||
) {
|
||||
Row(
|
||||
|
@ -186,7 +186,7 @@ fun TransactionList(viewModel: WalletViewModel) {
|
|||
.weight(1f))
|
||||
|
||||
Text(
|
||||
text = "%.2f".format(it.value / 100.0),
|
||||
text = "%.2f %s".format(it.value / 100.0, BuildConfig.CURRENCY_UNIT),
|
||||
color = if (it.value < 0) MaterialTheme.colorScheme.error else Color.Unspecified
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue