Reply Box View
Overview
The ReplyBoxView
component displays a reply interface for responding to specific messages in a chatroom. It allows users to view the message they are replying to and includes a close button to dismiss the reply box. The component integrates seamlessly with state management and provides customization options.
UI Components
The ReplyBoxView
includes the following elements:
- Reply Box: Displays the message being replied to, utilizing the
ReplyBox
component. - Close Button: A clickable button to dismiss the reply box, with customizable behavior.
Props
Property | Type | Description | Optional |
---|---|---|---|
handleReplyBoxCloseProp | Function | Custom callback function triggered when the close button is pressed. If not provided, the default behavior dispatches actions to reset the reply state. | ✔️ |
Features
Dynamic Reply Box:
- Displays the message being replied to, with additional context (e.g., chatroom name).
Customizable Close Action:
- Supports a custom callback for closing the reply box or defaults to resetting the reply state.
Seamless State Management:
- Uses context (
InputBoxContext
) and Redux dispatch for managing reply states (isReply
andreplyMessage
).
- Uses context (
Usage Example
To Customise Callbacks
Define a custom method like handleReplyBoxClose
and pass it to the handleReplyBoxCloseProp
of the <ReplyBoxView/>
component.
import React from "react";
import { View } from "react-native";
import {
AddFilesView,
AddMoreFilesView,
EditBox,
InputBoxView,
InputWrapper,
InputWrapperLeftSection,
LinkPreviewInputView,
ReplyBoxView,
SelectFilesModal,
SendDMRequestModal,
TextInputWrapper,
useInputBoxContext,
VoiceNoteRecordToast,
UserTaggingList,
RecordSendInputFabView,
} from "@likeminds.community/chat-rn-core";
const CustomMessageInputBox = () => {
const { hideDMSentAlert, message, DMSentAlertModalVisible, onSend } =
useInputBoxContext();
// Customize the reply box close behavior, else simply avoid passing it as a prop to the ReplyBoxView component
const handleReplyBoxClose = () => {
console.log("Reply box closed");
};
return (
<View>
<VoiceNoteRecordToast />
<InputWrapper>
<InputWrapperLeftSection>
<UserTaggingList />
{/* Add ReplyBoxView component like this*/}
<ReplyBoxView handleReplyBoxCloseProp={handleReplyBoxClose} />
<LinkPreviewInputView />
<EditBox />
<TextInputWrapper>
<AddMoreFilesView />
<InputBoxView />
<AddFilesView />
</TextInputWrapper>
</InputWrapperLeftSection>
<RecordSendInputFabView />
</InputWrapper>
<SelectFilesModal />
<SendDMRequestModal
hideDMSentAlert={hideDMSentAlert}
DMSentAlertModalVisible={DMSentAlertModalVisible}
onSend={onSend}
message={message}
/>
</View>
);
};
export default CustomMessageInputBox;
Customise <ReplyBoxView />
UI Component
- Create a new component
CustomReplyBoxView
, referencing theReplyBoxView
component. - Perform your UI customizations in the new component.
import React from "react";
import { View } from "react-native";
import {
AddFilesView,
AddMoreFilesView,
EditBox,
InputBoxView,
InputWrapper,
InputWrapperLeftSection,
LinkPreviewInputView,
ReplyBoxView,
SelectFilesModal,
SendDMRequestModal,
TextInputWrapper,
useInputBoxContext,
VoiceNoteRecordToast,
UserTaggingList,
RecordSendInputFabView,
} from "@likeminds.community/chat-rn-core";
import CustomReplyBoxView from "<path_to_custom_reply_box_view_component>";
const CustomMessageInputBox = () => {
const { hideDMSentAlert, message, DMSentAlertModalVisible, onSend } =
useInputBoxContext();
return (
<View>
<VoiceNoteRecordToast />
<InputWrapper>
<InputWrapperLeftSection>
<UserTaggingList />
{/* Add CustomReplyBoxView component like this*/}
<CustomReplyBoxView />
<LinkPreviewInputView />
<EditBox />
<TextInputWrapper>
<AddMoreFilesView />
<InputBoxView />
<AddFilesView />
</TextInputWrapper>
</InputWrapperLeftSection>
<RecordSendInputFabView />
</InputWrapper>
<SelectFilesModal />
<SendDMRequestModal
hideDMSentAlert={hideDMSentAlert}
DMSentAlertModalVisible={DMSentAlertModalVisible}
onSend={onSend}
message={message}
/>
</View>
);
};
export default CustomMessageInputBox;
- Use the
CustomMessageInputBox
component as a child of theMessageInput
component in the relevant screens: