diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png index 96c9029eea..f5dc94fc90 100644 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png and b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png index 55788a78da..15855b09f6 100644 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png and b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png index 56522659bf..8c5c63d5cf 100644 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png and b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png index 9aff3b102a..07fffa6e55 100644 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png and b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen with search bar[Dark].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen with search bar[Dark].png index 96e9eaffbc..696df74d2a 100644 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen with search bar[Dark].png and b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen with search bar[Dark].png differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen with search bar[Light].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen with search bar[Light].png index f2debae7f9..dd32722d39 100644 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen with search bar[Light].png and b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen with search bar[Light].png differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Dark].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Dark].png index 4d2a026474..ed7456402d 100644 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Dark].png and b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Dark].png differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Light].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Light].png index c187fb7652..12bddf70cf 100644 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Light].png and b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Light].png differ diff --git a/screen/loans/src/test/snapshots/images/com.ivy.loans_LoanScreenPaparazziTest_snapshot loanScreen composable[Dark].png b/screen/loans/src/test/snapshots/images/com.ivy.loans_LoanScreenPaparazziTest_snapshot loanScreen composable[Dark].png index 31921f6f1e..cba4296d0d 100644 Binary files a/screen/loans/src/test/snapshots/images/com.ivy.loans_LoanScreenPaparazziTest_snapshot loanScreen composable[Dark].png and b/screen/loans/src/test/snapshots/images/com.ivy.loans_LoanScreenPaparazziTest_snapshot loanScreen composable[Dark].png differ diff --git a/screen/loans/src/test/snapshots/images/com.ivy.loans_LoanScreenPaparazziTest_snapshot loanScreen composable[Light].png b/screen/loans/src/test/snapshots/images/com.ivy.loans_LoanScreenPaparazziTest_snapshot loanScreen composable[Light].png index 82c88a8087..8e34d6beb5 100644 Binary files a/screen/loans/src/test/snapshots/images/com.ivy.loans_LoanScreenPaparazziTest_snapshot loanScreen composable[Light].png and b/screen/loans/src/test/snapshots/images/com.ivy.loans_LoanScreenPaparazziTest_snapshot loanScreen composable[Light].png differ diff --git a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Dark].png b/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Dark].png index f0e64b1021..4c3fd6dcf7 100644 Binary files a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Dark].png and b/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Dark].png differ diff --git a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Light].png b/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Light].png index 30d230af7d..089af7d865 100644 Binary files a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Light].png and b/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Light].png differ diff --git a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png b/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png index 7fc42ddabf..f20ddfe28e 100644 Binary files a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png and b/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png differ diff --git a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png b/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png index 37bb2eafb1..2f58760670 100644 Binary files a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png and b/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png differ diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/BalanceRow.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/BalanceRow.kt index 7f839e4c0a..6db91b81c0 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/BalanceRow.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/BalanceRow.kt @@ -27,6 +27,7 @@ import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.legacy.IvyWalletComponentPreview import com.ivy.legacy.utils.toDecimalFormat +import com.ivy.legacy.utils.toDecimalFormatWithFraction import kotlinx.coroutines.launch @Deprecated("Old design system. Use `:ivy-design` and Material3") @@ -78,7 +79,7 @@ fun BalanceRowMini( ) } -@SuppressLint("CoroutineCreationDuringComposition", "DefaultLocale") +@SuppressLint("CoroutineCreationDuringComposition") @Composable fun BalanceRow( currency: String, @@ -95,7 +96,7 @@ fun BalanceRow( val context = LocalContext.current val scope = rememberCoroutineScope() var formattedBalance by remember { - mutableStateOf(String.format("%.2f", balance)) + mutableStateOf(balance.toDecimalFormatWithFraction()) } scope.launch { formattedBalance = balance.toDecimalFormat(context) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/wallet/AmountCurrency.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/wallet/AmountCurrency.kt index d3230c30b4..d99513bed8 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/wallet/AmountCurrency.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/wallet/AmountCurrency.kt @@ -22,6 +22,7 @@ import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.legacy.utils.format import com.ivy.legacy.utils.toDecimalFormat +import com.ivy.legacy.utils.toDecimalFormatWithFraction import kotlinx.coroutines.launch @Deprecated("Old design system. Use `:ivy-design` and Material3") @@ -72,7 +73,7 @@ fun AmountCurrencyB1Row( } } -@SuppressLint("ComposeContentEmitterReturningValues", "CoroutineCreationDuringComposition", "DefaultLocale") +@SuppressLint("ComposeContentEmitterReturningValues", "CoroutineCreationDuringComposition") @Composable fun AmountCurrencyB1( amount: Double, @@ -83,7 +84,7 @@ fun AmountCurrencyB1( ) { val context = LocalContext.current val scope = rememberCoroutineScope() - var formattedAmount by remember { mutableStateOf(String.format("%.2f", amount)) } + var formattedAmount by remember { mutableStateOf(amount.toDecimalFormatWithFraction()) } scope.launch { formattedAmount = amount.toDecimalFormat(context) } diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/utils/AmountFormatting.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/utils/AmountFormatting.kt index 9694c75535..3b26dfc07e 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/utils/AmountFormatting.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/utils/AmountFormatting.kt @@ -6,6 +6,8 @@ import com.ivy.wallet.domain.data.IvyCurrency import dagger.hilt.EntryPoints import java.text.DecimalFormat import java.text.DecimalFormatSymbols +import java.text.NumberFormat +import java.util.Locale import kotlin.math.abs import kotlin.math.log10 import kotlin.math.truncate @@ -206,6 +208,16 @@ suspend fun Double.toDecimalFormat(context: Context): String { return useCase.format(this) } +fun Double.toDecimalFormatWithFraction(fraction: Int = 2): String { + val defaultLocale: Locale = Locale.getDefault() + + // Create a NumberFormat instance for the current locale + val numberFormat: NumberFormat = NumberFormat.getNumberInstance(defaultLocale) + numberFormat.minimumFractionDigits = fraction + numberFormat.maximumFractionDigits = fraction + return numberFormat.format(this) +} + /** toInt on numbers in the range (-1.0, 0.0) (exclusive of boundaries) will produce a positive int 0 So, this function append negative sign in that case