react-native-gifted-chat 2.6.5 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -17
- package/lib/Actions.d.ts +0 -11
- package/lib/Actions.js +2 -14
- package/lib/Actions.js.map +1 -1
- package/lib/Avatar.d.ts +1 -23
- package/lib/Avatar.js +32 -40
- package/lib/Avatar.js.map +1 -1
- package/lib/Bubble/index.d.ts +30 -0
- package/lib/{Bubble.js → Bubble/index.js} +31 -181
- package/lib/Bubble/index.js.map +1 -0
- package/lib/Bubble/styles.d.ts +69 -0
- package/lib/Bubble/styles.js +72 -0
- package/lib/Bubble/styles.js.map +1 -0
- package/lib/Bubble/types.d.ts +47 -0
- package/lib/Bubble/types.js +2 -0
- package/lib/Bubble/types.js.map +1 -0
- package/lib/Composer.d.ts +0 -17
- package/lib/Composer.js +3 -18
- package/lib/Composer.js.map +1 -1
- package/lib/Constant.d.ts +1 -1
- package/lib/Constant.js +1 -1
- package/lib/Constant.js.map +1 -1
- package/lib/Day/index.d.ts +4 -0
- package/lib/Day/index.js +39 -0
- package/lib/Day/index.js.map +1 -0
- package/lib/Day/styles.d.ts +20 -0
- package/lib/Day/styles.js +22 -0
- package/lib/Day/styles.js.map +1 -0
- package/lib/Day/types.d.ts +9 -0
- package/lib/Day/types.js +2 -0
- package/lib/Day/types.js.map +1 -0
- package/lib/GiftedAvatar.d.ts +1 -11
- package/lib/GiftedAvatar.js +26 -33
- package/lib/GiftedAvatar.js.map +1 -1
- package/lib/GiftedChat/index.d.ts +26 -0
- package/lib/{GiftedChat.js → GiftedChat/index.js} +46 -52
- package/lib/GiftedChat/index.js.map +1 -0
- package/lib/GiftedChat/styles.d.ts +6 -0
- package/lib/GiftedChat/styles.js +7 -0
- package/lib/GiftedChat/styles.js.map +1 -0
- package/lib/{GiftedChat.d.ts → GiftedChat/types.d.ts} +28 -38
- package/lib/GiftedChat/types.js +2 -0
- package/lib/GiftedChat/types.js.map +1 -0
- package/lib/InputToolbar.d.ts +1 -14
- package/lib/InputToolbar.js +0 -12
- package/lib/InputToolbar.js.map +1 -1
- package/lib/LoadEarlier.d.ts +0 -14
- package/lib/LoadEarlier.js +2 -16
- package/lib/LoadEarlier.js.map +1 -1
- package/lib/Message/index.d.ts +6 -0
- package/lib/Message/index.js +85 -0
- package/lib/Message/index.js.map +1 -0
- package/lib/Message/styles.d.ts +21 -0
- package/lib/Message/styles.js +22 -0
- package/lib/Message/styles.js.map +1 -0
- package/lib/Message/types.d.ts +22 -0
- package/lib/Message/types.js +2 -0
- package/lib/Message/types.js.map +1 -0
- package/lib/MessageAudio.js +1 -2
- package/lib/MessageAudio.js.map +1 -1
- package/lib/MessageContainer/components/DayAnimated/index.d.ts +5 -0
- package/lib/MessageContainer/components/DayAnimated/index.js +85 -0
- package/lib/MessageContainer/components/DayAnimated/index.js.map +1 -0
- package/lib/MessageContainer/components/DayAnimated/styles.d.ts +11 -0
- package/lib/MessageContainer/components/DayAnimated/styles.js +12 -0
- package/lib/MessageContainer/components/DayAnimated/styles.js.map +1 -0
- package/lib/MessageContainer/components/DayAnimated/types.d.ts +17 -0
- package/lib/MessageContainer/components/DayAnimated/types.js +2 -0
- package/lib/MessageContainer/components/DayAnimated/types.js.map +1 -0
- package/lib/MessageContainer/components/Item/index.d.ts +22 -0
- package/lib/MessageContainer/components/Item/index.js +69 -0
- package/lib/MessageContainer/components/Item/index.js.map +1 -0
- package/lib/MessageContainer/components/Item/types.d.ts +18 -0
- package/lib/MessageContainer/components/Item/types.js +2 -0
- package/lib/MessageContainer/components/Item/types.js.map +1 -0
- package/lib/MessageContainer/index.d.ts +6 -0
- package/lib/MessageContainer/index.js +200 -0
- package/lib/MessageContainer/index.js.map +1 -0
- package/lib/MessageContainer/styles.d.ts +34 -0
- package/lib/MessageContainer/styles.js +31 -0
- package/lib/MessageContainer/styles.js.map +1 -0
- package/lib/MessageContainer/types.d.ts +54 -0
- package/lib/MessageContainer/types.js +2 -0
- package/lib/MessageContainer/types.js.map +1 -0
- package/lib/MessageImage.d.ts +1 -12
- package/lib/MessageImage.js +2 -12
- package/lib/MessageImage.js.map +1 -1
- package/lib/MessageText.d.ts +1 -24
- package/lib/MessageText.js +0 -22
- package/lib/MessageText.js.map +1 -1
- package/lib/MessageVideo.js +1 -2
- package/lib/MessageVideo.js.map +1 -1
- package/lib/QuickReplies.d.ts +1 -12
- package/lib/QuickReplies.js +10 -20
- package/lib/QuickReplies.js.map +1 -1
- package/lib/Send.d.ts +2 -16
- package/lib/Send.js +0 -13
- package/lib/Send.js.map +1 -1
- package/lib/SystemMessage.d.ts +1 -10
- package/lib/SystemMessage.js +2 -12
- package/lib/SystemMessage.js.map +1 -1
- package/lib/Time.d.ts +1 -17
- package/lib/Time.js +0 -15
- package/lib/Time.js.map +1 -1
- package/lib/TypingIndicator/index.d.ts +5 -0
- package/lib/{TypingIndicator.js → TypingIndicator/index.js} +9 -30
- package/lib/TypingIndicator/index.js.map +1 -0
- package/lib/TypingIndicator/styles.d.ts +20 -0
- package/lib/TypingIndicator/styles.js +22 -0
- package/lib/TypingIndicator/styles.js.map +1 -0
- package/lib/TypingIndicator/types.d.ts +3 -0
- package/lib/TypingIndicator/types.js +2 -0
- package/lib/TypingIndicator/types.js.map +1 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/styles.d.ts +10 -0
- package/lib/styles.js +11 -0
- package/lib/styles.js.map +1 -0
- package/lib/{Models.d.ts → types.d.ts} +1 -1
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +1 -3
- package/lib/utils.js +0 -7
- package/lib/utils.js.map +1 -1
- package/package.json +21 -29
- package/src/Actions.tsx +3 -15
- package/src/Avatar.tsx +43 -52
- package/src/{Bubble.tsx → Bubble/index.tsx} +52 -269
- package/src/Bubble/styles.ts +73 -0
- package/src/Bubble/types.ts +90 -0
- package/src/Composer.tsx +3 -19
- package/src/Constant.ts +1 -1
- package/src/Day/index.tsx +63 -0
- package/src/Day/styles.ts +22 -0
- package/src/Day/types.ts +14 -0
- package/src/GiftedAvatar.tsx +31 -38
- package/src/GiftedChat/index.tsx +501 -0
- package/src/GiftedChat/styles.ts +7 -0
- package/src/GiftedChat/types.ts +206 -0
- package/src/InputToolbar.tsx +1 -14
- package/src/LoadEarlier.tsx +2 -17
- package/src/Message/index.tsx +135 -0
- package/src/Message/styles.ts +22 -0
- package/src/Message/types.ts +26 -0
- package/src/MessageAudio.tsx +1 -4
- package/src/MessageContainer/components/DayAnimated/index.tsx +143 -0
- package/src/MessageContainer/components/DayAnimated/styles.ts +12 -0
- package/src/MessageContainer/components/DayAnimated/types.ts +12 -0
- package/src/MessageContainer/components/Item/index.tsx +136 -0
- package/src/MessageContainer/components/Item/types.ts +13 -0
- package/src/MessageContainer/index.tsx +343 -0
- package/src/MessageContainer/styles.ts +31 -0
- package/src/MessageContainer/types.ts +60 -0
- package/src/MessageImage.tsx +3 -14
- package/src/MessageText.tsx +1 -24
- package/src/MessageVideo.tsx +1 -4
- package/src/QuickReplies.tsx +14 -25
- package/src/Send.tsx +1 -15
- package/src/SystemMessage.tsx +3 -14
- package/src/Time.tsx +1 -17
- package/src/{TypingIndicator.tsx → TypingIndicator/index.tsx} +12 -35
- package/src/TypingIndicator/styles.ts +22 -0
- package/src/TypingIndicator/types.ts +3 -0
- package/src/__tests__/Bubble.test.tsx +7 -4
- package/src/__tests__/GiftedAvatar.test.tsx +6 -2
- package/src/__tests__/GiftedChat.test.tsx +20 -14
- package/src/__tests__/Message.test.tsx +4 -1
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +6 -2
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +3 -1
- package/src/__tests__/__snapshots__/Composer.test.tsx.snap +2 -0
- package/src/__tests__/__snapshots__/Constant.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/Day.test.tsx.snap +1 -33
- package/src/__tests__/__snapshots__/GiftedAvatar.test.tsx.snap +4 -2
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +22 -9
- package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +2 -0
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +3 -1
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +21 -100
- package/src/__tests__/__snapshots__/MessageContainer.test.tsx.snap +282 -82
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +8 -4
- package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +5 -1
- package/src/__tests__/data.ts +1 -1
- package/src/index.ts +0 -2
- package/src/styles.ts +11 -0
- package/src/{Models.ts → types.ts} +1 -1
- package/src/utils.ts +1 -9
- package/lib/Actions.js.flow +0 -21
- package/lib/Avatar.js.flow +0 -27
- package/lib/Bubble.d.ts +0 -148
- package/lib/Bubble.js.flow +0 -69
- package/lib/Bubble.js.map +0 -1
- package/lib/Composer.js.flow +0 -24
- package/lib/Day.d.ts +0 -15
- package/lib/Day.js +0 -36
- package/lib/Day.js.flow +0 -23
- package/lib/Day.js.map +0 -1
- package/lib/GiftedAvatar.js.flow +0 -17
- package/lib/GiftedChat.js.flow +0 -163
- package/lib/GiftedChat.js.map +0 -1
- package/lib/InputToolbar.js.flow +0 -31
- package/lib/LoadEarlier.js.flow +0 -20
- package/lib/Message.d.ts +0 -67
- package/lib/Message.js +0 -157
- package/lib/Message.js.flow +0 -32
- package/lib/Message.js.map +0 -1
- package/lib/MessageAudio.js.flow +0 -15
- package/lib/MessageContainer.d.ts +0 -105
- package/lib/MessageContainer.js +0 -224
- package/lib/MessageContainer.js.flow +0 -39
- package/lib/MessageContainer.js.map +0 -1
- package/lib/MessageImage.js.flow +0 -20
- package/lib/MessageText.js.flow +0 -23
- package/lib/MessageVideo.js.flow +0 -16
- package/lib/Models.js +0 -2
- package/lib/Models.js.map +0 -1
- package/lib/QuickReplies.js.flow +0 -25
- package/lib/Send.js.flow +0 -19
- package/lib/SystemMessage.js.flow +0 -18
- package/lib/Time.js.flow +0 -19
- package/lib/TypingIndicator.d.ts +0 -6
- package/lib/TypingIndicator.js.map +0 -1
- package/lib/index.js.flow +0 -2
- package/lib/types.js.flow +0 -43
- package/lib/utils.js.flow +0 -16
- package/src/Day.tsx +0 -71
- package/src/GiftedChat.tsx +0 -689
- package/src/Message.tsx +0 -229
- package/src/MessageContainer.tsx +0 -361
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
declare const styles: {
|
|
2
|
+
left: {
|
|
3
|
+
container: {
|
|
4
|
+
alignItems: "flex-start";
|
|
5
|
+
};
|
|
6
|
+
wrapper: {
|
|
7
|
+
borderRadius: number;
|
|
8
|
+
backgroundColor: string;
|
|
9
|
+
marginRight: number;
|
|
10
|
+
minHeight: number;
|
|
11
|
+
justifyContent: "flex-end";
|
|
12
|
+
};
|
|
13
|
+
containerToNext: {
|
|
14
|
+
borderBottomLeftRadius: number;
|
|
15
|
+
};
|
|
16
|
+
containerToPrevious: {
|
|
17
|
+
borderTopLeftRadius: number;
|
|
18
|
+
};
|
|
19
|
+
bottom: {
|
|
20
|
+
flexDirection: "row";
|
|
21
|
+
justifyContent: "flex-start";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
right: {
|
|
25
|
+
container: {
|
|
26
|
+
alignItems: "flex-end";
|
|
27
|
+
};
|
|
28
|
+
wrapper: {
|
|
29
|
+
borderRadius: number;
|
|
30
|
+
backgroundColor: string;
|
|
31
|
+
marginLeft: number;
|
|
32
|
+
minHeight: number;
|
|
33
|
+
justifyContent: "flex-end";
|
|
34
|
+
};
|
|
35
|
+
containerToNext: {
|
|
36
|
+
borderBottomRightRadius: number;
|
|
37
|
+
};
|
|
38
|
+
containerToPrevious: {
|
|
39
|
+
borderTopRightRadius: number;
|
|
40
|
+
};
|
|
41
|
+
bottom: {
|
|
42
|
+
flexDirection: "row";
|
|
43
|
+
justifyContent: "flex-end";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
content: {
|
|
47
|
+
tick: {
|
|
48
|
+
fontSize: number;
|
|
49
|
+
backgroundColor: string;
|
|
50
|
+
color: string;
|
|
51
|
+
};
|
|
52
|
+
tickView: {
|
|
53
|
+
flexDirection: "row";
|
|
54
|
+
marginRight: number;
|
|
55
|
+
};
|
|
56
|
+
username: {
|
|
57
|
+
top: number;
|
|
58
|
+
left: number;
|
|
59
|
+
fontSize: number;
|
|
60
|
+
backgroundColor: string;
|
|
61
|
+
color: string;
|
|
62
|
+
};
|
|
63
|
+
usernameView: {
|
|
64
|
+
flexDirection: "row";
|
|
65
|
+
marginHorizontal: number;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export default styles;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import Color from '../Color';
|
|
3
|
+
const styles = {
|
|
4
|
+
left: StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
alignItems: 'flex-start',
|
|
7
|
+
},
|
|
8
|
+
wrapper: {
|
|
9
|
+
borderRadius: 15,
|
|
10
|
+
backgroundColor: Color.leftBubbleBackground,
|
|
11
|
+
marginRight: 60,
|
|
12
|
+
minHeight: 20,
|
|
13
|
+
justifyContent: 'flex-end',
|
|
14
|
+
},
|
|
15
|
+
containerToNext: {
|
|
16
|
+
borderBottomLeftRadius: 3,
|
|
17
|
+
},
|
|
18
|
+
containerToPrevious: {
|
|
19
|
+
borderTopLeftRadius: 3,
|
|
20
|
+
},
|
|
21
|
+
bottom: {
|
|
22
|
+
flexDirection: 'row',
|
|
23
|
+
justifyContent: 'flex-start',
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
right: StyleSheet.create({
|
|
27
|
+
container: {
|
|
28
|
+
alignItems: 'flex-end',
|
|
29
|
+
},
|
|
30
|
+
wrapper: {
|
|
31
|
+
borderRadius: 15,
|
|
32
|
+
backgroundColor: Color.defaultBlue,
|
|
33
|
+
marginLeft: 60,
|
|
34
|
+
minHeight: 20,
|
|
35
|
+
justifyContent: 'flex-end',
|
|
36
|
+
},
|
|
37
|
+
containerToNext: {
|
|
38
|
+
borderBottomRightRadius: 3,
|
|
39
|
+
},
|
|
40
|
+
containerToPrevious: {
|
|
41
|
+
borderTopRightRadius: 3,
|
|
42
|
+
},
|
|
43
|
+
bottom: {
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
justifyContent: 'flex-end',
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
content: StyleSheet.create({
|
|
49
|
+
tick: {
|
|
50
|
+
fontSize: 10,
|
|
51
|
+
backgroundColor: Color.backgroundTransparent,
|
|
52
|
+
color: Color.white,
|
|
53
|
+
},
|
|
54
|
+
tickView: {
|
|
55
|
+
flexDirection: 'row',
|
|
56
|
+
marginRight: 10,
|
|
57
|
+
},
|
|
58
|
+
username: {
|
|
59
|
+
top: -3,
|
|
60
|
+
left: 0,
|
|
61
|
+
fontSize: 12,
|
|
62
|
+
backgroundColor: Color.backgroundTransparent,
|
|
63
|
+
color: '#aaa',
|
|
64
|
+
},
|
|
65
|
+
usernameView: {
|
|
66
|
+
flexDirection: 'row',
|
|
67
|
+
marginHorizontal: 10,
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
export default styles;
|
|
72
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/Bubble/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,MAAM,UAAU,CAAA;AAE5B,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC;QACtB,SAAS,EAAE;YACT,UAAU,EAAE,YAAY;SACzB;QACD,OAAO,EAAE;YACP,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,KAAK,CAAC,oBAAoB;YAC3C,WAAW,EAAE,EAAE;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2
|
+
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
import { QuickRepliesProps } from '../QuickReplies';
|
|
4
|
+
import { MessageTextProps } from '../MessageText';
|
|
5
|
+
import { MessageImageProps } from '../MessageImage';
|
|
6
|
+
import { TimeProps } from '../Time';
|
|
7
|
+
import { User, IMessage, LeftRightStyle, Reply, Omit, MessageVideoProps, MessageAudioProps } from '../types';
|
|
8
|
+
export type RenderMessageImageProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageImageProps<TMessage>;
|
|
9
|
+
export type RenderMessageVideoProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageVideoProps<TMessage>;
|
|
10
|
+
export type RenderMessageAudioProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageAudioProps<TMessage>;
|
|
11
|
+
export type RenderMessageTextProps<TMessage extends IMessage> = Omit<BubbleProps<TMessage>, 'containerStyle' | 'wrapperStyle'> & MessageTextProps<TMessage>;
|
|
12
|
+
export interface BubbleProps<TMessage extends IMessage> {
|
|
13
|
+
user?: User;
|
|
14
|
+
touchableProps?: object;
|
|
15
|
+
renderUsernameOnMessage?: boolean;
|
|
16
|
+
isCustomViewBottom?: boolean;
|
|
17
|
+
inverted?: boolean;
|
|
18
|
+
position: 'left' | 'right';
|
|
19
|
+
currentMessage: TMessage;
|
|
20
|
+
nextMessage?: TMessage;
|
|
21
|
+
previousMessage?: TMessage;
|
|
22
|
+
optionTitles?: string[];
|
|
23
|
+
containerStyle?: LeftRightStyle<ViewStyle>;
|
|
24
|
+
wrapperStyle?: LeftRightStyle<ViewStyle>;
|
|
25
|
+
textStyle?: LeftRightStyle<TextStyle>;
|
|
26
|
+
bottomContainerStyle?: LeftRightStyle<ViewStyle>;
|
|
27
|
+
tickStyle?: StyleProp<TextStyle>;
|
|
28
|
+
containerToNextStyle?: LeftRightStyle<ViewStyle>;
|
|
29
|
+
containerToPreviousStyle?: LeftRightStyle<ViewStyle>;
|
|
30
|
+
usernameStyle?: TextStyle;
|
|
31
|
+
quickReplyStyle?: StyleProp<ViewStyle>;
|
|
32
|
+
quickReplyTextStyle?: StyleProp<TextStyle>;
|
|
33
|
+
quickReplyContainerStyle?: StyleProp<ViewStyle>;
|
|
34
|
+
onPress?(context?: unknown, message?: unknown): void;
|
|
35
|
+
onLongPress?(context?: unknown, message?: unknown): void;
|
|
36
|
+
onQuickReply?(replies: Reply[]): void;
|
|
37
|
+
renderMessageImage?(props: RenderMessageImageProps<TMessage>): React.ReactNode;
|
|
38
|
+
renderMessageVideo?(props: RenderMessageVideoProps<TMessage>): React.ReactNode;
|
|
39
|
+
renderMessageAudio?(props: RenderMessageAudioProps<TMessage>): React.ReactNode;
|
|
40
|
+
renderMessageText?(props: RenderMessageTextProps<TMessage>): React.ReactNode;
|
|
41
|
+
renderCustomView?(bubbleProps: BubbleProps<TMessage>): React.ReactNode;
|
|
42
|
+
renderTime?(timeProps: TimeProps<TMessage>): React.ReactNode;
|
|
43
|
+
renderTicks?(currentMessage: TMessage): React.ReactNode;
|
|
44
|
+
renderUsername?(user?: TMessage['user']): React.ReactNode;
|
|
45
|
+
renderQuickReplySend?(): React.ReactNode;
|
|
46
|
+
renderQuickReplies?(quickReplies: QuickRepliesProps<TMessage>): React.ReactNode;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Bubble/types.ts"],"names":[],"mappings":""}
|
package/lib/Composer.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import { TextInputProps } from 'react-native';
|
|
4
3
|
export interface ComposerProps {
|
|
5
4
|
composerHeight?: number;
|
|
@@ -19,19 +18,3 @@ export interface ComposerProps {
|
|
|
19
18
|
}): void;
|
|
20
19
|
}
|
|
21
20
|
export declare function Composer({ composerHeight, disableComposer, keyboardAppearance, multiline, onInputSizeChanged, onTextChanged, placeholder, placeholderTextColor, text, textInputAutoFocus, textInputProps, textInputStyle, }: ComposerProps): React.ReactElement;
|
|
22
|
-
export declare namespace Composer {
|
|
23
|
-
var propTypes: {
|
|
24
|
-
composerHeight: PropTypes.Requireable<number>;
|
|
25
|
-
text: PropTypes.Requireable<string>;
|
|
26
|
-
placeholder: PropTypes.Requireable<string>;
|
|
27
|
-
placeholderTextColor: PropTypes.Requireable<string>;
|
|
28
|
-
textInputProps: PropTypes.Requireable<object>;
|
|
29
|
-
onTextChanged: PropTypes.Requireable<(...args: any[]) => any>;
|
|
30
|
-
onInputSizeChanged: PropTypes.Requireable<(...args: any[]) => any>;
|
|
31
|
-
multiline: PropTypes.Requireable<boolean>;
|
|
32
|
-
disableComposer: PropTypes.Requireable<boolean>;
|
|
33
|
-
textInputStyle: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
|
|
34
|
-
textInputAutoFocus: PropTypes.Requireable<boolean>;
|
|
35
|
-
keyboardAppearance: PropTypes.Requireable<string>;
|
|
36
|
-
};
|
|
37
|
-
}
|
package/lib/Composer.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useRef } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import { Platform, StyleSheet, TextInput, } from 'react-native';
|
|
4
3
|
import { MIN_COMPOSER_HEIGHT, DEFAULT_PLACEHOLDER } from './Constant';
|
|
5
4
|
import Color from './Color';
|
|
6
|
-
import
|
|
5
|
+
import stylesCommon from './styles';
|
|
7
6
|
export function Composer({ composerHeight = MIN_COMPOSER_HEIGHT, disableComposer = false, keyboardAppearance = 'default', multiline = true, onInputSizeChanged, onTextChanged, placeholder = DEFAULT_PLACEHOLDER, placeholderTextColor = Color.defaultColor, text = '', textInputAutoFocus = false, textInputProps, textInputStyle, }) {
|
|
8
|
-
const dimensionsRef = useRef();
|
|
7
|
+
const dimensionsRef = useRef(null);
|
|
9
8
|
const determineInputSizeChange = useCallback((dimensions) => {
|
|
10
9
|
// Support earlier versions of React Native on Android.
|
|
11
10
|
if (!dimensions)
|
|
@@ -20,6 +19,7 @@ export function Composer({ composerHeight = MIN_COMPOSER_HEIGHT, disableComposer
|
|
|
20
19
|
}, [onInputSizeChanged]);
|
|
21
20
|
const handleContentSizeChange = useCallback(({ nativeEvent: { contentSize }, }) => determineInputSizeChange(contentSize), [determineInputSizeChange]);
|
|
22
21
|
return (<TextInput testID={placeholder} accessible accessibilityLabel={placeholder} placeholder={placeholder} placeholderTextColor={placeholderTextColor} multiline={multiline} editable={!disableComposer} onContentSizeChange={handleContentSizeChange} onChangeText={onTextChanged} style={[
|
|
22
|
+
stylesCommon.fill,
|
|
23
23
|
styles.textInput,
|
|
24
24
|
textInputStyle,
|
|
25
25
|
{
|
|
@@ -34,23 +34,8 @@ export function Composer({ composerHeight = MIN_COMPOSER_HEIGHT, disableComposer
|
|
|
34
34
|
},
|
|
35
35
|
]} autoFocus={textInputAutoFocus} value={text} enablesReturnKeyAutomatically underlineColorAndroid='transparent' keyboardAppearance={keyboardAppearance} {...textInputProps}/>);
|
|
36
36
|
}
|
|
37
|
-
Composer.propTypes = {
|
|
38
|
-
composerHeight: PropTypes.number,
|
|
39
|
-
text: PropTypes.string,
|
|
40
|
-
placeholder: PropTypes.string,
|
|
41
|
-
placeholderTextColor: PropTypes.string,
|
|
42
|
-
textInputProps: PropTypes.object,
|
|
43
|
-
onTextChanged: PropTypes.func,
|
|
44
|
-
onInputSizeChanged: PropTypes.func,
|
|
45
|
-
multiline: PropTypes.bool,
|
|
46
|
-
disableComposer: PropTypes.bool,
|
|
47
|
-
textInputStyle: StylePropType,
|
|
48
|
-
textInputAutoFocus: PropTypes.bool,
|
|
49
|
-
keyboardAppearance: PropTypes.string,
|
|
50
|
-
};
|
|
51
37
|
const styles = StyleSheet.create({
|
|
52
38
|
textInput: {
|
|
53
|
-
flex: 1,
|
|
54
39
|
marginLeft: 10,
|
|
55
40
|
fontSize: 16,
|
|
56
41
|
lineHeight: 22,
|
package/lib/Composer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Composer.js","sourceRoot":"","sources":["../src/Composer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"Composer.js","sourceRoot":"","sources":["../src/Composer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,GAIV,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,YAAY,MAAM,UAAU,CAAA;AAiBnC,MAAM,UAAU,QAAQ,CAAE,EACxB,cAAc,GAAG,mBAAmB,EACpC,eAAe,GAAG,KAAK,EACvB,kBAAkB,GAAG,SAAS,EAC9B,SAAS,GAAG,IAAI,EAChB,kBAAkB,EAClB,aAAa,EACb,WAAW,GAAG,mBAAmB,EACjC,oBAAoB,GAAG,KAAK,CAAC,YAAY,EACzC,IAAI,GAAG,EAAE,EACT,kBAAkB,GAAG,KAAK,EAC1B,cAAc,EACd,cAAc,GACA;IACd,MAAM,aAAa,GAAG,MAAM,CAAoC,IAAI,CAAC,CAAA;IAErE,MAAM,wBAAwB,GAAG,WAAW,CAC1C,CAAC,UAA6C,EAAE,EAAE;QAChD,uDAAuD;QACvD,IAAI,CAAC,UAAU;YACb,OAAM;QAER,IACE,CAAC,aAAa,CAAC,OAAO;YACtB,CAAC,aAAa,CAAC,OAAO;gBACpB,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,KAAK,UAAU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,CACH,CAAA;AACH,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,GAAG,QAAQ,CAAC,MAAM,CAAC;YACjB,GAAG,EAAE;gBACH,UAAU,EAAE,CAAC;gBACb,WAAW,EAAE,CAAC;aACf;SACF,CAAC;QACF,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC;YACzB,GAAG,EAAE,CAAC;YACN,OAAO,EAAE,CAAC;YACV,GAAG,EAAE,CAAC;SACP,CAAC;QACF,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC;YAC5B,GAAG,EAAE,CAAC;YACN,OAAO,EAAE,CAAC;YACV,GAAG,EAAE,CAAC;SACP,CAAC;KACH;CACF,CAAC,CAAA"}
|
package/lib/Constant.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const MIN_COMPOSER_HEIGHT: number | undefined;
|
|
2
2
|
export declare const MAX_COMPOSER_HEIGHT = 200;
|
|
3
3
|
export declare const DEFAULT_PLACEHOLDER = "Type a message...";
|
|
4
|
-
export declare const DATE_FORMAT = "
|
|
4
|
+
export declare const DATE_FORMAT = "D MMMM";
|
|
5
5
|
export declare const TIME_FORMAT = "LT";
|
|
6
6
|
export declare const TEST_ID: {
|
|
7
7
|
WRAPPER: string;
|
package/lib/Constant.js
CHANGED
|
@@ -7,7 +7,7 @@ export const MIN_COMPOSER_HEIGHT = Platform.select({
|
|
|
7
7
|
});
|
|
8
8
|
export const MAX_COMPOSER_HEIGHT = 200;
|
|
9
9
|
export const DEFAULT_PLACEHOLDER = 'Type a message...';
|
|
10
|
-
export const DATE_FORMAT = '
|
|
10
|
+
export const DATE_FORMAT = 'D MMMM';
|
|
11
11
|
export const TIME_FORMAT = 'LT';
|
|
12
12
|
export const TEST_ID = {
|
|
13
13
|
WRAPPER: 'GC_WRAPPER',
|
package/lib/Constant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constant.js","sourceRoot":"","sources":["../src/Constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC;IACjD,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;IACX,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;CACZ,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AACtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAA;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"Constant.js","sourceRoot":"","sources":["../src/Constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC;IACjD,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;IACX,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;CACZ,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AACtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAA;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAA;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAA;AAE/B,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO,EAAE,YAAY;IACrB,eAAe,EAAE,sBAAsB;IACvC,cAAc,EAAE,mBAAmB;CACpC,CAAA"}
|
package/lib/Day/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Text, View, } from 'react-native';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
5
|
+
import calendar from 'dayjs/plugin/calendar';
|
|
6
|
+
import { DATE_FORMAT } from '../Constant';
|
|
7
|
+
import { useChatContext } from '../GiftedChatContext';
|
|
8
|
+
import stylesCommon from '../styles';
|
|
9
|
+
import styles from './styles';
|
|
10
|
+
export * from './types';
|
|
11
|
+
dayjs.extend(relativeTime);
|
|
12
|
+
dayjs.extend(calendar);
|
|
13
|
+
export function Day({ dateFormat = DATE_FORMAT, dateFormatCalendar, createdAt, containerStyle, wrapperStyle, textStyle, }) {
|
|
14
|
+
const { getLocale } = useChatContext();
|
|
15
|
+
const dateStr = React.useMemo(() => {
|
|
16
|
+
if (createdAt == null)
|
|
17
|
+
return null;
|
|
18
|
+
const now = dayjs().startOf('day');
|
|
19
|
+
const date = dayjs(createdAt).locale(getLocale()).startOf('day');
|
|
20
|
+
if (!now.isSame(date, 'year'))
|
|
21
|
+
return date.format('D MMMM YYYY');
|
|
22
|
+
if (now.diff(date, 'days') <= 1)
|
|
23
|
+
return date.calendar(now, {
|
|
24
|
+
sameDay: '[Today]',
|
|
25
|
+
...dateFormatCalendar,
|
|
26
|
+
});
|
|
27
|
+
return date.format(dateFormat);
|
|
28
|
+
}, [createdAt, dateFormat, getLocale, dateFormatCalendar]);
|
|
29
|
+
if (!dateStr)
|
|
30
|
+
return null;
|
|
31
|
+
return (<View style={[stylesCommon.centerItems, styles.container, containerStyle]}>
|
|
32
|
+
<View style={[styles.wrapper, wrapperStyle]}>
|
|
33
|
+
<Text style={[styles.text, textStyle]}>
|
|
34
|
+
{dateStr}
|
|
35
|
+
</Text>
|
|
36
|
+
</View>
|
|
37
|
+
</View>);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Day/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KA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O,EAAE,SAAS;gBAClB,GAAG,kBAAkB;aACtB,CAAC,CAAA;QAEJ,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAChC,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAA;IAE1D,IAAI,CAAC,OAAO;QACV,OAAO,IAAI,CAAA;IAEb,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CACxE;MAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAC1C;QAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CACpC;UAAA,CAAC,OAAO,CACV;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
container: {
|
|
3
|
+
marginTop: number;
|
|
4
|
+
marginBottom: number;
|
|
5
|
+
};
|
|
6
|
+
wrapper: {
|
|
7
|
+
backgroundColor: string;
|
|
8
|
+
paddingTop: number;
|
|
9
|
+
paddingBottom: number;
|
|
10
|
+
paddingLeft: number;
|
|
11
|
+
paddingRight: number;
|
|
12
|
+
borderRadius: number;
|
|
13
|
+
};
|
|
14
|
+
text: {
|
|
15
|
+
color: string;
|
|
16
|
+
fontSize: number;
|
|
17
|
+
fontWeight: "600";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import Color from '../Color';
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
marginTop: 5,
|
|
6
|
+
marginBottom: 10,
|
|
7
|
+
},
|
|
8
|
+
wrapper: {
|
|
9
|
+
backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
|
10
|
+
paddingTop: 6,
|
|
11
|
+
paddingBottom: 6,
|
|
12
|
+
paddingLeft: 10,
|
|
13
|
+
paddingRight: 10,
|
|
14
|
+
borderRadius: 15,
|
|
15
|
+
},
|
|
16
|
+
text: {
|
|
17
|
+
color: Color.white,
|
|
18
|
+
fontSize: 12,
|
|
19
|
+
fontWeight: '600',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/Day/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,MAAM,UAAU,CAAA;AAE5B,eAAe,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,EAAE;KACjB;IACD,OAAO,EAAE;QACP,eAAe,EAAE,qBAAqB;QACtC,UAAU,EAAE,CAAC;QACb,aAAa,EAAE,CAAC;QAChB,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,EAAE;QAChB,YAAY,EAAE,EAAE;KACjB;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAAK;KAClB;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
export interface DayProps {
|
|
3
|
+
createdAt: Date | number;
|
|
4
|
+
dateFormat?: string;
|
|
5
|
+
dateFormatCalendar?: object;
|
|
6
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
7
|
+
wrapperStyle?: StyleProp<ViewStyle>;
|
|
8
|
+
textStyle?: StyleProp<TextStyle>;
|
|
9
|
+
}
|
package/lib/Day/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Day/types.ts"],"names":[],"mappings":""}
|
package/lib/GiftedAvatar.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { StyleProp, ImageStyle, TextStyle } from 'react-native';
|
|
4
|
-
import { User } from './
|
|
3
|
+
import { User } from './types';
|
|
5
4
|
export interface GiftedAvatarProps {
|
|
6
5
|
user?: User;
|
|
7
6
|
avatarStyle?: StyleProp<ImageStyle>;
|
|
@@ -10,12 +9,3 @@ export interface GiftedAvatarProps {
|
|
|
10
9
|
onLongPress?: (props: GiftedAvatarProps) => void;
|
|
11
10
|
}
|
|
12
11
|
export declare function GiftedAvatar(props: GiftedAvatarProps): React.JSX.Element;
|
|
13
|
-
export declare namespace GiftedAvatar {
|
|
14
|
-
var propTypes: {
|
|
15
|
-
user: PropTypes.Requireable<object>;
|
|
16
|
-
onPress: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
-
onLongPress: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
-
avatarStyle: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
|
|
19
|
-
textStyle: PropTypes.Requireable<NonNullable<number | boolean | object | null | undefined>>;
|
|
20
|
-
};
|
|
21
|
-
}
|
package/lib/GiftedAvatar.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useCallback, useRef } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
2
|
import { Image, Text, TouchableOpacity, View, StyleSheet, } from 'react-native';
|
|
4
3
|
import Color from './Color';
|
|
5
|
-
import
|
|
4
|
+
import stylesCommon from './styles';
|
|
6
5
|
const { carrot, emerald, peterRiver, wisteria, alizarin, turquoise, midnightBlue, } = Color;
|
|
7
6
|
const styles = StyleSheet.create({
|
|
8
7
|
avatarStyle: {
|
|
9
|
-
justifyContent: 'center',
|
|
10
|
-
alignItems: 'center',
|
|
11
8
|
width: 40,
|
|
12
9
|
height: 40,
|
|
13
10
|
borderRadius: 20,
|
|
@@ -23,21 +20,20 @@ const styles = StyleSheet.create({
|
|
|
23
20
|
},
|
|
24
21
|
});
|
|
25
22
|
export function GiftedAvatar(props) {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const { user =
|
|
29
|
-
name: null,
|
|
30
|
-
avatar: null,
|
|
31
|
-
}, avatarStyle = {}, textStyle = {}, onPress, } = props;
|
|
23
|
+
const [avatarName, setAvatarName] = useState(undefined);
|
|
24
|
+
const [backgroundColor, setBackgroundColor] = useState(undefined);
|
|
25
|
+
const { user, avatarStyle, textStyle, onPress, } = props;
|
|
32
26
|
const setAvatarColor = useCallback(() => {
|
|
33
|
-
|
|
27
|
+
if (backgroundColor)
|
|
28
|
+
return;
|
|
29
|
+
const userName = user?.name || '';
|
|
34
30
|
const name = userName.toUpperCase().split(' ');
|
|
35
31
|
if (name.length === 1)
|
|
36
|
-
|
|
32
|
+
setAvatarName(`${name[0].charAt(0)}`);
|
|
37
33
|
else if (name.length > 1)
|
|
38
|
-
|
|
34
|
+
setAvatarName(`${name[0].charAt(0)}${name[1].charAt(0)}`);
|
|
39
35
|
else
|
|
40
|
-
|
|
36
|
+
setAvatarName('');
|
|
41
37
|
let sumChars = 0;
|
|
42
38
|
for (let i = 0; i < userName.length; i += 1)
|
|
43
39
|
sumChars += userName.charCodeAt(i);
|
|
@@ -52,25 +48,25 @@ export function GiftedAvatar(props) {
|
|
|
52
48
|
turquoise,
|
|
53
49
|
midnightBlue,
|
|
54
50
|
];
|
|
55
|
-
|
|
56
|
-
}, [user
|
|
51
|
+
setBackgroundColor(colors[sumChars % colors.length]);
|
|
52
|
+
}, [user?.name, backgroundColor]);
|
|
57
53
|
const renderAvatar = useCallback(() => {
|
|
58
|
-
switch (typeof user
|
|
54
|
+
switch (typeof user?.avatar) {
|
|
59
55
|
case 'function':
|
|
60
|
-
return user.avatar([styles.avatarStyle, avatarStyle]);
|
|
56
|
+
return user.avatar([stylesCommon.centerItems, styles.avatarStyle, avatarStyle]);
|
|
61
57
|
case 'string':
|
|
62
|
-
return (<Image source={{ uri: user.avatar }} style={[styles.avatarStyle, avatarStyle]}/>);
|
|
58
|
+
return (<Image source={{ uri: user.avatar }} style={[stylesCommon.centerItems, styles.avatarStyle, avatarStyle]}/>);
|
|
63
59
|
case 'number':
|
|
64
|
-
return (<Image source={user.avatar} style={[styles.avatarStyle, avatarStyle]}/>);
|
|
60
|
+
return (<Image source={user.avatar} style={[stylesCommon.centerItems, styles.avatarStyle, avatarStyle]}/>);
|
|
65
61
|
default:
|
|
66
62
|
return null;
|
|
67
63
|
}
|
|
68
|
-
}, [user
|
|
64
|
+
}, [user, avatarStyle]);
|
|
69
65
|
const renderInitials = useCallback(() => {
|
|
70
66
|
return (<Text style={[styles.textStyle, textStyle]}>
|
|
71
|
-
{
|
|
67
|
+
{avatarName}
|
|
72
68
|
</Text>);
|
|
73
|
-
}, [textStyle]);
|
|
69
|
+
}, [textStyle, avatarName]);
|
|
74
70
|
const handleOnPress = () => {
|
|
75
71
|
const { onPress, ...rest } = props;
|
|
76
72
|
if (onPress)
|
|
@@ -81,9 +77,13 @@ export function GiftedAvatar(props) {
|
|
|
81
77
|
if (onLongPress)
|
|
82
78
|
onLongPress(rest);
|
|
83
79
|
};
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
setAvatarColor();
|
|
82
|
+
}, [setAvatarColor]);
|
|
84
83
|
if (!user || (!user.name && !user.avatar))
|
|
85
84
|
// render placeholder
|
|
86
85
|
return (<View style={[
|
|
86
|
+
stylesCommon.centerItems,
|
|
87
87
|
styles.avatarStyle,
|
|
88
88
|
styles.avatarTransparent,
|
|
89
89
|
avatarStyle,
|
|
@@ -92,20 +92,13 @@ export function GiftedAvatar(props) {
|
|
|
92
92
|
return (<TouchableOpacity disabled={!onPress} onPress={handleOnPress} onLongPress={handleOnLongPress} accessibilityRole='image'>
|
|
93
93
|
{renderAvatar()}
|
|
94
94
|
</TouchableOpacity>);
|
|
95
|
-
setAvatarColor();
|
|
96
95
|
return (<TouchableOpacity disabled={!onPress} onPress={handleOnPress} onLongPress={handleOnLongPress} style={[
|
|
96
|
+
stylesCommon.centerItems,
|
|
97
97
|
styles.avatarStyle,
|
|
98
|
-
{ backgroundColor
|
|
98
|
+
{ backgroundColor },
|
|
99
99
|
avatarStyle,
|
|
100
100
|
]} accessibilityRole='image'>
|
|
101
101
|
{renderInitials()}
|
|
102
102
|
</TouchableOpacity>);
|
|
103
103
|
}
|
|
104
|
-
GiftedAvatar.propTypes = {
|
|
105
|
-
user: PropTypes.object,
|
|
106
|
-
onPress: PropTypes.func,
|
|
107
|
-
onLongPress: PropTypes.func,
|
|
108
|
-
avatarStyle: StylePropType,
|
|
109
|
-
textStyle: StylePropType,
|
|
110
|
-
};
|
|
111
104
|
//# sourceMappingURL=GiftedAvatar.js.map
|
package/lib/GiftedAvatar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GiftedAvatar.js","sourceRoot":"","sources":["../src/GiftedAvatar.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"GiftedAvatar.js","sourceRoot":"","sources":["../src/GiftedAvatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,EACL,KAAK,EACL,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,UAAU,GAIX,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,MAAM,SAAS,CAAA;AAE3B,OAAO,YAAY,MAAM,UAAU,CAAA;AAEnC,MAAM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AAC,gBAAgB,CACf,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CACnB,OAAO,CAAC,CAAC,aAAa,CAAC,CACvB,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAC/B,iBAAiB,CAAC,OAAO,CAEzB;QAAA,CAAC,YAAY,EAAE,CACjB;MAAA,EAAE,gBAAgB,CAAC,CACpB,CAAA;IAEH,OAAO,CACL,CAAC,gBAAgB,CACf,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CACnB,OAAO,CAAC,CAAC,aAAa,CAAC,CACvB,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAC/B,KAAK,CAAC,CAAC;YACL,YAAY,CAAC,WAAW;YACxB,MAAM,CAAC,WAAW;YAClB,EAAE,eAAe,EAAE;YACnB,WAAW;SACZ,CAAC,CACF,iBAAiB,CAAC,OAAO,CAEzB;MAAA,CAAC,cAAc,EAAE,CACnB;IAAA,EAAE,gBAAgB,CAAC,CACpB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Actions } from '../Actions';
|
|
3
|
+
import { Avatar } from '../Avatar';
|
|
4
|
+
import Bubble from '../Bubble';
|
|
5
|
+
import { Composer } from '../Composer';
|
|
6
|
+
import { Day } from '../Day';
|
|
7
|
+
import { GiftedAvatar } from '../GiftedAvatar';
|
|
8
|
+
import { InputToolbar } from '../InputToolbar';
|
|
9
|
+
import { LoadEarlier } from '../LoadEarlier';
|
|
10
|
+
import Message from '../Message';
|
|
11
|
+
import MessageContainer from '../MessageContainer';
|
|
12
|
+
import { MessageImage } from '../MessageImage';
|
|
13
|
+
import { MessageText } from '../MessageText';
|
|
14
|
+
import { IMessage } from '../types';
|
|
15
|
+
import { Send } from '../Send';
|
|
16
|
+
import { SystemMessage } from '../SystemMessage';
|
|
17
|
+
import { Time } from '../Time';
|
|
18
|
+
import * as utils from '../utils';
|
|
19
|
+
import { GiftedChatProps } from './types';
|
|
20
|
+
declare function GiftedChatWrapper(props: GiftedChatProps): React.JSX.Element;
|
|
21
|
+
declare namespace GiftedChatWrapper {
|
|
22
|
+
var append: <TMessage extends IMessage>(currentMessages: TMessage[] | undefined, messages: TMessage[], inverted?: boolean) => TMessage[];
|
|
23
|
+
var prepend: <TMessage extends IMessage>(currentMessages: TMessage[] | undefined, messages: TMessage[], inverted?: boolean) => TMessage[];
|
|
24
|
+
}
|
|
25
|
+
export * from '../types';
|
|
26
|
+
export { GiftedChatWrapper as GiftedChat, Actions, Avatar, Bubble, SystemMessage, MessageImage, MessageText, Composer, Day, InputToolbar, LoadEarlier, Message, MessageContainer, Send, Time, GiftedAvatar, utils };
|