-
-
Save theapache64/9dfa23d9f688112b9a51c1fe36de1271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.animation.core.animateFloatAsState | |
import androidx.compose.animation.core.tween | |
import androidx.compose.desktop.Window | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.getValue | |
import androidx.compose.runtime.mutableStateOf | |
import androidx.compose.runtime.remember | |
import androidx.compose.runtime.setValue | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.draw.rotate | |
import androidx.compose.ui.unit.sp | |
// Preview | |
fun main() { | |
Window { | |
var enabled by remember { mutableStateOf(true) } | |
val targetValue = if (enabled) { | |
0f | |
} else { | |
180f | |
} | |
val animatedValue by animateFloatAsState( | |
targetValue = targetValue, | |
animationSpec = tween(2000), | |
finishedListener = { | |
enabled = !enabled | |
} | |
) | |
Box( | |
modifier = Modifier | |
.fillMaxSize(), | |
contentAlignment = Alignment.Center | |
) { | |
Text( | |
modifier = Modifier.rotate(animatedValue), | |
text = "Test", | |
fontSize = 30.sp | |
) | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment