feat: consistent corners in message composition area, typing indicator

This commit is contained in:
Infi 2023-02-25 22:37:49 +01:00
parent d06eb55aa3
commit 8c4615f207
3 changed files with 48 additions and 36 deletions

View File

@ -5,7 +5,6 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
@ -128,11 +127,7 @@ fun MessageField(
.padding(4.dp)
)
}
},
shape = RoundedCornerShape(
topStart = 16.dp,
topEnd = 16.dp
)
}
)
}
)

View File

@ -5,10 +5,12 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@ -43,9 +45,15 @@ fun TypingIndicator(
) {
Row(
Modifier
.background(MaterialTheme.colorScheme.surface)
.fillMaxWidth()
.padding(all = 4.dp)
.clip(
RoundedCornerShape(
topStart = 16.dp,
topEnd = 16.dp,
)
)
.background(MaterialTheme.colorScheme.background)
.padding(vertical = 8.dp, horizontal = 16.dp)
) {
Text(
text = stringResource(

View File

@ -377,7 +377,7 @@ fun ChannelScreen(
}
val scrollDownFABPadding by animateDpAsState(
if (viewModel.typingUsers.isNotEmpty()) 32.dp else 0.dp,
if (viewModel.typingUsers.isNotEmpty()) 40.dp else 0.dp,
animationSpec = RevoltTweenDp
)
@ -462,7 +462,7 @@ fun ChannelScreen(
) {
LazyColumn(state = lazyListState, reverseLayout = true) {
item {
Spacer(modifier = Modifier.height(32.dp))
Spacer(modifier = Modifier.height(40.dp))
}
items(viewModel.renderableMessages) { message ->
@ -523,33 +523,42 @@ fun ChannelScreen(
)
}
AnimatedVisibility(visible = viewModel.replies.isNotEmpty()) {
ReplyManager(
replies = viewModel.replies,
onRemove = viewModel::removeReply,
onToggleMention = viewModel::toggleReplyMentionFor
Column(
modifier = Modifier.clip(
RoundedCornerShape(
topStart = 16.dp,
topEnd = 16.dp
)
)
) {
AnimatedVisibility(visible = viewModel.replies.isNotEmpty()) {
ReplyManager(
replies = viewModel.replies,
onRemove = viewModel::removeReply,
onToggleMention = viewModel::toggleReplyMentionFor
)
}
AnimatedVisibility(visible = viewModel.attachments.isNotEmpty()) {
AttachmentManager(
attachments = viewModel.attachments,
uploading = viewModel.sendingMessage,
onRemove = viewModel::removeAttachment
)
}
MessageField(
messageContent = viewModel.messageContent,
onMessageContentChange = viewModel::setMessageContent,
onSendMessage = viewModel::sendPendingMessage,
onAddAttachment = {
pickFileLauncher.launch(arrayOf("*/*"))
},
channelType = channel.channelType!!,
channelName = channel.name ?: channel.id!!,
forceSendButton = viewModel.attachments.isNotEmpty(),
disabled = viewModel.attachments.isNotEmpty() && viewModel.sendingMessage
)
}
AnimatedVisibility(visible = viewModel.attachments.isNotEmpty()) {
AttachmentManager(
attachments = viewModel.attachments,
uploading = viewModel.sendingMessage,
onRemove = viewModel::removeAttachment
)
}
MessageField(
messageContent = viewModel.messageContent,
onMessageContentChange = viewModel::setMessageContent,
onSendMessage = viewModel::sendPendingMessage,
onAddAttachment = {
pickFileLauncher.launch(arrayOf("*/*"))
},
channelType = channel.channelType!!,
channelName = channel.name ?: channel.id!!,
forceSendButton = viewModel.attachments.isNotEmpty(),
disabled = viewModel.attachments.isNotEmpty() && viewModel.sendingMessage
)
}
}