mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
feat: animate the arrow button
This commit is contained in:
parent
81f485da6b
commit
4868c45b43
1 changed files with 9 additions and 4 deletions
|
@ -1,22 +1,27 @@
|
|||
package app.revanced.manager.ui.component
|
||||
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
||||
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import app.revanced.manager.R
|
||||
|
||||
@Composable
|
||||
fun ArrowButton(expanded: Boolean, onClick: () -> Unit) {
|
||||
IconButton(onClick = onClick) {
|
||||
val (icon, string) = if (expanded) Icons.Filled.KeyboardArrowUp to R.string.collapse_content else Icons.Filled.KeyboardArrowDown to R.string.expand_content
|
||||
val description = if (expanded) R.string.collapse_content else R.string.expand_content
|
||||
val rotation by animateFloatAsState(targetValue = if (expanded) 0f else 180f)
|
||||
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = stringResource(string)
|
||||
imageVector = Icons.Filled.KeyboardArrowUp,
|
||||
contentDescription = stringResource(description),
|
||||
modifier = Modifier.rotate(rotation)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue