Updated on 2026-08-14
This commit is contained in:
parent
68920e11b5
commit
2754318b8e
9 changed files with 45 additions and 13 deletions
|
|
@ -64,6 +64,7 @@ fun AmountTextField(
|
|||
keyboardType = KeyboardType.Number,
|
||||
),
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
isEnabled: Boolean = true,
|
||||
isAutoResize: Boolean = false,
|
||||
@FloatRange(from = 0.0, to = 1.0, fromInclusive = false, toInclusive = false)
|
||||
reduceFactor: Double = 0.9,
|
||||
|
|
@ -106,21 +107,20 @@ fun AmountTextField(
|
|||
textStyle = textStyle.copy(
|
||||
fontSize = fontSize,
|
||||
textDirection = TextDirection.ContentOrLtr,
|
||||
textAlign = TextAlign.Center,
|
||||
),
|
||||
color = color,
|
||||
keyboardOptions = keyboardOptions,
|
||||
keyboardActions = keyboardActions,
|
||||
singleLine = true,
|
||||
readOnly = !isEnabled,
|
||||
visualTransformation = AmountVisualTransformation(decimals, symbol, decimalFormat),
|
||||
modifier = Modifier.background(TangemTheme.colors.background.action),
|
||||
decorationBox = { innerTextField ->
|
||||
Box {
|
||||
if (value.isBlank() && showPlaceholder) {
|
||||
val placeholder = if (symbol != null) {
|
||||
decimalFormat.defaultFormat().plus(" $symbol")
|
||||
} else {
|
||||
decimalFormat.defaultFormat()
|
||||
var placeholder = decimalFormat.defaultFormat()
|
||||
if (symbol != null) {
|
||||
placeholder = placeholder.plus(" $symbol")
|
||||
}
|
||||
Text(
|
||||
text = placeholder,
|
||||
|
|
|
|||
|
|
@ -11,10 +11,11 @@ class JobHolder {
|
|||
|
||||
private var job: Job? = null
|
||||
|
||||
/** Update current [job] */
|
||||
fun update(job: Job?) {
|
||||
/** Update current [JobHolder.job] and return new [job] */
|
||||
fun update(job: Job): Job {
|
||||
this.job?.cancel()
|
||||
this.job = job
|
||||
return job
|
||||
}
|
||||
|
||||
/** Cancel current [job] */
|
||||
|
|
@ -23,4 +24,4 @@ class JobHolder {
|
|||
}
|
||||
}
|
||||
|
||||
fun Job.saveIn(jobHolder: JobHolder) = jobHolder.update(job = this)
|
||||
fun Job.saveIn(jobHolder: JobHolder): Job = jobHolder.update(job = this)
|
||||
Loading…
Add table
Add a link
Reference in a new issue