Skip to content

Commit 6500f6b

Browse files
committed
AnimatableSpacer.kt
1 parent abd992c commit 6500f6b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

animatable-compose/src/main/java/com/commandiron/animatable_compose/AnimatableText.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import androidx.compose.ui.unit.TextUnit
2121
import com.commandiron.animatable_compose.state.AnimatableState
2222
import com.commandiron.animatable_compose.state.AnimatableStateTag
2323
import com.commandiron.animatable_compose.state.SharedAnimatableState
24+
import org.w3c.dom.Text
2425

2526
@Composable
2627
fun AnimatableText(
@@ -41,6 +42,7 @@ fun AnimatableText(
4142
style: TextStyle = LocalTextStyle.current,
4243
state: SharedAnimatableState,
4344
stateIndex: Int = 0,
45+
fixedFontSize: TextUnit? = null,
4446
@FloatRange(from = 0.0, to = 1.0)
4547
fixedAlpha: Float? = null,
4648
fixedOffset: DpOffset = DpOffset.Unspecified,
@@ -64,7 +66,7 @@ fun AnimatableText(
6466
.alpha(fixedAlpha ?: stateIn.animatedAlpha)
6567
.then(modifier),
6668
color = color,
67-
fontSize = stateIn.animatedFontSize,
69+
fontSize = fixedFontSize ?: stateIn.animatedFontSize,
6870
fontStyle = fontStyle,
6971
fontWeight = fontWeight,
7072
fontFamily = fontFamily,
@@ -98,6 +100,7 @@ fun AnimatableText(
98100
onTextLayout: (TextLayoutResult) -> Unit = {},
99101
style: TextStyle = LocalTextStyle.current,
100102
state: AnimatableState,
103+
fixedFontSize: TextUnit? = null,
101104
@FloatRange(from = 0.0, to = 1.0)
102105
fixedAlpha: Float? = null,
103106
fixedOffset: DpOffset = DpOffset.Unspecified,
@@ -118,7 +121,7 @@ fun AnimatableText(
118121
.alpha(fixedAlpha ?: state.animatedAlpha)
119122
.then(modifier),
120123
color = color,
121-
fontSize = state.animatedFontSize,
124+
fontSize = fixedFontSize ?: state.animatedFontSize,
122125
fontStyle = fontStyle,
123126
fontWeight = fontWeight,
124127
fontFamily = fontFamily,

app/src/main/java/com/commandiron/animatablecompose/Show8InfoCard.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ fun Show8InfoCard() {
5959
)
6060
val animatableTextState = rememberAnimatableTextState(
6161
initialFontSize = 0.sp,
62-
targetFontSize = 12.sp
62+
targetFontSize = 12.sp,
63+
initialOffset = DpOffset(x = 0.dp, y = 300.dp),
64+
targetOffset = DpOffset(x = 0.dp, y = 0.dp)
6365
)
6466

6567

0 commit comments

Comments
 (0)