Skip to content

Commit 37eacb7

Browse files
committed
refactor: clean code
1 parent 334356d commit 37eacb7

File tree

1 file changed

+0
-79
lines changed

1 file changed

+0
-79
lines changed

app/src/main/java/to/bitkit/ui/components/BalanceHeaderView.kt

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
88
import androidx.compose.foundation.layout.height
99
import androidx.compose.foundation.layout.padding
1010
import androidx.compose.runtime.Composable
11-
import androidx.compose.runtime.LaunchedEffect
12-
import androidx.compose.runtime.mutableLongStateOf
13-
import androidx.compose.runtime.remember
1411
import androidx.compose.ui.Alignment
1512
import androidx.compose.ui.Modifier
1613
import androidx.compose.ui.tooling.preview.Preview
@@ -19,12 +16,6 @@ import to.bitkit.models.ConvertedAmount
1916
import to.bitkit.models.PrimaryDisplay
2017
import to.bitkit.ui.LocalCurrencies
2118
import to.bitkit.ui.currencyViewModel
22-
import androidx.compose.runtime.getValue
23-
import androidx.compose.runtime.setValue
24-
import androidx.compose.runtime.mutableIntStateOf
25-
import androidx.compose.runtime.mutableStateOf
26-
import to.bitkit.ext.removeSpaces
27-
import to.bitkit.models.BitcoinDisplayUnit
2819
import to.bitkit.ui.shared.util.clickableAlpha
2920
import to.bitkit.ui.theme.AppThemeSurface
3021
import to.bitkit.ui.theme.Colors
@@ -71,76 +62,6 @@ fun BalanceHeaderView(
7162
}
7263
}
7364

74-
@Composable
75-
fun BalanceHeaderEditable(
76-
input: String,
77-
showBitcoinSymbol: Boolean = true,
78-
onSatsChanged: (String) -> Unit,
79-
modifier: Modifier = Modifier,
80-
) {
81-
val (rates, _, _, _, displayUnit, primaryDisplay) = LocalCurrencies.current
82-
val currency = currencyViewModel ?: return
83-
84-
var placeholder: String by remember { mutableStateOf("0") }
85-
var placeholderFractional: String by remember { mutableStateOf("") }
86-
var value: String by remember { mutableStateOf("") }
87-
88-
if (displayUnit == BitcoinDisplayUnit.CLASSIC) {
89-
placeholderFractional = "00000000"
90-
}
91-
92-
if (primaryDisplay == PrimaryDisplay.FIAT) {
93-
placeholderFractional = "00"
94-
}
95-
96-
if (placeholderFractional.isNotEmpty()) {
97-
placeholder = "0.$placeholderFractional"
98-
}
99-
100-
if (input.isNotEmpty()) {
101-
102-
val whole = input.split(".").firstOrNull().orEmpty().removeSpaces()
103-
val fraction = input.split(".").getOrNull(1).orEmpty().removeSpaces()
104-
105-
if (primaryDisplay == PrimaryDisplay.FIAT) {
106-
value = whole //TODO FORMAT FIAT
107-
}
108-
109-
if (input.contains(".")) {
110-
placeholder = fraction //TODO GET FRACTIONAL LENGTH
111-
112-
// truncate to 2 decimals for fiat
113-
if (primaryDisplay == PrimaryDisplay.FIAT) {
114-
115-
value = "$whole.$fraction" //TODO FORMAT MONEY
116-
}
117-
} else {
118-
if (displayUnit == BitcoinDisplayUnit.MODERN && primaryDisplay == PrimaryDisplay.BITCOIN) {
119-
value = input //TODO FORMAT SATOSHI
120-
placeholder = ""
121-
} else {
122-
placeholder = ".$placeholderFractional"
123-
}
124-
}
125-
}
126-
127-
var smallRowPrefix: String by remember { mutableStateOf("") }
128-
var smallRowText: String by remember { mutableStateOf("") }
129-
var smallRowSymbol: String by remember { mutableStateOf("") }
130-
131-
BalanceHeader(
132-
modifier = modifier,
133-
smallRowPrefix = smallRowPrefix,
134-
smallRowSymbol = smallRowSymbol,
135-
smallRowText = smallRowText,
136-
largeRowPrefix = largeRowPrefix,
137-
largeRowText = largeRowText,
138-
largeRowSymbol = largeRowSymbol,
139-
showSymbol = showBitcoinSymbol,
140-
onClick = { }
141-
)
142-
}
143-
14465
@Composable
14566
fun BalanceHeader(
14667
modifier: Modifier = Modifier,

0 commit comments

Comments
 (0)