forked from melod1n/fast-messenger
feat: Display stickers in messages (#200)
This commit introduces the ability to display stickers within message bubbles.
Key changes:
- `Attachments.kt`: Added handling for `AttachmentType.STICKER`. If an attachment type is unsupported, a placeholder text is now displayed.
- `Sticker.kt`: New composable created to render `VkStickerDomain` using `AsyncImage`.
- `MessageBubble.kt`:
- Adjusted background alpha for sticker messages to make the bubble transparent.
- Minor refactoring of `minDateContainerWidth` and `dateContainerWidth` initialization.
- `VkStickerDomain.kt`: Added `getUrl()` function to construct sticker image URLs, with options for specifying width and background.
This commit is contained in:
@@ -21,4 +21,12 @@ data class VkStickerDomain(
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
fun getUrl(width: Int = 256, withBackground: Boolean = false): String? = when {
|
||||
withBackground && backgroundImages != null -> {
|
||||
backgroundImages.firstOrNull { it.width >= width }?.url
|
||||
}
|
||||
images != null -> images.firstOrNull { it.width >= width }?.url
|
||||
else -> "https://vk.com/sticker/1-${id}-${width}b"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user