feat: tweak slide to reply animation
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
c211f24e5e
commit
4acc42294c
|
|
@ -4,8 +4,9 @@ import android.annotation.SuppressLint
|
||||||
import androidx.compose.animation.AnimatedContent
|
import androidx.compose.animation.AnimatedContent
|
||||||
import androidx.compose.animation.animateColorAsState
|
import androidx.compose.animation.animateColorAsState
|
||||||
import androidx.compose.animation.core.animateFloatAsState
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.animation.slideInVertically
|
import androidx.compose.animation.core.spring
|
||||||
import androidx.compose.animation.slideOutVertically
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.togetherWith
|
import androidx.compose.animation.togetherWith
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
|
@ -218,17 +219,6 @@ fun RegularMessage(
|
||||||
with(LocalDensity.current) {
|
with(LocalDensity.current) {
|
||||||
val msgHeightAsDp = messageHeight.toDp()
|
val msgHeightAsDp = messageHeight.toDp()
|
||||||
BoxWithConstraints(Modifier.height(msgHeightAsDp)) {
|
BoxWithConstraints(Modifier.height(msgHeightAsDp)) {
|
||||||
AnimatedContent(
|
|
||||||
targetState = canReleaseToSend,
|
|
||||||
transitionSpec = {
|
|
||||||
if (canReleaseToSend) {
|
|
||||||
slideInVertically { -it } togetherWith slideOutVertically { it }
|
|
||||||
} else {
|
|
||||||
slideInVertically { it } togetherWith slideOutVertically { -it }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
label = "Swipe to Reply indicator content slide"
|
|
||||||
) {
|
|
||||||
Row(
|
Row(
|
||||||
Modifier
|
Modifier
|
||||||
.height(msgHeightAsDp)
|
.height(msgHeightAsDp)
|
||||||
|
|
@ -240,11 +230,7 @@ fun RegularMessage(
|
||||||
).toDp()
|
).toDp()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.background(
|
.background(indicatorBackground)
|
||||||
// indicatorBackground
|
|
||||||
if (it) MaterialTheme.colorScheme.inversePrimary
|
|
||||||
else MaterialTheme.colorScheme.primaryContainer
|
|
||||||
)
|
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(start = 16.dp),
|
.padding(start = 16.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
|
@ -262,10 +248,16 @@ fun RegularMessage(
|
||||||
24.dp
|
24.dp
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
tint = // indicatorForeground
|
tint = indicatorForeground
|
||||||
if (it) MaterialTheme.colorScheme.primary
|
|
||||||
else MaterialTheme.colorScheme.onPrimaryContainer
|
|
||||||
)
|
)
|
||||||
|
AnimatedContent(
|
||||||
|
targetState = canReleaseToSend,
|
||||||
|
transitionSpec = {
|
||||||
|
fadeIn(animationSpec = spring()) togetherWith
|
||||||
|
fadeOut(animationSpec = spring())
|
||||||
|
},
|
||||||
|
label = "Swipe to Reply indicator label"
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
when (it) {
|
when (it) {
|
||||||
true -> stringResource(
|
true -> stringResource(
|
||||||
|
|
@ -276,7 +268,8 @@ fun RegularMessage(
|
||||||
R.string.swipe_to_reply_keep_swiping
|
R.string.swipe_to_reply_keep_swiping
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
color = indicatorForeground
|
color = indicatorForeground,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue