mattermost / mattermost-mobile

Next generation iOS and Android apps for Mattermost in React Native
https://about.mattermost.com/
Apache License 2.0
2.26k stars 1.37k forks source link

fix: fixed image overflow in message attachments #8361

Open fxnm opened 5 days ago

fxnm commented 5 days ago

Summary

Fixed the overflow if a message attachment is wider than the Viewport. (https://developers.mattermost.com/integrate/reference/message-attachments/#images) This is done by modifying the getViewPortWidth and introducing a new VIEWPORT_IMAGE_ATTACHMENT_OFFSET. The value of it is calculated with the padding of the MessageAttachment component (2 * 12) + the padding of the AttachmentImage component (2,5 + 5) => 31,5

https://github.com/mattermost/mattermost-mobile/blob/9b450cf68b60b47ebcb4ca84af9cc07293397567/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx#L42

https://github.com/mattermost/mattermost-mobile/blob/9b450cf68b60b47ebcb4ca84af9cc07293397567/app/components/post_list/post/body/content/message_attachments/attachment_image/index.tsx#L26-L28

Ticket Link

None

Checklist

Device Information

This PR was tested on:

Screenshots

Example Attachment

"attachments": [
        {
            "fallback": "test",
            "color": "#FF8000",
            "image_url": "https://raw.githubusercontent.com/mattermost/mattermost/refs/heads/master/server/tests/orientation_test_1.jpeg"
        }
    ]
Before After
Screenshot_20241119-130413_Mattermost Beta Screenshot_20241119-130205_Mattermost Beta

Release Note

Fixed image overflow when using message attachments.
mattermost-build commented 5 days ago

Hello @fxnm,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

fxnm commented 5 days ago

I also would recommend, that the padding of the AttachmentImage should be unified for a even spaced border around the image component.

lukasnacht commented 3 days ago

Please review, this is a high priority for one of our paying customers