mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 08:45:27 +02:00
Animate UnixTextField
This commit is contained in:
parent
ebca5218cc
commit
59de376f61
@ -18,6 +18,13 @@
|
|||||||
|
|
||||||
package com.sadellie.unitto.feature.epoch.component
|
package com.sadellie.unitto.feature.epoch.component
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedContent
|
||||||
|
import androidx.compose.animation.SizeTransform
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.slideInVertically
|
||||||
|
import androidx.compose.animation.slideOutVertically
|
||||||
|
import androidx.compose.animation.with
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.IntrinsicSize
|
import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
@ -41,11 +48,26 @@ fun UnixTextField(
|
|||||||
.horizontalScroll(rememberScrollState()),
|
.horizontalScroll(rememberScrollState()),
|
||||||
horizontalArrangement = Arrangement.End
|
horizontalArrangement = Arrangement.End
|
||||||
) {
|
) {
|
||||||
Text(
|
AnimatedContent(
|
||||||
text = unix.ifEmpty { "0" },
|
targetState = unix.ifEmpty { "0" },
|
||||||
modifier = modifier,
|
transitionSpec = {
|
||||||
style = NumbersTextStyleDisplayMedium,
|
if (targetState.toBigDecimal() > initialState.toBigDecimal()) {
|
||||||
textAlign = TextAlign.End
|
slideInVertically { height -> height } + fadeIn() with
|
||||||
)
|
slideOutVertically { height -> -height } + fadeOut()
|
||||||
|
} else {
|
||||||
|
slideInVertically { height -> -height } + fadeIn() with
|
||||||
|
slideOutVertically { height -> height } + fadeOut()
|
||||||
|
}.using(
|
||||||
|
SizeTransform(clip = false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = it,
|
||||||
|
modifier = modifier,
|
||||||
|
style = NumbersTextStyleDisplayMedium,
|
||||||
|
textAlign = TextAlign.End
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user