-
Notifications
You must be signed in to change notification settings - Fork 211
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
Add custom location attachment to the Demo App #2947
Conversation
Generated by 🚫 Danger |
37623ba
to
5e4220c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff @nuno-vieira 👏 Just added few small things, otherwise this is a very nice improvement.
DemoApp/StreamChat/Components/CustomAttachments/DemoChatMessageListVC.swift
Show resolved
Hide resolved
Sources/StreamChatUI/ChatMessageList/Attachments/MixedAttachmentViewInjector.swift
Show resolved
Hide resolved
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 47 New issues |
This reverts commit a26f3c2.
🔗 Issue Links
Resolves https://github.com/GetStream/ios-issues-tracking/issues/684
🎯 Goal
Adds a custom attachment example to the Demo App. This will make it easier to test features for custom attachments. It is also helpful for customers to see how a custom attachment can be implemented. In the future, we should update the documentation to use this example instead of the dummy "workout" example we currently have.
While working on this, I realised it was not easy for custom attachments to support the mixed attachments rendering, so I made some improvements to make it easier.
📝 Summary
🛠 Implementation
Adds a custom location attachment to the Demo App
For this attachment, we are just saving the coordinates of a location. Then, the app is responsible for showing that location on a map. For better performance, an image snapshot of the map is generated in the message list, and only when tapping the snapshot we open the actual map. We could also save the generated snapshots upload it to the CDN, and save them in the message. This way, Web could use the generated snapshots from iOS or Android, but this is out of scope right now, especially for a Demo App example.
Makes it easier for custom attachments to support mixed attachment rendering
Previously, in order to support mixed attachments for our custom attachment was quite complex and not intuitive. It was required to override the
MixedAttachmentInjector
, override theinjectors
property, make sure we did it lazily and make sure we defined the correct order.Now, we just need to register our custom attachment to the
MixedAttachmentInjector
registry, and then when overriding the Catalog, make sure to return theMixedAttachmentInjector
when there are multiples attachment types.Example:
Fixes deleted messages, always showing custom attachments
We returned
nil
for the attachment injector whenever the message was deleted. But this was done in the incorrect place. Whenever there was a customization, this logic was overriden.🎨 Showcase
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-12-21.at.02.34.54.mov
🧪 Manual Testing Notes
Precondition
Location Attachments should be enabled in the Demo App Configuration.
Adds a custom location attachment to the Demo App
Please check the video above
Makes it easier for custom attachments to support mixed attachments rendering
Fixes deleted messages, always showing custom attachments
☑️ Contributor Checklist