Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: location replies (WPB-5480) #2534

Merged
merged 12 commits into from
Dec 19, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class RegularMessageMapper @Inject constructor(
}

is MessageContent.QuotedMessageDetails.Text -> UIQuotedMessage.UIQuotedData.Text(quotedContent.value)
is MessageContent.QuotedMessageDetails.Location -> UIQuotedMessage.UIQuotedData.Location(quotedContent.locationName.orEmpty())
MessageContent.QuotedMessageDetails.Deleted -> UIQuotedMessage.UIQuotedData.Deleted
MessageContent.QuotedMessageDetails.Invalid -> UIQuotedMessage.UIQuotedData.Invalid
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ internal fun QuotedMessage(
style = style,
startContent = startContent
)

is UIQuotedMessage.UIQuotedData.Location -> QuotedLocation(
senderName = messageData.senderName,
originalDateTimeText = messageData.originalMessageDateDescription,
locationName = quotedContent.locationName,
modifier = modifier,
style = style,
startContent = startContent
)
}
}

Expand Down Expand Up @@ -406,7 +415,11 @@ private fun AutosizeContainer(
val imageDimension = Dimension.value(dimensions().spacing56x)
// ConstraintLayout is used to measure the text content and then
// resize the image to match the height of the text
ConstraintLayout(modifier = modifier.fillMaxWidth().padding(dimensions().spacing8x)) {
ConstraintLayout(
modifier = modifier
.fillMaxWidth()
.padding(dimensions().spacing8x)
) {
val (leftSide, rightSide) = createRefs()
Column(
verticalArrangement = Arrangement.spacedBy(4.dp, Alignment.Top),
Expand All @@ -431,7 +444,8 @@ private fun AutosizeContainer(
end.linkTo(parent.end)
width = imageDimension
height = Dimension.fillToConstraints
}.clip(RoundedCornerShape(dimensions().spacing8x))
}
.clip(RoundedCornerShape(dimensions().spacing8x))
.border(
width = 1.dp,
color = MaterialTheme.wireColorScheme.outline,
Expand Down Expand Up @@ -514,3 +528,29 @@ private fun QuotedGenericAsset(
}, footerContent = { QuotedMessageOriginalDate(originalDateTimeText) }
)
}

@Composable
private fun QuotedLocation(
senderName: UIText,
originalDateTimeText: UIText,
locationName: String,
style: QuotedMessageStyle,
startContent: @Composable () -> Unit = {},
modifier: Modifier
) {
QuotedMessageContent(
senderName = senderName.asString(), style = style, modifier = modifier, centerContent = {
MainContentText(locationName)
}, startContent = {
startContent()
}, endContent = {
Icon(
painter = painterResource(R.drawable.ic_location),
contentDescription = null,
modifier = modifier
.size(dimensions().spacing24x),
tint = colorsScheme().secondaryText
)
}, footerContent = { QuotedMessageOriginalDate(originalDateTimeText) }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@
val displayable: ImageAsset.PrivateAsset
) : Content

data class Location(val locationName: String) : Content

Check warning on line 595 in app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/model/UIMessage.kt#L595

Added line #L595 was not covered by tests

object AudioMessage : Content

object Deleted : Content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
)
}

is UIMessageContent.Location -> with(messageContent) {
UIQuotedMessage.UIQuotedData.Location(locationName = name)

Check warning on line 101 in app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/state/MessageCompositionHolder.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/state/MessageCompositionHolder.kt#L101

Added line #L101 was not covered by tests
}

else -> {
appLogger.w("Attempting to reply to an unsupported message type of content = $messageContent")
null
Expand Down
Loading