Skip to content

Commit cf28cf2

Browse files
CRNS-54: Adding props for MessageTextContainer
1 parent 6cbee9f commit cf28cf2

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

src/components/DateSeparator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export const DateSeparator = themed(
4848
class DateSeparator extends React.PureComponent {
4949
static propTypes = {
5050
message: PropTypes.object.isRequired,
51+
/**
52+
* Formatter function for date object.
53+
*
54+
* @param date Date object of message
55+
* @returns string
56+
*/
5157
formatDate: PropTypes.func,
5258
};
5359

src/components/MessageSimple/MessageTextContainer.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import styled, { withTheme } from '@stream-io/styled-components';
33

44
import { renderText, capitalize } from '../../utils';
5+
import PropTypes from 'prop-types';
56

67
const TextContainer = styled.View`
78
border-bottom-left-radius: ${({ theme, groupStyle }) =>
@@ -76,3 +77,25 @@ export const MessageTextContainer = withTheme((props) => {
7677
</React.Fragment>
7778
);
7879
});
80+
81+
MessageTextContainer.propTypes = {
82+
/** Current [message object](https://getstream.io/chat/docs/#message_format) */
83+
message: PropTypes.object,
84+
/**
85+
* Position of message in group - top, bottom, middle, single.
86+
*
87+
* Message group is a group of consecutive messages from same user. groupStyles can be used to style message as per their position in message group
88+
* e.g., user avatar (to which message belongs to) is only showed for last (bottom) message in group.
89+
*/
90+
groupStyles: PropTypes.array,
91+
/**
92+
* Returns true if message (param) belongs to current user, else false
93+
*
94+
* @param message
95+
* */
96+
isMyMessage: PropTypes.func,
97+
/** Custom UI component for message text */
98+
MessageText: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
99+
/** Complete theme object. Its a [defaultTheme](https://github.com/GetStream/stream-chat-react-native/blob/master/src/styles/theme.js#L22) merged with customized theme provided as prop to Chat component */
100+
theme: PropTypes.object,
101+
};

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export {
99
withSuggestionsContext,
1010
KeyboardContext,
1111
withKeyboardContext,
12+
MessageContentContext,
13+
withMessageContentContext,
1214
} from './context.js';
1315

1416
export { MESSAGE_ACTIONS, renderText } from './utils';

types/index.d.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ export interface KeyboardContextValue {
110110
dismissKeyboard?(): void;
111111
}
112112

113+
export interface MessageContentContext
114+
extends React.Context<MessageContentContextValue> {}
115+
export interface MessageContentContextValue {
116+
onLongPress?: (event: GestureResponderEvent) => void;
117+
}
118+
113119
//================================================================================================
114120
//================================================================================================
115121
//
@@ -202,7 +208,7 @@ export interface MessageInputProps
202208
AttachmentFileIcon?: React.ElementType<FileIconUIComponentProps>;
203209
}
204210

205-
export interface AttachmentProps {
211+
export interface AttachmentProps extends MessageContentContextValue {
206212
/** The attachment to render */
207213
attachment: Client.Attachment;
208214
/**
@@ -436,6 +442,7 @@ export interface MessageUIComponentProps
436442
* */
437443
forceAlign: string | boolean;
438444
showMessageStatus: boolean;
445+
/** Custom UI component for message text */
439446
MessageText?: React.ElementType<MessageTextProps>;
440447
/** https://github.com/beefe/react-native-actionsheet/blob/master/lib/styles.js */
441448
actionSheetStyles?: object;
@@ -489,6 +496,28 @@ export interface MessageContentUIComponentProps
489496
alignment: string;
490497
}
491498

499+
export interface MessageTextContainerUIComponentProps {
500+
/** Current [message object](https://getstream.io/chat/docs/#message_format) */
501+
message: Client.MessageResponse;
502+
/**
503+
* Position of message in group - top, bottom, middle, single.
504+
*
505+
* Message group is a group of consecutive messages from same user. groupStyles can be used to style message as per their position in message group
506+
* e.g., user avatar (to which message belongs to) is only showed for last (bottom) message in group.
507+
*/
508+
groupStyles: [];
509+
/**
510+
* Returns true if message (param) belongs to current user, else false
511+
*
512+
* @param message
513+
* */
514+
isMyMessage?(message: Client.MessageResponse): boolean;
515+
/** Custom UI component for message text */
516+
MessageText?: React.ElementType<MessageTextProps>;
517+
/** Complete theme object. Its a [defaultTheme](https://github.com/GetStream/stream-chat-react-native/blob/master/src/styles/theme.js#L22) merged with customized theme provided as prop to Chat component */
518+
theme?: object;
519+
}
520+
492521
export interface MessageTextProps {
493522
message: Client.MessageResponse;
494523
}
@@ -791,6 +820,11 @@ export class MessageAvatar extends React.PureComponent<
791820
any
792821
> {}
793822

823+
export class MessageTextContainer extends React.PureComponent<
824+
MessageTextContainerUIComponentProps,
825+
any
826+
> {}
827+
794828
export class ChannelList extends React.PureComponent<ChannelListProps, any> {}
795829

796830
export class Thread extends React.PureComponent<ThreadProps, any> {}

0 commit comments

Comments
 (0)