Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Money total sum customization #2824

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@
<string name="experimental">تجريبي</string>
<string name="experimental_settings">الإعدادات التجريبية</string>
<string name="wallet_balance">رصيد المحفظة</string>
<string name="total_exclusive">%1$s %2$s: المجموع (حصريا)</string>
</resources>
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@
<string name="experimental">Experimental</string>
<string name="experimental_settings">Experimental Settings</string>
<string name="wallet_balance">Wallet balance</string>
<string name="total_exclusive">Общо (без): %1$s %2$s</string>
</resources>
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@
<string name="experimental">Experimental</string>
<string name="experimental_settings">Ajustes experimentales</string>
<string name="wallet_balance">Wallet balance</string>
<string name="total_exclusive">Total (exclusivo): %1$s %2$s</string>
</resources>
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@
<string name="experimental">Experimental</string>
<string name="experimental_settings">प्रायोगिक सेटिंग्स</string>
<string name="wallet_balance">वॉलेट बैलेंस</string>
<string name="total_exclusive">कुल (अनन्य): %1$s %2$s</string>
</resources>
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@
<string name="experimental">Sperimantale</string>
<string name="experimental_settings">Impostazioni Sperimentali</string>
<string name="wallet_balance">Wallet balance</string>
<string name="total_exclusive">Totale (esclusivo): %1$s %2$s</string>
</resources>
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values-kn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@
<string name="experimental">ಪ್ರಯೋಗಾತ್ಮಕ</string>
<string name="experimental_settings">ಪ್ರಯೋಗಾತ್ಮಕ ಸೆಟ್ಟಿಂಗ್‌ಗಳು</string>
<string name="wallet_balance">Wallet balance</string>
<string name="total_exclusive">ಒಟ್ಟು (ವಿಶೇಷ): %1$s %2$s</string>
</resources>
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values-mn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@
<string name="experimental">Туршилт</string>
<string name="experimental_settings">Туршилтын тохиргоо</string>
<string name="wallet_balance">Хэтэвчний үлдэгдэл</string>
<string name="total_exclusive">Нийт (онцгой): %1$s %2$s</string>
</resources>
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@
<string name="experimental">Experimental</string>
<string name="experimental_settings">Experimental Settings</string>
<string name="wallet_balance">Wallet balance</string>
<string name="total_exclusive">Итого (эксклюзивно): %1$s %2$s</string>
</resources>
1 change: 1 addition & 0 deletions ivy-resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,5 @@
<string name="experimental">Experimental</string>
<string name="experimental_settings">Experimental Settings</string>
<string name="wallet_balance">Wallet balance</string>
<string name="total_exclusive">Total (exclusive): %1$s %2$s</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ data class AccountsState(
val accountsData: ImmutableList<AccountData>,
val totalBalanceWithExcluded: String,
val totalBalanceWithExcludedText: String,
val totalBalanceWithoutExcluded: String,
val totalBalanceWithoutExcludedText: String,
val reorderVisible: Boolean
)
)
10 changes: 10 additions & 0 deletions screen-accounts/src/main/java/com/ivy/accounts/AccountsTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ private fun BoxWithConstraintsScope.UI(
fontWeight = FontWeight.Bold
)
)

Text(
text = state.totalBalanceWithoutExcludedText,
style = UI.typo.nC.style(
color = Gray,
fontWeight = FontWeight.Bold
)
)
}

Spacer(Modifier.weight(1f))
Expand Down Expand Up @@ -367,6 +375,8 @@ private fun PreviewAccountsTab() {
),
totalBalanceWithExcluded = "25.54",
totalBalanceWithExcludedText = "BGN 25.54",
totalBalanceWithoutExcluded = "25.54",
totalBalanceWithoutExcludedText = "BGN 25.54",
reorderVisible = false
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class AccountsViewModel @Inject constructor(
) : ComposeViewModel<AccountsState, AccountsEvent>() {
private val baseCurrency = mutableStateOf("")
private val accountsData = mutableStateOf(listOf<AccountData>())
private val totalBalanceWithExcluded = mutableStateOf("")
private val totalBalanceWithExcludedText = mutableStateOf("")
private val totalBalanceWithoutExcluded = mutableStateOf("")
private val totalBalanceWithoutExcludedText = mutableStateOf("")
private val reorderVisible = mutableStateOf(false)
Expand All @@ -70,6 +72,8 @@ class AccountsViewModel @Inject constructor(
accountsData = getAccountsData(),
totalBalanceWithExcluded = getTotalBalanceWithExcluded(),
totalBalanceWithExcludedText = getTotalBalanceWithExcludedText(),
totalBalanceWithoutExcluded = getTotalBalanceWithoutExcluded(),
totalBalanceWithoutExcludedText = getTotalBalanceWithoutExcludedText(),
reorderVisible = getReorderVisible()
)
}
Expand All @@ -86,11 +90,21 @@ class AccountsViewModel @Inject constructor(

@Composable
private fun getTotalBalanceWithExcluded(): String {
return totalBalanceWithoutExcluded.value
return totalBalanceWithExcluded.value
}

@Composable
private fun getTotalBalanceWithExcludedText(): String {
return totalBalanceWithExcludedText.value
}

@Composable
private fun getTotalBalanceWithoutExcluded(): String {
return totalBalanceWithoutExcluded.value
}

@Composable
private fun getTotalBalanceWithoutExcludedText(): String {
return totalBalanceWithoutExcludedText.value
}

Expand Down Expand Up @@ -157,6 +171,13 @@ class AccountsViewModel @Inject constructor(
)
)

val totalBalanceWithExcludedAccounts = calcWalletBalanceAct(
CalcWalletBalanceAct.Input(
baseCurrency = baseCurrencyCode,
withExcluded = true
)
).toDouble()

val totalBalanceWithoutExcludedAccounts = calcWalletBalanceAct(
CalcWalletBalanceAct.Input(
baseCurrency = baseCurrencyCode
Expand All @@ -165,9 +186,17 @@ class AccountsViewModel @Inject constructor(

baseCurrency.value = baseCurrencyCode
accountsData.value = accountsDataList
totalBalanceWithExcludedText.value = totalBalanceWithExcludedAccounts.toString()
totalBalanceWithExcludedText.value = context.getString(
R.string.total,
baseCurrencyCode,
totalBalanceWithExcludedAccounts.format(
baseCurrencyCode
)
)
totalBalanceWithoutExcluded.value = totalBalanceWithoutExcludedAccounts.toString()
totalBalanceWithoutExcludedText.value = context.getString(
R.string.total,
R.string.total_exclusive,
baseCurrencyCode,
totalBalanceWithoutExcludedAccounts.format(
baseCurrencyCode
Expand Down