diff options
| author | Albin <albin@mullvad.net> | 2023-04-07 17:21:48 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-04-11 11:09:38 +0200 |
| commit | b5b13e3974a29623c868eeb2a2f9348c6a074136 (patch) | |
| tree | a68cb764a314a2432bb4c0eb5627acd9de437e90 | |
| parent | c841f16fa4bb8419311fd647f335599ed75a8ff9 (diff) | |
| download | mullvadvpn-b5b13e3974a29623c868eeb2a2f9348c6a074136.tar.xz mullvadvpn-b5b13e3974a29623c868eeb2a2f9348c6a074136.zip | |
Add chevron composable
Co-authored-by: saber safavi <saber.safavi@codic.se>
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt new file mode 100644 index 0000000000..8d458c7077 --- /dev/null +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt @@ -0,0 +1,36 @@ +package net.mullvad.mullvadvpn.compose.component + +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.tween +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.size +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.rotate +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import net.mullvad.mullvadvpn.R + +@Composable +fun ChevronView(isExpanded: Boolean) { + val resourceId = R.drawable.icon_chevron + val rotation = remember { Animatable(90f) } + + LaunchedEffect(isExpanded) { + rotation.animateTo( + targetValue = 90f + if (isExpanded) 0f else 180f, + animationSpec = tween(100, easing = LinearEasing) + ) + } + + Image( + painterResource(id = resourceId), + contentDescription = null, + modifier = Modifier.size(30.dp).rotate(rotation.value), + ) +} |
