@cometchat/chat-uikit-react-native 5.1.2 → 5.2.0
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/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.d.ts +40 -0
- package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js +467 -0
- package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js.map +1 -0
- package/lib/CometChatAIAssistantChatHistory/Skeleton.d.ts +24 -0
- package/lib/CometChatAIAssistantChatHistory/Skeleton.js +130 -0
- package/lib/CometChatAIAssistantChatHistory/Skeleton.js.map +1 -0
- package/lib/CometChatAIAssistantChatHistory/index.d.ts +1 -0
- package/lib/CometChatAIAssistantChatHistory/index.js +2 -0
- package/lib/CometChatAIAssistantChatHistory/index.js.map +1 -0
- package/lib/CometChatAIAssistantChatHistory/style.d.ts +30 -0
- package/lib/CometChatAIAssistantChatHistory/style.js +122 -0
- package/lib/CometChatAIAssistantChatHistory/style.js.map +1 -0
- package/lib/CometChatConversations/CometChatConversations.js +26 -5
- package/lib/CometChatConversations/CometChatConversations.js.map +1 -1
- package/lib/CometChatMessageComposer/CometChatMessageComposer.d.ts +7 -0
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js +101 -13
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
- package/lib/CometChatMessageHeader/CometChatMessageHeader.d.ts +16 -0
- package/lib/CometChatMessageHeader/CometChatMessageHeader.js +63 -13
- package/lib/CometChatMessageHeader/CometChatMessageHeader.js.map +1 -1
- package/lib/CometChatMessageList/CometChatMessageList.d.ts +33 -0
- package/lib/CometChatMessageList/CometChatMessageList.js +535 -76
- package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
- package/lib/CometChatMessageList/style.js +74 -2
- package/lib/CometChatMessageList/style.js.map +1 -1
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +6 -12
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
- package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js +4 -3
- package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js.map +1 -1
- package/lib/extensions/Polls/Polls.js +38 -17
- package/lib/extensions/Polls/Polls.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/lib/shared/constants/UIKitConstants.d.ts +16 -0
- package/lib/shared/constants/UIKitConstants.js +16 -0
- package/lib/shared/constants/UIKitConstants.js.map +1 -1
- package/lib/shared/events/CometChatMessageEvents/index.d.ts +3 -0
- package/lib/shared/events/CometChatMessageEvents/index.js +3 -0
- package/lib/shared/events/CometChatMessageEvents/index.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +3 -0
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +3 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.js +4 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
- package/lib/shared/events/ListenerInitializer.d.ts +3 -1
- package/lib/shared/events/ListenerInitializer.js +5 -1
- package/lib/shared/events/ListenerInitializer.js.map +1 -1
- package/lib/shared/events/messages.d.ts +2 -1
- package/lib/shared/events/messages.js +1 -0
- package/lib/shared/events/messages.js.map +1 -1
- package/lib/shared/framework/DataSource.d.ts +3 -1
- package/lib/shared/framework/DataSourceDecorator.d.ts +3 -1
- package/lib/shared/framework/DataSourceDecorator.js +8 -2
- package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
- package/lib/shared/framework/MessageDataSource.d.ts +6 -0
- package/lib/shared/framework/MessageDataSource.js +64 -1
- package/lib/shared/framework/MessageDataSource.js.map +1 -1
- package/lib/shared/icons/components/ai-chat-history.d.ts +8 -0
- package/lib/shared/icons/components/ai-chat-history.js +9 -0
- package/lib/shared/icons/components/ai-chat-history.js.map +1 -0
- package/lib/shared/icons/components/ai-copy-option.d.ts +8 -0
- package/lib/shared/icons/components/ai-copy-option.js +9 -0
- package/lib/shared/icons/components/ai-copy-option.js.map +1 -0
- package/lib/shared/icons/components/ai-new-chat.d.ts +8 -0
- package/lib/shared/icons/components/ai-new-chat.js +9 -0
- package/lib/shared/icons/components/ai-new-chat.js.map +1 -0
- package/lib/shared/icons/components/ai-send-button.d.ts +8 -0
- package/lib/shared/icons/components/ai-send-button.js +9 -0
- package/lib/shared/icons/components/ai-send-button.js.map +1 -0
- package/lib/shared/icons/components/right-arrow.d.ts +3 -0
- package/lib/shared/icons/components/right-arrow.js +6 -0
- package/lib/shared/icons/components/right-arrow.js.map +1 -0
- package/lib/shared/icons/components/stop-fill.js +8 -7
- package/lib/shared/icons/components/stop-fill.js.map +1 -1
- package/lib/shared/icons/icon-mapping.d.ts +11 -0
- package/lib/shared/icons/icon-mapping.js +11 -0
- package/lib/shared/icons/icon-mapping.js.map +1 -1
- package/lib/shared/modals/CometChatAIAssistantTools.d.ts +47 -0
- package/lib/shared/modals/CometChatAIAssistantTools.js +44 -0
- package/lib/shared/modals/CometChatAIAssistantTools.js.map +1 -0
- package/lib/shared/modals/StreamMessage.d.ts +4 -0
- package/lib/shared/modals/StreamMessage.js +11 -0
- package/lib/shared/modals/StreamMessage.js.map +1 -0
- package/lib/shared/modals/index.d.ts +3 -1
- package/lib/shared/modals/index.js +3 -1
- package/lib/shared/modals/index.js.map +1 -1
- package/lib/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.d.ts +126 -0
- package/lib/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
- package/lib/shared/services/stream-message.service.d.ts +84 -0
- package/lib/shared/services/stream-message.service.js +406 -0
- package/lib/shared/services/stream-message.service.js.map +1 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.d.ts +9 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js +248 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js.map +1 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/index.d.ts +3 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js +4 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js.map +1 -0
- package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js +5 -2
- package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js.map +1 -1
- package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js +1 -1
- package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js.map +1 -1
- package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js +52 -32
- package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js.map +1 -1
- package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.d.ts +10 -0
- package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js +54 -0
- package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js.map +1 -0
- package/lib/shared/views/CometChatSendButtonView/index.d.ts +1 -0
- package/lib/shared/views/CometChatSendButtonView/index.js +2 -0
- package/lib/shared/views/CometChatSendButtonView/index.js.map +1 -0
- package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.d.ts +8 -0
- package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js +436 -0
- package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js.map +1 -0
- package/lib/shared/views/CometChatStreamMessageBubble/index.d.ts +3 -0
- package/lib/shared/views/CometChatStreamMessageBubble/index.js +3 -0
- package/lib/shared/views/CometChatStreamMessageBubble/index.js.map +1 -0
- package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.d.ts +14 -6
- package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js +82 -57
- package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js.map +1 -1
- package/lib/theme/context.d.ts +96 -15
- package/lib/theme/type.d.ts +14 -1
- package/package.json +5 -2
- package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +627 -0
- package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +228 -0
- package/src/CometChatAIAssistantChatHistory/index.ts +2 -0
- package/src/CometChatAIAssistantChatHistory/style.ts +160 -0
- package/src/CometChatConversations/CometChatConversations.tsx +36 -10
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +137 -19
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +106 -18
- package/src/CometChatMessageList/CometChatMessageList.tsx +619 -72
- package/src/CometChatMessageList/style.ts +74 -2
- package/src/index.ts +31 -1
- package/src/shared/constants/UIKitConstants.ts +17 -0
- package/src/shared/events/CometChatMessageEvents/index.ts +3 -1
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
- package/src/shared/events/ListenerInitializer.ts +6 -1
- package/src/shared/events/messages.ts +1 -0
- package/src/shared/framework/DataSource.ts +4 -2
- package/src/shared/framework/DataSourceDecorator.tsx +10 -2
- package/src/shared/framework/MessageDataSource.tsx +75 -2
- package/src/shared/icons/Icon.tsx +1 -1
- package/src/shared/icons/components/ai-chat-history.tsx +21 -0
- package/src/shared/icons/components/ai-copy-option.tsx +21 -0
- package/src/shared/icons/components/ai-new-chat.tsx +21 -0
- package/src/shared/icons/components/ai-send-button.tsx +24 -0
- package/src/shared/icons/components/right-arrow.tsx +13 -0
- package/src/shared/icons/components/stop-fill.tsx +14 -12
- package/src/shared/icons/icon-mapping.tsx +14 -0
- package/src/shared/modals/CometChatAIAssistantTools.ts +65 -0
- package/src/shared/modals/StreamMessage.ts +12 -0
- package/src/shared/modals/index.ts +5 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
- package/src/shared/services/stream-message.service.ts +470 -0
- package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +262 -0
- package/src/shared/views/CometChatAIAssistantMessageBubble/index.ts +4 -0
- package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +86 -0
- package/src/shared/views/CometChatSendButtonView/index.ts +1 -0
- package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +493 -0
- package/src/shared/views/CometChatStreamMessageBubble/index.ts +9 -0
- package/src/theme/type.ts +14 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { Animated, Dimensions, Easing, ScrollView, StyleSheet, View } from "react-native";
|
|
3
|
+
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
|
|
4
|
+
import { useTheme } from "../theme";
|
|
5
|
+
import type { ColorValue } from "react-native";
|
|
6
|
+
import { CometChatTheme } from "../theme/type";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Animated skeleton placeholder mimicking chat history in CometChat UI‑Kit.
|
|
10
|
+
*
|
|
11
|
+
* The component respects the defaults provided by `theme.chatHistoryStyles.skeletonStyle`,
|
|
12
|
+
* but every visual property can be **overridden per instance** using the
|
|
13
|
+
* `style` prop.
|
|
14
|
+
*/
|
|
15
|
+
export interface SkeletonProps {
|
|
16
|
+
/** Partial style overrides (theme fallback for omitted keys). */
|
|
17
|
+
style?: Partial<SkeletonStyle>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Alias for the skeleton style slice inside the theme. */
|
|
21
|
+
type SkeletonStyle = {
|
|
22
|
+
backgroundColor?: ColorValue;
|
|
23
|
+
linearGradientColors?: [string, string];
|
|
24
|
+
shimmerBackgroundColor?: ColorValue;
|
|
25
|
+
shimmerOpacity?: number;
|
|
26
|
+
speed?: number;
|
|
27
|
+
containerBackgroundColor?: ColorValue;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
31
|
+
// Utility helpers
|
|
32
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
function getStyleValue<K extends keyof SkeletonStyle>(
|
|
35
|
+
key: K,
|
|
36
|
+
overrides: Partial<SkeletonStyle> | undefined,
|
|
37
|
+
theme: CometChatTheme
|
|
38
|
+
): NonNullable<SkeletonStyle[K]> {
|
|
39
|
+
// Use userStyles as fallback since it's guaranteed to exist
|
|
40
|
+
const fallbackSkeletonStyle = theme.userStyles.skeletonStyle;
|
|
41
|
+
const themeValue = (theme as any).chatHistoryStyles?.skeletonStyle?.[key];
|
|
42
|
+
return ((overrides?.[key] as SkeletonStyle[K]) ??
|
|
43
|
+
themeValue ??
|
|
44
|
+
fallbackSkeletonStyle[key]) as NonNullable<SkeletonStyle[K]>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
48
|
+
// Layout constants – adapted for chat history structure
|
|
49
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
const { width: SCREEN_WIDTH } = Dimensions.get("window");
|
|
52
|
+
|
|
53
|
+
const PADDING = 20;
|
|
54
|
+
const SECTION_HEADER_HEIGHT = 16;
|
|
55
|
+
const SECTION_SPACING = 25;
|
|
56
|
+
const MESSAGE_HEIGHT = 18;
|
|
57
|
+
const MESSAGE_SPACING = 32;
|
|
58
|
+
const SECTIONS_COUNT = 3;
|
|
59
|
+
const MESSAGES_PER_SECTION = 4;
|
|
60
|
+
|
|
61
|
+
/** Total height required for the SVG canvas */
|
|
62
|
+
const TOTAL_HEIGHT =
|
|
63
|
+
SECTIONS_COUNT * (SECTION_HEADER_HEIGHT + SECTION_SPACING + MESSAGES_PER_SECTION * (MESSAGE_HEIGHT + MESSAGE_SPACING)) +
|
|
64
|
+
PADDING * 2;
|
|
65
|
+
|
|
66
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
67
|
+
// SVG elements factory (memoized for perf)
|
|
68
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
const useHistoryElements = (fill: ColorValue) =>
|
|
71
|
+
useMemo(() => {
|
|
72
|
+
const elements: React.ReactElement[] = [];
|
|
73
|
+
let currentY = PADDING;
|
|
74
|
+
|
|
75
|
+
// Chat history sections
|
|
76
|
+
for (let sectionIndex = 0; sectionIndex < SECTIONS_COUNT; sectionIndex++) {
|
|
77
|
+
// Section header (Today, Yesterday, etc.)
|
|
78
|
+
elements.push(
|
|
79
|
+
<Rect
|
|
80
|
+
key={`section-${sectionIndex}`}
|
|
81
|
+
x={PADDING}
|
|
82
|
+
y={currentY}
|
|
83
|
+
width={60 + sectionIndex * 20} // Varying widths for different date labels
|
|
84
|
+
height={SECTION_HEADER_HEIGHT}
|
|
85
|
+
rx={SECTION_HEADER_HEIGHT / 2}
|
|
86
|
+
fill={fill as string}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
currentY += SECTION_HEADER_HEIGHT + SECTION_SPACING;
|
|
90
|
+
|
|
91
|
+
// Messages in this section
|
|
92
|
+
for (let messageIndex = 0; messageIndex < MESSAGES_PER_SECTION; messageIndex++) {
|
|
93
|
+
const messageWidth = SCREEN_WIDTH - PADDING * 2 - (messageIndex * 30); // Varying message widths
|
|
94
|
+
elements.push(
|
|
95
|
+
<Rect
|
|
96
|
+
key={`message-${sectionIndex}-${messageIndex}`}
|
|
97
|
+
x={PADDING}
|
|
98
|
+
y={currentY}
|
|
99
|
+
width={Math.max(messageWidth, SCREEN_WIDTH * 0.4)} // Minimum width
|
|
100
|
+
height={MESSAGE_HEIGHT}
|
|
101
|
+
rx={MESSAGE_HEIGHT / 2}
|
|
102
|
+
fill={fill as string}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
currentY += MESSAGE_HEIGHT + MESSAGE_SPACING;
|
|
106
|
+
}
|
|
107
|
+
currentY += 10; // Extra spacing between sections
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return elements;
|
|
111
|
+
}, [fill]);
|
|
112
|
+
|
|
113
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
114
|
+
// Component Implementation
|
|
115
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
export const Skeleton: React.FC<SkeletonProps> = ({ style }) => {
|
|
118
|
+
const theme = useTheme();
|
|
119
|
+
const get = <K extends keyof SkeletonStyle>(key: K) => getStyleValue(key, style, theme);
|
|
120
|
+
|
|
121
|
+
// Shimmer animation ------------------------------------------
|
|
122
|
+
const translate = useRef(new Animated.Value(0)).current;
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const speed = get("speed");
|
|
126
|
+
const duration = 1000 / speed;
|
|
127
|
+
const loop = Animated.loop(
|
|
128
|
+
Animated.timing(translate, {
|
|
129
|
+
toValue: 1,
|
|
130
|
+
duration,
|
|
131
|
+
easing: Easing.linear,
|
|
132
|
+
useNativeDriver: false, // SVG not yet compatible with native driver
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
loop.start();
|
|
137
|
+
return () => loop.stop();
|
|
138
|
+
}, [get, translate]);
|
|
139
|
+
|
|
140
|
+
const translateX = translate.interpolate({
|
|
141
|
+
inputRange: [0, 1],
|
|
142
|
+
outputRange: [-SCREEN_WIDTH * 2, SCREEN_WIDTH],
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Pre‑build elements (bottom gradient + top mask)
|
|
146
|
+
const elementsGradient = useHistoryElements("url(#gradient)");
|
|
147
|
+
const elementsSolid = useHistoryElements(String(get("backgroundColor")));
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<ScrollView
|
|
151
|
+
scrollEnabled={false}
|
|
152
|
+
showsVerticalScrollIndicator={false}
|
|
153
|
+
style={{ backgroundColor: get("containerBackgroundColor") }}
|
|
154
|
+
>
|
|
155
|
+
{/* Bottom layer (gradient fill) */}
|
|
156
|
+
<Svg
|
|
157
|
+
height={TOTAL_HEIGHT}
|
|
158
|
+
width={SCREEN_WIDTH}
|
|
159
|
+
fill='none'
|
|
160
|
+
preserveAspectRatio='xMidYMid meet'
|
|
161
|
+
>
|
|
162
|
+
<Defs>
|
|
163
|
+
<LinearGradient
|
|
164
|
+
id='gradient'
|
|
165
|
+
x1='0'
|
|
166
|
+
y1='0'
|
|
167
|
+
x2={SCREEN_WIDTH}
|
|
168
|
+
y2='0'
|
|
169
|
+
gradientUnits='userSpaceOnUse'
|
|
170
|
+
>
|
|
171
|
+
{(() => {
|
|
172
|
+
const colors = get("linearGradientColors");
|
|
173
|
+
return [
|
|
174
|
+
<Stop key={0} stopColor={colors[0]} />,
|
|
175
|
+
<Stop key={1} offset='1' stopColor={colors[1]} />,
|
|
176
|
+
];
|
|
177
|
+
})()}
|
|
178
|
+
</LinearGradient>
|
|
179
|
+
</Defs>
|
|
180
|
+
{elementsGradient}
|
|
181
|
+
</Svg>
|
|
182
|
+
|
|
183
|
+
{/* Moving shimmer highlight (rendered twice for coverage) */}
|
|
184
|
+
{[0, SCREEN_WIDTH / 2].map((offset) => (
|
|
185
|
+
<Animated.View
|
|
186
|
+
key={offset}
|
|
187
|
+
style={[
|
|
188
|
+
styles.shimmer,
|
|
189
|
+
{
|
|
190
|
+
transform: [
|
|
191
|
+
{ translateX: Animated.add(translateX, offset) },
|
|
192
|
+
{ translateY: -20 },
|
|
193
|
+
{ rotate: "15deg" },
|
|
194
|
+
],
|
|
195
|
+
backgroundColor: get("shimmerBackgroundColor"),
|
|
196
|
+
opacity: get("shimmerOpacity"),
|
|
197
|
+
},
|
|
198
|
+
]}
|
|
199
|
+
/>
|
|
200
|
+
))}
|
|
201
|
+
|
|
202
|
+
{/* Top mask – solid shapes clip the shimmer to elements */}
|
|
203
|
+
<View style={StyleSheet.absoluteFill} pointerEvents='none'>
|
|
204
|
+
<Svg
|
|
205
|
+
height={TOTAL_HEIGHT}
|
|
206
|
+
width={SCREEN_WIDTH}
|
|
207
|
+
fill='none'
|
|
208
|
+
preserveAspectRatio='xMidYMid meet'
|
|
209
|
+
>
|
|
210
|
+
{elementsSolid}
|
|
211
|
+
</Svg>
|
|
212
|
+
</View>
|
|
213
|
+
</ScrollView>
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
218
|
+
// Styles
|
|
219
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
220
|
+
|
|
221
|
+
const styles = StyleSheet.create({
|
|
222
|
+
shimmer: {
|
|
223
|
+
position: "absolute",
|
|
224
|
+
width: "25%", // thin bar for highlight
|
|
225
|
+
top: 0,
|
|
226
|
+
bottom: 0,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ColorValue, ViewStyle, TextStyle } from "react-native";
|
|
2
|
+
import { deepMerge } from "../shared/helper/helperFunctions";
|
|
3
|
+
import { CometChatTheme } from "../theme/type";
|
|
4
|
+
import { DeepPartial } from "../shared/helper/types";
|
|
5
|
+
|
|
6
|
+
export type ChatHistoryStyle = {
|
|
7
|
+
containerStyle: ViewStyle;
|
|
8
|
+
headerStyle: ViewStyle;
|
|
9
|
+
headerContentStyle: ViewStyle;
|
|
10
|
+
headerTitleStyle: TextStyle;
|
|
11
|
+
closeButtonStyle: ViewStyle;
|
|
12
|
+
closeButtonTextStyle: TextStyle;
|
|
13
|
+
newChatButtonStyle: ViewStyle;
|
|
14
|
+
newChatTextStyle: TextStyle;
|
|
15
|
+
listContainerStyle: ViewStyle;
|
|
16
|
+
sectionHeaderStyle: ViewStyle;
|
|
17
|
+
sectionHeaderTextStyle: TextStyle;
|
|
18
|
+
messageItemStyle: ViewStyle;
|
|
19
|
+
messageTextStyle: TextStyle;
|
|
20
|
+
centerContainerStyle: ViewStyle;
|
|
21
|
+
stateTitleStyle: TextStyle;
|
|
22
|
+
stateTextStyle: TextStyle;
|
|
23
|
+
footerLoaderStyle: ViewStyle;
|
|
24
|
+
skeletonStyle: {
|
|
25
|
+
linearGradientColors: [string, string];
|
|
26
|
+
shimmerBackgroundColor: ColorValue;
|
|
27
|
+
shimmerOpacity: number;
|
|
28
|
+
speed: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const getChatHistoryStyleLight = (
|
|
33
|
+
color: CometChatTheme["color"],
|
|
34
|
+
spacing: CometChatTheme["spacing"],
|
|
35
|
+
typography: CometChatTheme["typography"]
|
|
36
|
+
): DeepPartial<ChatHistoryStyle> => {
|
|
37
|
+
return {
|
|
38
|
+
containerStyle: {
|
|
39
|
+
flex: 1,
|
|
40
|
+
backgroundColor: color.background3,
|
|
41
|
+
},
|
|
42
|
+
headerStyle: {
|
|
43
|
+
paddingTop: spacing.padding.p4,
|
|
44
|
+
paddingBottom: spacing.padding.p4,
|
|
45
|
+
backgroundColor: color.background3,
|
|
46
|
+
},
|
|
47
|
+
headerContentStyle: {
|
|
48
|
+
flexDirection: 'row',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
paddingHorizontal: spacing.padding.p3,
|
|
51
|
+
borderBottomColor: color.borderDefault,
|
|
52
|
+
borderBottomWidth: 1,
|
|
53
|
+
paddingBottom: spacing.padding.p4,
|
|
54
|
+
width: '100%',
|
|
55
|
+
},
|
|
56
|
+
headerTitleStyle: {
|
|
57
|
+
fontSize: typography.heading4.medium.fontSize,
|
|
58
|
+
fontWeight: typography.heading4.medium.fontWeight,
|
|
59
|
+
color: color.textPrimary,
|
|
60
|
+
marginLeft: spacing.margin.m2,
|
|
61
|
+
...typography.heading4.medium,
|
|
62
|
+
fontFamily: typography.heading4.medium.fontFamily,
|
|
63
|
+
},
|
|
64
|
+
closeButtonStyle: {
|
|
65
|
+
width: 32,
|
|
66
|
+
height: 32,
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
},
|
|
70
|
+
closeButtonTextStyle: {
|
|
71
|
+
fontSize: 18,
|
|
72
|
+
color: color.textSecondary,
|
|
73
|
+
},
|
|
74
|
+
newChatButtonStyle: {
|
|
75
|
+
flexDirection: 'row',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
paddingHorizontal: spacing.padding.p4,
|
|
78
|
+
paddingVertical: spacing.padding.p2,
|
|
79
|
+
marginBottom: spacing.margin.m2,
|
|
80
|
+
backgroundColor: color.background3,
|
|
81
|
+
},
|
|
82
|
+
newChatTextStyle: {
|
|
83
|
+
fontSize: typography.body.regular.fontSize,
|
|
84
|
+
marginLeft: spacing.margin.m3,
|
|
85
|
+
fontWeight: typography.body.regular.fontWeight,
|
|
86
|
+
color: color.textPrimary,
|
|
87
|
+
...typography.body.regular,
|
|
88
|
+
},
|
|
89
|
+
listContainerStyle: {
|
|
90
|
+
paddingHorizontal: spacing.padding.p5,
|
|
91
|
+
},
|
|
92
|
+
sectionHeaderStyle: {
|
|
93
|
+
paddingVertical: spacing.padding.p2,
|
|
94
|
+
backgroundColor: color.background3,
|
|
95
|
+
borderBottomWidth: 1,
|
|
96
|
+
borderBottomColor: color.borderLight,
|
|
97
|
+
},
|
|
98
|
+
sectionHeaderTextStyle: {
|
|
99
|
+
fontSize: typography.caption1.medium.fontSize,
|
|
100
|
+
fontWeight: typography.caption1.medium.fontWeight,
|
|
101
|
+
textTransform: 'capitalize',
|
|
102
|
+
color: color.textTertiary,
|
|
103
|
+
...typography.caption1.medium,
|
|
104
|
+
},
|
|
105
|
+
messageItemStyle: {
|
|
106
|
+
paddingVertical: spacing.padding.p3,
|
|
107
|
+
},
|
|
108
|
+
messageTextStyle: {
|
|
109
|
+
fontSize: typography.body.regular.fontSize,
|
|
110
|
+
lineHeight: 20,
|
|
111
|
+
color: color.textPrimary,
|
|
112
|
+
...typography.body.regular,
|
|
113
|
+
},
|
|
114
|
+
centerContainerStyle: {
|
|
115
|
+
flex: 1,
|
|
116
|
+
justifyContent: 'center',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
padding: spacing.padding.p5,
|
|
119
|
+
backgroundColor: color.background3,
|
|
120
|
+
},
|
|
121
|
+
stateTitleStyle: {
|
|
122
|
+
fontSize: 18,
|
|
123
|
+
fontWeight: 'bold',
|
|
124
|
+
marginBottom: spacing.margin.m2,
|
|
125
|
+
color: color.textPrimary,
|
|
126
|
+
...typography.heading3.bold,
|
|
127
|
+
},
|
|
128
|
+
stateTextStyle: {
|
|
129
|
+
fontSize: 16,
|
|
130
|
+
textAlign: 'center',
|
|
131
|
+
color: color.textSecondary,
|
|
132
|
+
...typography.body.regular,
|
|
133
|
+
},
|
|
134
|
+
footerLoaderStyle: {
|
|
135
|
+
paddingVertical: spacing.padding.p4,
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
},
|
|
138
|
+
skeletonStyle: {
|
|
139
|
+
linearGradientColors: ["#E8E8E8", "#F5F5F5"],
|
|
140
|
+
shimmerBackgroundColor: color.background3,
|
|
141
|
+
shimmerOpacity: 0.01,
|
|
142
|
+
speed: 0.1,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const getChatHistoryStyleDark = (
|
|
148
|
+
color: CometChatTheme["color"],
|
|
149
|
+
spacing: CometChatTheme["spacing"],
|
|
150
|
+
typography: CometChatTheme["typography"]
|
|
151
|
+
): DeepPartial<ChatHistoryStyle> => {
|
|
152
|
+
return deepMerge(getChatHistoryStyleLight(color, spacing, typography), {
|
|
153
|
+
skeletonStyle: {
|
|
154
|
+
linearGradientColors: ["#383838", "#272727"],
|
|
155
|
+
shimmerBackgroundColor: color.background3,
|
|
156
|
+
shimmerOpacity: 0.01,
|
|
157
|
+
speed: 0.1,
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
};
|
|
@@ -1507,7 +1507,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1507
1507
|
const withObj = conv.getConversationWith();
|
|
1508
1508
|
const avatarURL = withObj instanceof CometChat.User ? withObj.getAvatar() : withObj.getIcon();
|
|
1509
1509
|
const name = withObj.getName();
|
|
1510
|
-
|
|
1510
|
+
|
|
1511
1511
|
return (
|
|
1512
1512
|
<>
|
|
1513
1513
|
<CometChatAvatar
|
|
@@ -1526,19 +1526,45 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1526
1526
|
);
|
|
1527
1527
|
|
|
1528
1528
|
const TitleViewRaw = useCallback(
|
|
1529
|
-
(conv: CometChat.Conversation) =>
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1529
|
+
(conv: CometChat.Conversation) => {
|
|
1530
|
+
const conversationWith = conv.getConversationWith();
|
|
1531
|
+
const isAgentic = conversationWith instanceof CometChat.User && conversationWith.getRole() === "@agentic";
|
|
1532
|
+
|
|
1533
|
+
return (
|
|
1534
|
+
<View style={[
|
|
1535
|
+
{ flex: 1 },
|
|
1536
|
+
isAgentic ? { justifyContent: 'center' } : null
|
|
1537
|
+
]}>
|
|
1538
|
+
<Text
|
|
1539
|
+
numberOfLines={1}
|
|
1540
|
+
ellipsizeMode='tail'
|
|
1541
|
+
style={mergedStyles.itemStyle.titleStyle}
|
|
1542
|
+
>
|
|
1543
|
+
{conversationWith.getName()}
|
|
1544
|
+
</Text>
|
|
1545
|
+
</View>
|
|
1546
|
+
);
|
|
1547
|
+
},
|
|
1534
1548
|
[mergedStyles]
|
|
1535
1549
|
);
|
|
1536
1550
|
|
|
1537
|
-
const SubtitleViewRaw = (conv: CometChat.Conversation) =>
|
|
1538
|
-
|
|
1539
|
-
|
|
1551
|
+
const SubtitleViewRaw = (conv: CometChat.Conversation) => {
|
|
1552
|
+
const conversationWith = conv.getConversationWith();
|
|
1553
|
+
if (conversationWith instanceof CometChat.User && conversationWith.getRole() === "@agentic") {
|
|
1554
|
+
return <></>;
|
|
1555
|
+
}
|
|
1556
|
+
return (
|
|
1557
|
+
<LastMessageView conversations={conv} typingText={conv?.["lastMessage"]?.["typing"]} />
|
|
1558
|
+
);
|
|
1559
|
+
};
|
|
1540
1560
|
|
|
1541
|
-
const TrailingViewRaw = useCallback((conv: CometChat.Conversation) =>
|
|
1561
|
+
const TrailingViewRaw = useCallback((conv: CometChat.Conversation) => {
|
|
1562
|
+
const conversationWith = conv.getConversationWith();
|
|
1563
|
+
if (conversationWith instanceof CometChat.User && conversationWith.getRole() === "@agentic") {
|
|
1564
|
+
return <></>;
|
|
1565
|
+
}
|
|
1566
|
+
return getTrailingView(conv);
|
|
1567
|
+
}, [getTrailingView]);
|
|
1542
1568
|
|
|
1543
1569
|
return (
|
|
1544
1570
|
<View style={mergedStyles.containerStyle}>
|