Skip to content

Commit

Permalink
feat: animate the arrow button
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelen123 committed Jun 29, 2023
1 parent 81f485d commit 4868c45
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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)
)
}
}

0 comments on commit 4868c45

Please sign in to comment.