mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 13:28:26 +00:00
Tweak animations and make it scrollable on small screens
This commit is contained in:
parent
d0ebd3533b
commit
2cca1d4d8c
@ -8,7 +8,6 @@ import androidx.compose.animation.AnimatedVisibility
|
|||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.slideInVertically
|
import androidx.compose.animation.slideInVertically
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@ -16,6 +15,7 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
@ -32,6 +32,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.ComposeView
|
import androidx.compose.ui.platform.ComposeView
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
@ -103,7 +104,6 @@ class LandingActivity : BaseActionBarActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun LandingScreen() {
|
private fun LandingScreen() {
|
||||||
|
|
||||||
@ -132,18 +132,18 @@ class LandingActivity : BaseActionBarActivity() {
|
|||||||
LazyColumn(
|
LazyColumn(
|
||||||
state = listState,
|
state = listState,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.heightIn(min = 200.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.weight(1f),
|
.weight(2f),
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
) {
|
) {
|
||||||
items(
|
items(
|
||||||
MESSAGES.take(count),
|
MESSAGES.take(count),
|
||||||
key = { it.stringId }
|
key = { it.stringId }
|
||||||
) { item ->
|
) { item ->
|
||||||
MessageText(
|
AnimateMessageText(
|
||||||
stringResource(item.stringId),
|
stringResource(item.stringId),
|
||||||
item.isOutgoing,
|
item.isOutgoing
|
||||||
modifier = Modifier.animateItemPlacement()
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,13 +198,32 @@ class LandingActivity : BaseActionBarActivity() {
|
|||||||
Intent(Intent.ACTION_VIEW, Uri.parse(url)).let(::startActivity)
|
Intent(Intent.ACTION_VIEW, Uri.parse(url)).let(::startActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun AnimateMessageText(text: String, isOutgoing: Boolean, modifier: Modifier = Modifier) {
|
||||||
|
var visible by remember { mutableStateOf(false) }
|
||||||
|
LaunchedEffect(Unit) { visible = true }
|
||||||
|
|
||||||
|
Box {
|
||||||
|
// TODO [SES-2077] Use LazyList itemAnimation when we update to compose 1.7 or so.
|
||||||
|
MessageText(text, isOutgoing, Modifier.alpha(0f))
|
||||||
|
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = visible,
|
||||||
|
enter = fadeIn(animationSpec = tween(durationMillis = 300)) +
|
||||||
|
slideInVertically(animationSpec = tween(durationMillis = 300)) { it }
|
||||||
|
) {
|
||||||
|
MessageText(text, isOutgoing, modifier)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun MessageText(text: String, isOutgoing: Boolean, modifier: Modifier) {
|
private fun MessageText(text: String, isOutgoing: Boolean, modifier: Modifier) {
|
||||||
if (isOutgoing) OutgoingText(text, modifier) else IncomingText(text, modifier)
|
if (isOutgoing) OutgoingText(text, modifier) else IncomingText(text, modifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun IncomingText(text: String, modifier: Modifier) {
|
private fun IncomingText(text: String, modifier: Modifier = Modifier) {
|
||||||
ChatText(
|
ChatText(
|
||||||
text,
|
text,
|
||||||
color = classicDarkColors[2],
|
color = classicDarkColors[2],
|
||||||
@ -213,7 +232,7 @@ class LandingActivity : BaseActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun OutgoingText(text: String, modifier: Modifier) {
|
private fun OutgoingText(text: String, modifier: Modifier = Modifier) {
|
||||||
Box(modifier = modifier then Modifier.fillMaxWidth()) {
|
Box(modifier = modifier then Modifier.fillMaxWidth()) {
|
||||||
ChatText(
|
ChatText(
|
||||||
text,
|
text,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user