mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Animate rounded corner size change to avoid blink effect when changing number of lines from 1 <-> 2 in the composer.
This commit is contained in:
committed by
Benoit Marty
parent
e93f245fcf
commit
e5f933576f
+12
-4
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package io.element.android.libraries.textcomposer
|
package io.element.android.libraries.textcomposer
|
||||||
|
|
||||||
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
@@ -105,14 +107,20 @@ fun TextComposer(
|
|||||||
AttachmentButton(onClick = onAddAttachment, modifier = Modifier.padding(vertical = 6.dp))
|
AttachmentButton(onClick = onAddAttachment, modifier = Modifier.padding(vertical = 6.dp))
|
||||||
Spacer(modifier = Modifier.width(12.dp))
|
Spacer(modifier = Modifier.width(12.dp))
|
||||||
var lineCount by remember { mutableStateOf(0) }
|
var lineCount by remember { mutableStateOf(0) }
|
||||||
val roundedCorners = remember(lineCount, composerMode) {
|
val roundedCornerSize = remember(lineCount, composerMode) {
|
||||||
if (lineCount > 1 || composerMode is MessageComposerMode.Special) {
|
if (lineCount > 1 || composerMode is MessageComposerMode.Special) {
|
||||||
RoundedCornerShape(20.dp)
|
20.dp
|
||||||
} else {
|
} else {
|
||||||
RoundedCornerShape(28.dp)
|
28.dp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val roundedCornerSizeState = animateDpAsState(
|
||||||
|
targetValue = roundedCornerSize,
|
||||||
|
animationSpec = tween(
|
||||||
|
durationMillis = 100,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val roundedCorners = RoundedCornerShape(roundedCornerSizeState.value)
|
||||||
val minHeight = 42.dp
|
val minHeight = 42.dp
|
||||||
val bgColor = ElementTheme.colors.bgSubtleSecondary
|
val bgColor = ElementTheme.colors.bgSubtleSecondary
|
||||||
val borderColor = ElementTheme.colors.borderDisabled
|
val borderColor = ElementTheme.colors.borderDisabled
|
||||||
|
|||||||
Reference in New Issue
Block a user