Repository navigation
Feat: Message actions customisation [CRNS-438] - #941
Conversation
I have kept the `padding` property on `Thene`, and added a `container` property alonside it for more general customizations. This fixes #801
madsroskar
left a comment
There was a problem hiding this comment.
Overall looks good, I think. Added a bunch of comments, though not all are a direct result of your new changes necessarily, so could be turned into issues/tickets or something if it doesn't make sense for the PR (though I personally don't think it's a bad thing to consider making the changes in the context of this PR)
Could you also add some documentation for this, and a guide to customize the MessageActionList/MessageActionListItem components? (I'm guessing you have this on your list already, but mentioning just in case :))
If you'd like, we could also pair code a bit regarding a bunch of my comments, and see what we figure out to make sense or not together, or something too. Just ping me if you do : )
This is gonna be a good change to the customizability of the MessageActionList and MessageActionListItems I think :D
| ); | ||
| }; | ||
|
|
||
| const MessageActionListItemComponent = ({ actionType, ...rest }: MessageActionListItem) => { |
There was a problem hiding this comment.
Could the name of this one be made a bit more specific? The Component suffix doesn't tell me much about why we need this wrapper
There was a problem hiding this comment.
Is it just to add the animation to the two specific action types?
There was a problem hiding this comment.
It is just a Component that we pass as a value to the MessageActionListItem prop in the SampleApp. I can't think of anything other than this thing. Suggestions are welcome 🙂
| const MessageActionListItemComponent = ({ actionType, ...rest }: MessageActionListItem) => { | ||
| const { onTap } = useMessageActionAnimation({ action: rest.action }); | ||
| if (actionType === 'pinMessage') { | ||
| return ( | ||
| <TapGestureHandler onHandlerStateChange={onTap}> | ||
| <Animated.View> | ||
| <Text>{actionType}</Text> | ||
| </Animated.View> | ||
| </TapGestureHandler> | ||
| ); | ||
| } else if (actionType === 'muteUser') { | ||
| return ( | ||
| <TapGestureHandler onHandlerStateChange={onTap}> | ||
| <Animated.View> | ||
| <Text>{actionType}</Text> | ||
| </Animated.View> | ||
| </TapGestureHandler> | ||
| ); | ||
| } else { | ||
| return <MessageActionListItem {...rest} />; | ||
| } | ||
| }; |
There was a problem hiding this comment.
| const MessageActionListItemComponent = ({ actionType, ...rest }: MessageActionListItem) => { | |
| const { onTap } = useMessageActionAnimation({ action: rest.action }); | |
| if (actionType === 'pinMessage') { | |
| return ( | |
| <TapGestureHandler onHandlerStateChange={onTap}> | |
| <Animated.View> | |
| <Text>{actionType}</Text> | |
| </Animated.View> | |
| </TapGestureHandler> | |
| ); | |
| } else if (actionType === 'muteUser') { | |
| return ( | |
| <TapGestureHandler onHandlerStateChange={onTap}> | |
| <Animated.View> | |
| <Text>{actionType}</Text> | |
| </Animated.View> | |
| </TapGestureHandler> | |
| ); | |
| } else { | |
| return <MessageActionListItem {...rest} />; | |
| } | |
| }; | |
| const MessageActionListItemComponent = (props: MessageActionListItem) => { | |
| const { actionType } = props; | |
| const animatedActions = ['pinMessage', 'muteUser']; | |
| return animatedActions.includes(actionType) ? | |
| <AnimatedMessageActionListItem {...props}> : <MessageActionListItem {...props} />; | |
| }; | |
| const AnimatedMessageActionListItem = (props: MessageActionListItem) => { | |
| const { action, actionType } = props; | |
| const { onTap } = useMessageActionAnimation({ action }); | |
| return ( | |
| <TapGestureHandler onHandlerStateChange={onTap}> | |
| <Animated.View> | |
| <Text>{actionType}</Text> | |
| </Animated.View> | |
| </TapGestureHandler> | |
| ); | |
| } |
Changed it around a bit to think it out, haven't tested this suggestion, but seems a bit more skimmable to me personally
feat: message actions customisation feat: message actions customisation feat: message actions customisation
ae699dd to
f863a9e
Compare
| threadReply, | ||
| }: { | ||
| blockUser: MessageAction | null; | ||
| blockUser: MessageActionType | null; |
There was a problem hiding this comment.
null can be removed from here as well I guess?
vishalnarkhede
left a comment
There was a problem hiding this comment.
LGTM. Just one small cleanup comment.
🎯 Goal
This PR introduces a message action customization feature which allows adding
MessageActionListandMessageActionListItem. This allows full Message Action overlay modal customization or one of the message actions only.🛠 Implementation details
This is done to provide customization to the users. I have introduced two new components props
MessageActionListandMessageActionListItem. The first one allows a whole new implementation of the message action list and performs an action according to what the user defines. This provides full customizability. The second one allows customizing an individual Message Action list item let us sayEdit message. Users can customize the UI of the item as well as define its own action of what the item would perform on click.This PR also simplifies the
Message.tsxand made it simpler by introducing two new hooks:useMessageActions.tsx- Takes in essential arguments and returns the MessageAction object.useMessageActionHandlers.ts- Takes the essential arguments and returns the MessageAction handlers for implementing the logic of the action.They provide the default objects and function of the message action and we can use it in the component and import the objects as well as functions. This will also be helpful to the users as they can use the default implementation of actions and use it for their own purpose if needed.
PS - Documentation will be added through a different PR as discussed with @vishalnarkhede
🎨 UI Changes
_ Add relevant screenshots_
iOS
Android
🧪 Testing
Explain how this change can be tested (or why it can't be tested)