Abdul Hafeez Sajid
11/28/2022, 7:54 AMAbdul Hafeez Sajid
11/28/2022, 9:46 AM@OptIn(ExperimentalMotionApi::class)
@Composable
fun MyText(progress: Float) {
MotionLayout(
modifier = Modifier
.background(Color.LightGray)
.fillMaxWidth().fillMaxHeight(),
motionScene = MotionScene(
content = """
{
ConstraintSets: {
start: {
title: {
width: 'wrap',
top: ['parent', 'top'],
start: ['parent', 'start'],
end: ['parent', 'end'],
bottom: ['parent', 'bottom'],
custom: {
fontSize: 14,
}
},
},
end: {
title: {
top: ['parent', 'top'],
start: ['parent', 'start'],
end: ['parent', 'end'],
bottom: ['parent', 'bottom'],
custom: {
fontSize: 8
}
},
}
},
Transitions: {
default: {
from: 'start',
to: 'end'
}
}
}
""".trimIndent()),
progress = progress
) {
Text(
text = "This is some text",
modifier = Modifier
.layoutId("title")
.wrapContentWidth(unbounded = true),
color = MaterialTheme.colors.onSurface,
maxLines = 1,
softWrap = false,
fontSize = motionFontSize("title", "fontSize")
)
}
}