How to send Giphy image to message list with customized button? #111
kai-leeee
announced in
1. Chatting in a channel
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Guide & Snippet
1.
To add a customized button to the input view, you need to change
messageInputView. Specifically, you need to insert a new view ininputHStackViewand modify the icon position by adjusting the index ininsertArrangedSubview.To handle the tap event from the
giphyButton, define a custom delegate. You can relay the event externally by executing a delegate method inside the button's action.2
Now, create the
CustomGroupChannelModuleInputComponentclass with the custom input view,LeftButtonAddedMessageInputView. All we need to do is switching itsmessageInputViewto ourLeftButtonAddedMessageInputViewinstance whilesetupViewis in progress.Don't forget to implement
CustomMessageInputViewDelegateto monitor tap events, and also declareCustomGroupChannelModuleInputDelegateto further relay these events outside of the component, to the view controller in this example.3
For the next step, implement the
CustomGroupChannelModuleInputDelegatewithin yourCustomGroupChannelViewController. This will allow you to monitor tap events on thegiphyButton.If you have obtained the URL of a GIF from your codes, use the
viewModel'ssendFileMessagemethod to transmit the GIF file. You just need to pass the URL to theFileMessageCreateParamsconstructor in thefileURLto send a message.4
Lastly, you need to update
SBUModuleSetandSBUViewControllerSetlike below:References
Beta Was this translation helpful? Give feedback.
All reactions