mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Fix: ActionButton animation
This commit is contained in:
parent
ed0ad62dc0
commit
b3d1440f6a
@ -2,6 +2,12 @@ package com.looker.droidify.ui.compose.components
|
||||
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.animation.SizeTransform
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.animation.with
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
@ -11,6 +17,7 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.ElevatedButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -19,36 +26,49 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.looker.droidify.entity.ActionState
|
||||
import com.looker.droidify.entity.ComponentState
|
||||
import com.looker.droidify.entity.DownloadState
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
fun MainActionButton(
|
||||
modifier: Modifier = Modifier,
|
||||
actionState: ActionState,
|
||||
downloadState: DownloadState?,
|
||||
onClick: (ComponentState) -> Unit
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
|
||||
ElevatedButton(
|
||||
modifier = modifier,
|
||||
onClick = { onClick(actionState) }
|
||||
onClick = {
|
||||
onClick()
|
||||
},
|
||||
colors = ButtonDefaults.elevatedButtonColors(
|
||||
containerColor = when (actionState) {
|
||||
is ActionState.Cancel -> MaterialTheme.colorScheme.secondaryContainer
|
||||
is ActionState.NoAction -> MaterialTheme.colorScheme.inverseSurface
|
||||
else -> MaterialTheme.colorScheme.surface
|
||||
},
|
||||
contentColor = when (actionState) {
|
||||
is ActionState.Cancel -> MaterialTheme.colorScheme.secondary
|
||||
is ActionState.NoAction -> MaterialTheme.colorScheme.inverseOnSurface
|
||||
else -> MaterialTheme.colorScheme.primary
|
||||
},
|
||||
)
|
||||
) {
|
||||
val content = @Composable {
|
||||
}
|
||||
|
||||
AnimatedContent(
|
||||
targetState = packageState,
|
||||
// TODO Fix redrawing changing state
|
||||
/*transitionSpec = {
|
||||
targetState = actionState,
|
||||
transitionSpec = {
|
||||
when (targetState) {
|
||||
is Cancelable -> {
|
||||
slideInVertically { height -> height } + fadeIn() with
|
||||
slideOutVertically { height -> -height } + fadeOut()
|
||||
}
|
||||
is ButtonWork -> {
|
||||
is ActionState.Cancel ->
|
||||
(slideInVertically { height -> height } + fadeIn() with
|
||||
slideOutVertically { height -> -height } + fadeOut())
|
||||
else ->
|
||||
(slideInVertically { height -> -height } + fadeIn() with
|
||||
slideOutVertically { height -> height } + fadeOut())
|
||||
}
|
||||
}
|
||||
.using(SizeTransform(clip = false))
|
||||
}*/
|
||||
}
|
||||
) {
|
||||
Row(
|
||||
Modifier
|
||||
|
@ -40,8 +40,7 @@ fun AppInfoHeader(
|
||||
versionCode: String,
|
||||
appSize: String,
|
||||
appDev: String,
|
||||
mainAction: ActionState? = ActionState.Install,
|
||||
downloadState: DownloadState?,
|
||||
mainAction: ActionState?,
|
||||
secondaryAction: ComponentState? = null,
|
||||
onSource: () -> Unit = { },
|
||||
onSourceLong: () -> Unit = { },
|
||||
@ -73,8 +72,7 @@ fun AppInfoHeader(
|
||||
})
|
||||
MainActionButton(
|
||||
modifier = Modifier.weight(1f),
|
||||
actionState = mainAction ?: ActionState.Install,
|
||||
downloadState = downloadState,
|
||||
actionState = mainAction ?: ActionState.NoAction,
|
||||
onClick = {
|
||||
onAction()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user