Skip to content

Feat: Message actions customisation [CRNS-438] - #941

Merged
vishalnarkhede merged 11 commits into
v4.0.0from
khushal87-message-actions
Oct 25, 2021
Merged

vishalnarkhede merged 11 commits into
v4.0.0from
khushal87-message-actions

Conversation

@khushal87

@khushal87 khushal87 commented Oct 20, 2021 •

Copy link
Copy Markdown
Contributor

🎯 Goal

This PR introduces a message action customization feature which allows adding MessageActionList and MessageActionListItem. 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 MessageActionList and MessageActionListItem. 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 say Edit 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.tsx and 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
Before After
img img
Android
Before After
img img

🧪 Testing

Explain how this change can be tested (or why it can't be tested)

madsroskar and others added 4 commits October 7, 2021 15:00
I have kept the `padding` property on `Thene`, and added a `container`
property alonside it for more general customizations.

This fixes #801

@madsroskar madsroskar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread examples/SampleApp/App.tsx Outdated
);
};

const MessageActionListItemComponent = ({ actionType, ...rest }: MessageActionListItem) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just to add the animation to the two specific action types?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🙂

Comment thread examples/SampleApp/App.tsx Resolved
Comment thread examples/SampleApp/App.tsx Outdated
Comment on lines +112 to +133
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} />;
}
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment thread examples/SampleApp/App.tsx Resolved
feat: message actions customisation

feat: message actions customisation

feat: message actions customisation
@khushal87
khushal87 force-pushed the khushal87-message-actions branch from ae699dd to f863a9e Compare October 21, 2021 10:32
@khushal87
khushal87 marked this pull request as ready for review October 21, 2021 10:40
@GetStream GetStream deleted a comment from madsroskar Oct 21, 2021
@GetStream GetStream deleted a comment from madsroskar Oct 21, 2021
@GetStream GetStream deleted a comment from madsroskar Oct 21, 2021
threadReply,
}: {
blockUser: MessageAction | null;
blockUser: MessageActionType | null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null can be removed from here as well I guess?

@vishalnarkhede vishalnarkhede left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just one small cleanup comment.

@vishalnarkhede vishalnarkhede changed the title Feat: Message actions customisation Feat: Message actions customisation [CRNS-438] Oct 25, 2021
@vishalnarkhede
vishalnarkhede merged commit 94c20f8 into v4.0.0 Oct 25, 2021
@vishalnarkhede
vishalnarkhede deleted the khushal87-message-actions branch October 25, 2021 11:59
@vishalnarkhede vishalnarkhede linked an issue Nov 2, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't add custom MessageOverlay

3 participants