0% found this document useful (0 votes)
53 views2 pages

AnimationModifierScreen KT

This document defines a composable function called AnimationModifierScreen that displays text that can expand and contract in size using the animateContentSize modifier. It uses a boolean state variable to determine whether to display short or long sample text. The text is displayed within a rounded, clickable box that changes size as the text content changes between the short and long strings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views2 pages

AnimationModifierScreen KT

This document defines a composable function called AnimationModifierScreen that displays text that can expand and contract in size using the animateContentSize modifier. It uses a boolean state variable to determine whether to display short or long sample text. The text is displayed within a rounded, clickable box that changes size as the text content changes between the short and long strings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

package [Link].

animation

import [Link]
import [Link]
import [Link]
import [Link]
import [Link].*
import [Link]
//noinspection UsingMaterialAndMaterial3Libraries
import [Link]
//noinspection UsingMaterialAndMaterial3Libraries
import [Link]
import [Link].*
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link].R
import [Link]
import [Link]

private const val URL = "animation/[Link]"

@Composable
fun AnimationModifierScreen() {
DefaultScaffold(
title = [Link],
link = URL,
) {
Column(
modifier = [Link]().padding(paddingValues = it),
verticalArrangement = [Link],
horizontalAlignment = [Link],
) {
AnimateContent()
}
}
}

@Composable
private fun AnimateContent() {
val shortText = stringResource(id = [Link].short_text)
val longText = stringResource(id = [Link].long_text)
var short by remember { mutableStateOf(true) }
Box(
modifier = Modifier
.background(
[Link],
RoundedCornerShape([Link])
)
.clickable { short = !short }
.padding([Link])
.wrapContentSize()
.animateContentSize(
tween(500)
)
) {
Text(
if (short) {
shortText
} else {
longText
},
style = [Link](color = [Link])
)
}
}

You might also like