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

Commit

Permalink
Account Tab Decimal Formatting Added(Paparazzi snaps updated)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamim-emon committed Oct 6, 2024
1 parent d801d81 commit 6ade007
Show file tree
Hide file tree
Showing 20 changed files with 4 additions and 17 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions shared/ui/core/src/main/java/com/ivy/ui/FormatMoneyUseCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ class FormatMoneyUseCaseImpl @Inject constructor(
false -> withoutDecimalFormatter.format(value)
}
}

override fun formatWithDecimalPlaces(value: Double): String = withDecimalFormatter.format(value)
}

interface FormatMoneyUseCase {
suspend fun format(value: Double): String
fun formatWithDecimalPlaces(value: Double): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ 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.toDecimalFormatWithDecimalPlaces
import kotlinx.coroutines.launch

@Deprecated("Old design system. Use `:ivy-design` and Material3")
Expand Down Expand Up @@ -79,7 +78,7 @@ fun BalanceRowMini(
)
}

@SuppressLint("CoroutineCreationDuringComposition")
@SuppressLint("CoroutineCreationDuringComposition", "DefaultLocale")
@Composable
fun BalanceRow(
currency: String,
Expand All @@ -96,7 +95,7 @@ fun BalanceRow(
val context = LocalContext.current
val scope = rememberCoroutineScope()
var formattedBalance by remember {
mutableStateOf(balance.toDecimalFormatWithDecimalPlaces(context))
mutableStateOf(String.format("%.2f", balance))
}
scope.launch {
formattedBalance = balance.toDecimalFormat(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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.toDecimalFormatWithDecimalPlaces
import kotlinx.coroutines.launch

@Deprecated("Old design system. Use `:ivy-design` and Material3")
Expand Down Expand Up @@ -73,7 +72,7 @@ fun AmountCurrencyB1Row(
}
}

@SuppressLint("ComposeContentEmitterReturningValues", "CoroutineCreationDuringComposition")
@SuppressLint("ComposeContentEmitterReturningValues", "CoroutineCreationDuringComposition", "DefaultLocale")
@Composable
fun AmountCurrencyB1(
amount: Double,
Expand All @@ -84,7 +83,7 @@ fun AmountCurrencyB1(
) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
var formattedAmount by remember { mutableStateOf(amount.toDecimalFormatWithDecimalPlaces(context)) }
var formattedAmount by remember { mutableStateOf(String.format("%.2f", amount)) }
scope.launch {
formattedAmount = amount.toDecimalFormat(context)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,6 @@ suspend fun Double.toDecimalFormat(context: Context): String {
return useCase.format(this)
}

fun Double.toDecimalFormatWithDecimalPlaces(context: Context): String {
val appContext = context.applicationContext ?: error("Application Context Not Found")
val entryPoint =
EntryPoints.get(appContext, FormatMoneyUseCaseImpl.FormatMoneyUseCaseEntryPoint::class.java)
val useCase = entryPoint.FormatMoneyUseCase()
return useCase.formatWithDecimalPlaces(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
Expand Down

0 comments on commit 6ade007

Please sign in to comment.