diff --git a/presentation/src/main/kotlin/app/web/drjackycv/presentation/base/view/ChooseArrowView.kt b/presentation/src/main/kotlin/app/web/drjackycv/presentation/base/view/ChooseArrowView.kt index e09bdb2..88e2a72 100644 --- a/presentation/src/main/kotlin/app/web/drjackycv/presentation/base/view/ChooseArrowView.kt +++ b/presentation/src/main/kotlin/app/web/drjackycv/presentation/base/view/ChooseArrowView.kt @@ -14,7 +14,11 @@ import androidx.compose.foundation.layout.requiredHeight import androidx.compose.foundation.layout.requiredWidth 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.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.graphics.Color @@ -32,9 +36,17 @@ import app.web.drjackycv.presentation.products.choose.CirclePosition @Suppress("MagicNumber") @Composable fun ChooseArrowAnimation( - circleState: CirclePosition, modifier: Modifier = Modifier, ) { + var circleState by remember { mutableStateOf(CirclePosition.Start) } + + LaunchedEffect(Unit) { + circleState = when (circleState) { + CirclePosition.Start -> CirclePosition.Finish + CirclePosition.Finish -> CirclePosition.Start + } + } + val offsetAnimation: Dp by animateDpAsState( label = "offsetAnimation", targetValue = if (circleState == CirclePosition.Start) 0.dp else 100.dp, @@ -128,6 +140,5 @@ fun ChooseArrowAnimation( private fun ChooseArrowAnimationPreview() { ChooseArrowAnimation( modifier = Modifier, - circleState = CirclePosition.Start ) } \ No newline at end of file diff --git a/presentation/src/main/kotlin/app/web/drjackycv/presentation/products/choose/ChooseView.kt b/presentation/src/main/kotlin/app/web/drjackycv/presentation/products/choose/ChooseView.kt index e69bb2f..5b15fb3 100644 --- a/presentation/src/main/kotlin/app/web/drjackycv/presentation/products/choose/ChooseView.kt +++ b/presentation/src/main/kotlin/app/web/drjackycv/presentation/products/choose/ChooseView.kt @@ -8,11 +8,6 @@ import androidx.compose.material.Button import androidx.compose.material.Scaffold import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.text.TextStyle @@ -56,7 +51,7 @@ fun ChooseView( ) { val (chooseAnimation, rxButton, coroutineButton) = createRefs() - SetupAndRunChooseArrowAnimation( + ChooseArrowAnimation( modifier = Modifier .constrainAs(chooseAnimation) { start.linkTo(parent.start, margin = 20.dp) @@ -104,24 +99,6 @@ fun ChooseView( ) } -@Composable -fun SetupAndRunChooseArrowAnimation( - modifier: Modifier = Modifier, -) { - var circleState by remember { mutableStateOf(CirclePosition.Start) } - - ChooseArrowAnimation( - modifier = modifier, - circleState = circleState - ) - LaunchedEffect(Unit) { - circleState = when (circleState) { - CirclePosition.Start -> CirclePosition.Finish - CirclePosition.Finish -> CirclePosition.Start - } - } -} - @Composable //TODO fun PathButton( name: String,