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