using fullscreen preview when sending image
This commit is contained in:
parent
f668a1b8ea
commit
ac16306b1a
|
@ -69,15 +69,16 @@ internal fun MessengerScreen(roomId: RoomId, attachments: List<MessageAttachment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Room(state.roomState)
|
|
||||||
when (state.composerState) {
|
when (state.composerState) {
|
||||||
is ComposerState.Text -> {
|
is ComposerState.Text -> {
|
||||||
|
Room(state.roomState)
|
||||||
TextComposer(
|
TextComposer(
|
||||||
state.composerState,
|
state.composerState,
|
||||||
onTextChange = { viewModel.post(MessengerAction.ComposerTextUpdate(it)) },
|
onTextChange = { viewModel.post(MessengerAction.ComposerTextUpdate(it)) },
|
||||||
onSend = { viewModel.post(MessengerAction.ComposerSendText) },
|
onSend = { viewModel.post(MessengerAction.ComposerSendText) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ComposerState.Attachments -> {
|
is ComposerState.Attachments -> {
|
||||||
AttachmentComposer(
|
AttachmentComposer(
|
||||||
state.composerState,
|
state.composerState,
|
||||||
|
@ -131,6 +132,7 @@ private fun ColumnScope.Room(roomStateLce: Lce<MessengerState>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is Lce.Error -> {
|
is Lce.Error -> {
|
||||||
Box(contentAlignment = Alignment.Center) {
|
Box(contentAlignment = Alignment.Center) {
|
||||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
|
@ -210,6 +212,7 @@ private fun <T : RoomEvent> LazyItemScope.AlignedBubble(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
false -> {
|
false -> {
|
||||||
Box(modifier = Modifier.fillParentMaxWidth(0.95f), contentAlignment = Alignment.TopStart) {
|
Box(modifier = Modifier.fillParentMaxWidth(0.95f), contentAlignment = Alignment.TopStart) {
|
||||||
Bubble(
|
Bubble(
|
||||||
|
@ -320,9 +323,11 @@ private fun Bubble(
|
||||||
wasPreviousMessageSameSender -> {
|
wasPreviousMessageSameSender -> {
|
||||||
Spacer(modifier = Modifier.width(displayImageSize))
|
Spacer(modifier = Modifier.width(displayImageSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
message.author.avatarUrl == null -> {
|
message.author.avatarUrl == null -> {
|
||||||
MissingAvatarIcon(message.author.displayName ?: message.author.id.value, displayImageSize)
|
MissingAvatarIcon(message.author.displayName ?: message.author.id.value, displayImageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
MessengerUrlIcon(message.author.avatarUrl!!.value, displayImageSize)
|
MessengerUrlIcon(message.author.avatarUrl!!.value, displayImageSize)
|
||||||
}
|
}
|
||||||
|
@ -423,6 +428,7 @@ private fun ReplyBubbleContent(content: BubbleContent<RoomEvent.Reply>) {
|
||||||
textAlign = TextAlign.Start,
|
textAlign = TextAlign.Start,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is RoomEvent.Image -> {
|
is RoomEvent.Image -> {
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
Image(
|
Image(
|
||||||
|
@ -464,6 +470,7 @@ private fun ReplyBubbleContent(content: BubbleContent<RoomEvent.Reply>) {
|
||||||
textAlign = TextAlign.Start,
|
textAlign = TextAlign.Start,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is RoomEvent.Image -> {
|
is RoomEvent.Image -> {
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
Image(
|
Image(
|
||||||
|
@ -507,6 +514,7 @@ private fun RowScope.SendStatus(message: RoomEvent) {
|
||||||
MessageMeta.FromServer -> {
|
MessageMeta.FromServer -> {
|
||||||
// last message is self
|
// last message is self
|
||||||
}
|
}
|
||||||
|
|
||||||
is MessageMeta.LocalEcho -> {
|
is MessageMeta.LocalEcho -> {
|
||||||
when (val state = meta.state) {
|
when (val state = meta.state) {
|
||||||
MessageMeta.LocalEcho.State.Sending, MessageMeta.LocalEcho.State.Sent -> {
|
MessageMeta.LocalEcho.State.Sending, MessageMeta.LocalEcho.State.Sent -> {
|
||||||
|
@ -523,6 +531,7 @@ private fun RowScope.SendStatus(message: RoomEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is MessageMeta.LocalEcho.State.Error -> {
|
is MessageMeta.LocalEcho.State.Error -> {
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
Box(
|
Box(
|
||||||
|
@ -603,62 +612,33 @@ private fun TextComposer(state: ComposerState.Text, onTextChange: (String) -> Un
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AttachmentComposer(state: ComposerState.Attachments, onSend: () -> Unit, onCancel: () -> Unit) {
|
private fun AttachmentComposer(state: ComposerState.Attachments, onSend: () -> Unit, onCancel: () -> Unit) {
|
||||||
Row(
|
Box(modifier = Modifier.fillMaxSize()) {
|
||||||
Modifier
|
val context = LocalContext.current
|
||||||
.fillMaxWidth()
|
Image(
|
||||||
.padding(horizontal = 12.dp, vertical = 8.dp)
|
modifier = Modifier.fillMaxHeight().wrapContentWidth().align(Alignment.Center),
|
||||||
.fillMaxWidth()
|
painter = rememberAsyncImagePainter(
|
||||||
.height(IntrinsicSize.Min), verticalAlignment = Alignment.Bottom
|
model = ImageRequest.Builder(context)
|
||||||
) {
|
.data(state.values.first().uri.value.toUri())
|
||||||
Box(
|
.build()
|
||||||
modifier = Modifier
|
),
|
||||||
.align(Alignment.Bottom)
|
contentDescription = null,
|
||||||
.weight(1f)
|
)
|
||||||
.fillMaxHeight()
|
|
||||||
.background(MaterialTheme.colors.onSurface.copy(alpha = TextFieldDefaults.BackgroundOpacity), RoundedCornerShape(24.dp)),
|
Box(Modifier.align(Alignment.BottomEnd).padding(12.dp)) {
|
||||||
contentAlignment = Alignment.TopStart,
|
IconButton(
|
||||||
) {
|
enabled = true,
|
||||||
Box(Modifier.padding(14.dp)) {
|
modifier = Modifier
|
||||||
val context = LocalContext.current
|
.clip(CircleShape)
|
||||||
Image(
|
.background(MaterialTheme.colors.primary),
|
||||||
modifier = Modifier.size(50.dp, 50.dp),
|
onClick = onSend,
|
||||||
painter = rememberAsyncImagePainter(
|
) {
|
||||||
model = ImageRequest.Builder(context)
|
Icon(
|
||||||
.data(state.values.first().uri.value.toUri())
|
imageVector = Icons.Filled.Send,
|
||||||
.build()
|
contentDescription = "",
|
||||||
),
|
tint = MaterialTheme.colors.onPrimary,
|
||||||
contentDescription = null,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.width(6.dp))
|
|
||||||
var size by remember { mutableStateOf(IntSize(0, 0)) }
|
|
||||||
IconButton(
|
|
||||||
enabled = true,
|
|
||||||
modifier = Modifier
|
|
||||||
.clip(CircleShape)
|
|
||||||
.background(MaterialTheme.colors.primary)
|
|
||||||
.run {
|
|
||||||
if (size.height == 0 || size.width == 0) {
|
|
||||||
this
|
|
||||||
.onSizeChanged {
|
|
||||||
size = it
|
|
||||||
}
|
|
||||||
.fillMaxHeight()
|
|
||||||
} else {
|
|
||||||
with(LocalDensity.current) {
|
|
||||||
size(size.width.toDp(), size.height.toDp())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onClick = onSend,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.Send,
|
|
||||||
contentDescription = "",
|
|
||||||
tint = MaterialTheme.colors.onPrimary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue