Skip to content

Commit

Permalink
Set CalculatorModal.kt initial value based on AmountModal.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Iliyan Germanov committed Nov 15, 2021
1 parent 56f5af3 commit 206c4fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fun BoxWithConstraintsScope.AmountModal(

CalculatorModal(
visible = calculatorModalVisible,
initialAmount = amount.amountToDoubleOrNull(),
currency = currency,
dismiss = {
calculatorModalVisible = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import java.util.*
@Composable
fun BoxWithConstraintsScope.CalculatorModal(
id: UUID = UUID.randomUUID(),
initialAmount: Double?,
visible: Boolean,
currency: String,

dismiss: () -> Unit,
onCalculation: (Double) -> Unit
) {
var expression by remember(id) {
mutableStateOf("")
var expression by remember(id, initialAmount) {
mutableStateOf(initialAmount?.format(currency) ?: "")
}

IvyModal(
Expand Down Expand Up @@ -155,6 +156,7 @@ private fun Preview() {
IvyAppPreview {
CalculatorModal(
visible = true,
initialAmount = 50.23,
currency = "BGN",
dismiss = { },
onCalculation = {}
Expand Down

0 comments on commit 206c4fe

Please sign in to comment.