@cometchat/chat-uikit-react-native 5.0.0-beta.1 → 5.0.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/README.md +2 -3
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +29 -44
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +12 -0
- package/ios/FileManager.m +26 -9
- package/package.json +11 -36
- package/src/CometChatConversations/CometChatConversations.tsx +287 -147
- package/src/CometChatConversations/Skeleton.tsx +116 -73
- package/src/CometChatConversations/style.ts +17 -22
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +439 -227
- package/src/CometChatGroupMembers/style.ts +2 -4
- package/src/CometChatGroups/CometChatGroups.tsx +239 -135
- package/src/CometChatGroups/GroupsStyle.ts +20 -17
- package/src/CometChatGroups/Skeleton.tsx +198 -288
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +208 -73
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +97 -43
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -2
- package/src/CometChatMessageList/CometChatMessageList.tsx +200 -76
- package/src/CometChatMessageList/style.ts +4 -4
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +77 -11
- package/src/CometChatThreadHeader/style.ts +2 -2
- package/src/CometChatUsers/CometChatUsers.tsx +203 -51
- package/src/CometChatUsers/Skeleton.tsx +174 -159
- package/src/CometChatUsers/style.ts +21 -18
- package/src/calls/CallingConfiguration.ts +4 -3
- package/src/calls/CallingExtensionDecorator.tsx +5 -3
- package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +4 -2
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +10 -8
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +240 -97
- package/src/calls/CometChatCallLogs/Skeleton.tsx +175 -91
- package/src/calls/CometChatCallLogs/index.ts +1 -0
- package/src/calls/CometChatCallLogs/style.ts +85 -43
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +42 -29
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +36 -10
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +39 -12
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -4
- package/src/extensions/Polls/PollsDecorator.tsx +30 -9
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +34 -16
- package/src/index.ts +3 -1
- package/src/shared/base/Types.ts +31 -1
- package/src/shared/framework/DataSource.ts +64 -20
- package/src/shared/framework/DataSourceDecorator.tsx +46 -37
- package/src/shared/framework/MessageDataSource.tsx +518 -316
- package/src/shared/index.ts +3 -1
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +3 -2
- package/src/shared/utils/MessageUtils.tsx +41 -20
- package/src/shared/utils/conversationUtils.ts +2 -2
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +22 -1
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +20 -8
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +177 -123
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +76 -10
- package/src/shared/views/CometChatConfirmDialog/style.ts +2 -2
- package/src/shared/views/CometChatDate/CometChatDate.tsx +26 -18
- package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +22 -16
- package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +17 -5
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +65 -35
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +22 -11
- package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +47 -18
- package/src/shared/views/CometChatList/CometChatList.tsx +70 -46
- package/src/shared/views/CometChatList/Header.tsx +122 -37
- package/src/shared/views/CometChatList/styles.ts +1 -0
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +116 -30
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +52 -30
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +36 -22
- package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +41 -13
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +132 -17
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +30 -2
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +10 -6
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +20 -13
- package/src/shared/views/CometChatStatusIndicator/styles.ts +26 -13
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +25 -2
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +94 -14
- package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +52 -16
- package/src/shared/views/CometChatTooltipMenu/index.ts +2 -1
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +29 -9
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +20 -2
- package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +29 -14
- package/src/shared/views/index.ts +2 -0
- package/src/theme/default/index.ts +5 -5
- package/src/theme/type.ts +2 -2
- package/src/shared/views/CometChatPanel/CometChatPanel.tsx +0 -57
- package/src/shared/views/CometChatPanel/PanelStyle.tsx +0 -43
- package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
- package/src/shared/views/CometChatPanel/resources/index.ts +0 -3
|
@@ -6,11 +6,12 @@ import { DeepPartial } from "../shared/helper/types";
|
|
|
6
6
|
|
|
7
7
|
export type GroupStyle = CometChatListStylesInterface & {
|
|
8
8
|
skeletonStyle: {
|
|
9
|
-
|
|
10
|
-
linearGradientColors
|
|
11
|
-
shimmerBackgroundColor
|
|
12
|
-
shimmerOpacity
|
|
13
|
-
speed
|
|
9
|
+
backgroundColor?: ColorValue;
|
|
10
|
+
linearGradientColors?: [string, string];
|
|
11
|
+
shimmerBackgroundColor?: ColorValue;
|
|
12
|
+
shimmerOpacity?: number;
|
|
13
|
+
speed?: number;
|
|
14
|
+
containerBackgroundColor?: ColorValue;
|
|
14
15
|
};
|
|
15
16
|
headerContainerStyle: ViewStyle;
|
|
16
17
|
};
|
|
@@ -67,10 +68,8 @@ export const getGroupListStyleLight = (
|
|
|
67
68
|
},
|
|
68
69
|
trailingViewContainerStyle: {},
|
|
69
70
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
cancellationIcon: undefined,
|
|
73
|
-
cancellationIconStyle: {},
|
|
71
|
+
selectionCancelStyle: {},
|
|
72
|
+
confirmSelectionStyle: {},
|
|
74
73
|
loadingIconTint: color.primary,
|
|
75
74
|
sectionHeaderTextStyle: {
|
|
76
75
|
display: "none",
|
|
@@ -136,6 +135,13 @@ export const getGroupListStyleLight = (
|
|
|
136
135
|
},
|
|
137
136
|
},
|
|
138
137
|
errorStateStyle: {
|
|
138
|
+
containerStyle: {
|
|
139
|
+
flex: 1,
|
|
140
|
+
justifyContent: "center",
|
|
141
|
+
alignItems: "center",
|
|
142
|
+
paddingHorizontal: "10%",
|
|
143
|
+
flexDirection: "column",
|
|
144
|
+
},
|
|
139
145
|
titleStyle: {
|
|
140
146
|
color: color.textPrimary,
|
|
141
147
|
...typography.heading3.bold,
|
|
@@ -143,17 +149,13 @@ export const getGroupListStyleLight = (
|
|
|
143
149
|
},
|
|
144
150
|
subTitleStyle: {
|
|
145
151
|
color: color.textSecondary,
|
|
146
|
-
textAlign: "center"
|
|
152
|
+
textAlign: "center",
|
|
147
153
|
...typography.body.regular,
|
|
148
154
|
},
|
|
149
|
-
containerStyle: {
|
|
150
|
-
justifyContent: "center",
|
|
151
|
-
alignItems: "center",
|
|
152
|
-
padding: spacing.padding.p3,
|
|
153
|
-
},
|
|
154
155
|
},
|
|
155
156
|
skeletonStyle: {
|
|
156
|
-
|
|
157
|
+
containerBackgroundColor: color.background1,
|
|
158
|
+
backgroundColor: "transparent",
|
|
157
159
|
linearGradientColors: ["#E8E8E8", "#F5F5F5"] as [string, string],
|
|
158
160
|
shimmerBackgroundColor: color.staticBlack,
|
|
159
161
|
shimmerOpacity: 0.01,
|
|
@@ -169,11 +171,12 @@ export const getUserGroupStyleDark = (
|
|
|
169
171
|
): DeepPartial<GroupStyle> => {
|
|
170
172
|
return deepMerge(getGroupListStyleLight(color, spacing, typography), {
|
|
171
173
|
skeletonStyle: {
|
|
172
|
-
|
|
174
|
+
backgroundColor: "transparent",
|
|
173
175
|
linearGradientColors: ["#383838", "#272727"] as [string, string],
|
|
174
176
|
shimmerBackgroundColor: color.staticWhite,
|
|
175
177
|
shimmerOpacity: 0.01,
|
|
176
178
|
speed: 1,
|
|
179
|
+
containerBackgroundColor: color.background1,
|
|
177
180
|
},
|
|
178
181
|
});
|
|
179
182
|
};
|
|
@@ -1,328 +1,238 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
Dimensions,
|
|
5
|
+
Easing,
|
|
6
|
+
ScrollView,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
View,
|
|
9
|
+
} from "react-native";
|
|
3
10
|
import Svg, { Circle, Defs, LinearGradient, Rect, Stop } from "react-native-svg";
|
|
4
11
|
import { useTheme } from "../theme";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const itemY =
|
|
92
|
-
padding +
|
|
12
|
+
import { CometChatTheme } from "../theme/type";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* React‑Native skeleton list with animated shimmer.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* The component respects the brand/theme defaults defined in
|
|
19
|
+
* `theme.groupStyles.skeletonStyle` but allows **per‑instance overrides** via the
|
|
20
|
+
* `style` prop.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Skeleton
|
|
25
|
+
* style={{
|
|
26
|
+
* linearGradientColors: ["#eee", "#ddd"],
|
|
27
|
+
* backgroundColor: "#444",
|
|
28
|
+
* }}
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export interface SkeletonProps {
|
|
33
|
+
/**
|
|
34
|
+
* Partial style overrides. Any omitted property falls back to the theme
|
|
35
|
+
* default.
|
|
36
|
+
*/
|
|
37
|
+
style?: Partial<SkeletonStyle>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
41
|
+
// Theme typing helpers
|
|
42
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
/** Convenience alias for the skeleton style slice in the theme object. */
|
|
45
|
+
type SkeletonStyle = CometChatTheme["groupStyles"]["skeletonStyle"];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Utility to resolve a style value with **theme‑fallback**.
|
|
49
|
+
*
|
|
50
|
+
* @param key – The style property being resolved.
|
|
51
|
+
* @param overrides – Optional user overrides (`props.style`).
|
|
52
|
+
* @param theme – Current theme object.
|
|
53
|
+
* @returns The resolved style value.
|
|
54
|
+
*/
|
|
55
|
+
function resolveStyleValue<K extends keyof SkeletonStyle>(
|
|
56
|
+
key: K,
|
|
57
|
+
overrides: Partial<SkeletonStyle> | undefined,
|
|
58
|
+
theme: CometChatTheme
|
|
59
|
+
): SkeletonStyle[K] {
|
|
60
|
+
return (overrides?.[key] as SkeletonStyle[K]) ?? theme.groupStyles.skeletonStyle[key];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
64
|
+
// Layout constants – tweak here if the design changes
|
|
65
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
const { width: SCREEN_WIDTH } = Dimensions.get("window");
|
|
68
|
+
|
|
69
|
+
const PADDING = 20;
|
|
70
|
+
const AVATAR_RADIUS = 25;
|
|
71
|
+
const LIST_ITEM_HEIGHT = 25;
|
|
72
|
+
const LIST_ITEM_SUBTITLE_HEIGHT = 20;
|
|
73
|
+
const LIST_ITEM_SUBTITLE_SPACING = 10;
|
|
74
|
+
const LIST_ITEM_SPACING = 30;
|
|
75
|
+
const LIST_ITEM_COUNT = 14;
|
|
76
|
+
|
|
77
|
+
/** Total SVG height required to render all placeholder rows. */
|
|
78
|
+
const TOTAL_HEIGHT =
|
|
79
|
+
PADDING +
|
|
80
|
+
LIST_ITEM_COUNT *
|
|
81
|
+
(LIST_ITEM_HEIGHT + LIST_ITEM_SUBTITLE_SPACING + LIST_ITEM_SUBTITLE_HEIGHT + LIST_ITEM_SPACING);
|
|
82
|
+
|
|
83
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
84
|
+
// SVG building blocks
|
|
85
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Generates the repetitive row shapes used by both bottom and top layers.
|
|
89
|
+
*
|
|
90
|
+
* @param fill – The fill used for rectangles & circles in this layer.
|
|
91
|
+
*/
|
|
92
|
+
const useRowShapes = (fill: string) =>
|
|
93
|
+
useMemo(
|
|
94
|
+
() =>
|
|
95
|
+
Array.from({ length: LIST_ITEM_COUNT }).map((_, index) => {
|
|
96
|
+
const baseY =
|
|
97
|
+
PADDING +
|
|
93
98
|
index *
|
|
94
|
-
(
|
|
99
|
+
(LIST_ITEM_HEIGHT + LIST_ITEM_SUBTITLE_SPACING + LIST_ITEM_SUBTITLE_HEIGHT + LIST_ITEM_SPACING) -
|
|
95
100
|
10;
|
|
96
101
|
|
|
97
102
|
return (
|
|
98
103
|
<React.Fragment key={index}>
|
|
99
|
-
{/* Avatar Circle */}
|
|
100
104
|
<Circle
|
|
101
|
-
cx={
|
|
102
|
-
cy={
|
|
103
|
-
r={
|
|
104
|
-
fill=
|
|
105
|
+
cx={PADDING + AVATAR_RADIUS}
|
|
106
|
+
cy={baseY + AVATAR_RADIUS}
|
|
107
|
+
r={AVATAR_RADIUS}
|
|
108
|
+
fill={fill}
|
|
105
109
|
/>
|
|
106
|
-
|
|
107
|
-
{/* Username Rectangle */}
|
|
108
110
|
<Rect
|
|
109
|
-
x={
|
|
110
|
-
y={
|
|
111
|
-
width={
|
|
112
|
-
height={
|
|
113
|
-
rx={
|
|
114
|
-
fill=
|
|
111
|
+
x={PADDING + 2 * AVATAR_RADIUS + 12}
|
|
112
|
+
y={baseY}
|
|
113
|
+
width={SCREEN_WIDTH - (PADDING + 2 * AVATAR_RADIUS + 12 + PADDING)}
|
|
114
|
+
height={LIST_ITEM_HEIGHT}
|
|
115
|
+
rx={LIST_ITEM_HEIGHT / 2}
|
|
116
|
+
fill={fill}
|
|
115
117
|
/>
|
|
116
|
-
|
|
117
|
-
{/* Subtitle Rectangle */}
|
|
118
118
|
<Rect
|
|
119
|
-
x={
|
|
120
|
-
y={
|
|
121
|
-
width={
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
x={PADDING + 2 * AVATAR_RADIUS + 12}
|
|
120
|
+
y={baseY + LIST_ITEM_HEIGHT + LIST_ITEM_SUBTITLE_SPACING}
|
|
121
|
+
width={
|
|
122
|
+
(SCREEN_WIDTH - (PADDING + 2 * AVATAR_RADIUS + 12 + PADDING)) * 0.6 /* 60% width */
|
|
123
|
+
}
|
|
124
|
+
height={LIST_ITEM_SUBTITLE_HEIGHT}
|
|
125
|
+
rx={LIST_ITEM_SUBTITLE_HEIGHT / 2}
|
|
126
|
+
fill={fill}
|
|
125
127
|
/>
|
|
126
128
|
</React.Fragment>
|
|
127
129
|
);
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
{/* Gradient Definition */}
|
|
131
|
-
<Defs>
|
|
132
|
-
<LinearGradient
|
|
133
|
-
id='paint0_linear'
|
|
134
|
-
x1='0'
|
|
135
|
-
y1='0'
|
|
136
|
-
x2={screenWidth}
|
|
137
|
-
y2='0'
|
|
138
|
-
gradientUnits='userSpaceOnUse'
|
|
139
|
-
>
|
|
140
|
-
<Stop stopColor={theme.groupStyles.skeletonStyle.linearGradientColors[0]} />
|
|
141
|
-
<Stop offset='1' stopColor={theme.groupStyles.skeletonStyle.linearGradientColors[1]} />
|
|
142
|
-
</LinearGradient>
|
|
143
|
-
</Defs>
|
|
144
|
-
</Svg>
|
|
130
|
+
}),
|
|
131
|
+
[fill]
|
|
145
132
|
);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const SkeletonItemTop = () => {
|
|
149
|
-
const theme = useTheme();
|
|
150
|
-
|
|
151
|
-
const totalHeight = calculateTotalHeight();
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<Svg height={totalHeight} width={screenWidth} fill='none' preserveAspectRatio='xMidYMid meet'>
|
|
155
|
-
{/* Header Rectangle */}
|
|
156
|
-
{/* <Rect
|
|
157
|
-
x={padding + 5}
|
|
158
|
-
y={padding}
|
|
159
|
-
width={screenWidth * 0.5}
|
|
160
|
-
height={headerHeight}
|
|
161
|
-
rx={6}
|
|
162
|
-
fill={theme.groupStyles.skeletonStyle.backgroudColor}
|
|
163
|
-
/> */}
|
|
164
|
-
|
|
165
|
-
{/* Separator Line */}
|
|
166
|
-
{/* <Rect
|
|
167
|
-
x={padding}
|
|
168
|
-
y={padding + headerHeight + 12} // 12 units spacing below header
|
|
169
|
-
width={screenWidth - 2 * padding}
|
|
170
|
-
height={separatorHeight}
|
|
171
|
-
fill={theme.groupStyles.skeletonStyle.backgroudColor}
|
|
172
|
-
/> */}
|
|
173
|
-
|
|
174
|
-
{/* Content Rectangle with Semi-Circular Corners */}
|
|
175
|
-
{/* <Rect
|
|
176
|
-
x={padding}
|
|
177
|
-
y={padding + headerHeight + 12 + separatorHeight + 12} // Position below separator with spacing
|
|
178
|
-
width={screenWidth - 2 * padding}
|
|
179
|
-
height={contentRectHeight}
|
|
180
|
-
rx={contentRectHeight / 2} // Semi-circular corners
|
|
181
|
-
ry={contentRectHeight / 2} // Ensures vertical radius matches
|
|
182
|
-
fill={theme.groupStyles.skeletonStyle.backgroudColor}
|
|
183
|
-
/> */}
|
|
184
133
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
// padding +
|
|
189
|
-
// headerHeight +
|
|
190
|
-
// 12 +
|
|
191
|
-
// separatorHeight +
|
|
192
|
-
// 12 +
|
|
193
|
-
// contentRectHeight +
|
|
194
|
-
// 24 +
|
|
195
|
-
// index *
|
|
196
|
-
// (listItemHeight + listItemSubtitleSpacing + listItemSubtitleHeight + listItemSpacing);
|
|
134
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
135
|
+
// Component implementation
|
|
136
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
197
137
|
|
|
198
|
-
|
|
199
|
-
padding +
|
|
200
|
-
index *
|
|
201
|
-
(listItemHeight + listItemSubtitleSpacing + listItemSubtitleHeight + listItemSpacing) -
|
|
202
|
-
10;
|
|
203
|
-
|
|
204
|
-
return (
|
|
205
|
-
<React.Fragment key={index}>
|
|
206
|
-
{/* Avatar Circle */}
|
|
207
|
-
<Circle
|
|
208
|
-
cx={padding + avatarRadius}
|
|
209
|
-
cy={itemY + avatarRadius}
|
|
210
|
-
r={avatarRadius}
|
|
211
|
-
fill={theme.groupStyles.skeletonStyle.backgroudColor}
|
|
212
|
-
/>
|
|
213
|
-
|
|
214
|
-
{/* Username Rectangle */}
|
|
215
|
-
<Rect
|
|
216
|
-
x={padding + 2 * avatarRadius + 12} // 12 units spacing after avatar
|
|
217
|
-
y={itemY}
|
|
218
|
-
width={screenWidth - (padding + 2 * avatarRadius + 12 + padding)}
|
|
219
|
-
height={listItemHeight}
|
|
220
|
-
rx={listItemHeight / 2} // Rounded corners matching height
|
|
221
|
-
fill={theme.groupStyles.skeletonStyle.backgroudColor}
|
|
222
|
-
/>
|
|
223
|
-
|
|
224
|
-
{/* Subtitle Rectangle */}
|
|
225
|
-
<Rect
|
|
226
|
-
x={padding + 2 * avatarRadius + 12}
|
|
227
|
-
y={itemY + listItemHeight + listItemSubtitleSpacing}
|
|
228
|
-
width={(screenWidth - (padding + 2 * avatarRadius + 12 + padding)) * 0.6} // 60% width for subtitle
|
|
229
|
-
height={listItemSubtitleHeight}
|
|
230
|
-
rx={listItemSubtitleHeight / 2}
|
|
231
|
-
fill={theme.groupStyles.skeletonStyle.backgroudColor}
|
|
232
|
-
/>
|
|
233
|
-
</React.Fragment>
|
|
234
|
-
);
|
|
235
|
-
})}
|
|
236
|
-
</Svg>
|
|
237
|
-
);
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
export const Skeleton = () => {
|
|
138
|
+
export const Skeleton: React.FC<SkeletonProps> = ({ style }) => {
|
|
241
139
|
const theme = useTheme();
|
|
242
|
-
const animatedValue = useRef(new Animated.Value(0)).current;
|
|
243
140
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
Animated.loop(
|
|
248
|
-
Animated.timing(animatedValue, {
|
|
249
|
-
toValue: 1,
|
|
250
|
-
duration: (1 / theme.groupStyles.skeletonStyle.speed) * 1000,
|
|
251
|
-
easing: Easing.linear,
|
|
252
|
-
useNativeDriver: false,
|
|
253
|
-
})
|
|
254
|
-
).start();
|
|
255
|
-
};
|
|
141
|
+
/** Resolved style helpers (with theme‑fallback). */
|
|
142
|
+
const get = <K extends keyof SkeletonStyle>(key: K) =>
|
|
143
|
+
resolveStyleValue(key, style, theme);
|
|
256
144
|
|
|
257
|
-
|
|
258
|
-
|
|
145
|
+
// Animated shimmer setup -----------------------------------------------------
|
|
146
|
+
const shimmerTranslate = useRef(new Animated.Value(0)).current;
|
|
259
147
|
|
|
260
|
-
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
const duration = 1000 / get("speed")!;
|
|
150
|
+
const loop = Animated.loop(
|
|
151
|
+
Animated.timing(shimmerTranslate, {
|
|
152
|
+
toValue: 1,
|
|
153
|
+
duration,
|
|
154
|
+
easing: Easing.linear,
|
|
155
|
+
useNativeDriver: false, // SVG cannot use native driver
|
|
156
|
+
})
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
loop.start();
|
|
160
|
+
return () => loop.stop(); // <‑‑ Prevent memory leaks on unmount
|
|
161
|
+
}, [get("speed"), shimmerTranslate]);
|
|
162
|
+
|
|
163
|
+
// Interpolated translation across the screen width
|
|
164
|
+
const translateX = shimmerTranslate.interpolate({
|
|
261
165
|
inputRange: [0, 1],
|
|
262
|
-
outputRange: [-
|
|
166
|
+
outputRange: [-SCREEN_WIDTH * 2, SCREEN_WIDTH],
|
|
263
167
|
});
|
|
264
168
|
|
|
169
|
+
// SVG layers ---------------------------------------------------------------
|
|
170
|
+
const rowShapesBottom = useRowShapes("url(#gradient)" /* gradient fill */);
|
|
171
|
+
const rowShapesTop = useRowShapes(get("backgroundColor") as string);
|
|
172
|
+
|
|
173
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
174
|
+
// Render
|
|
175
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
176
|
+
|
|
177
|
+
// Note: Providing a backgroundColor override will be used for the top mask layer,
|
|
178
|
+
// which may hide the gradient effect defined by linearGradientColors.
|
|
265
179
|
return (
|
|
266
180
|
<ScrollView
|
|
267
181
|
scrollEnabled={false}
|
|
268
182
|
showsVerticalScrollIndicator={false}
|
|
269
|
-
style={{ backgroundColor:
|
|
183
|
+
style={{ backgroundColor: get("containerBackgroundColor") }}
|
|
270
184
|
>
|
|
271
|
-
|
|
272
|
-
<
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
position: "absolute",
|
|
309
|
-
top: 0,
|
|
310
|
-
left: 0,
|
|
311
|
-
right: 0,
|
|
312
|
-
bottom: 0,
|
|
313
|
-
}}
|
|
314
|
-
>
|
|
315
|
-
<SkeletonItemTop />
|
|
185
|
+
{/* Bottom gradient layer */}
|
|
186
|
+
<Svg height={TOTAL_HEIGHT} width={SCREEN_WIDTH} fill="none" preserveAspectRatio="xMidYMid meet">
|
|
187
|
+
{/* Reusable linear gradient */}
|
|
188
|
+
<Defs>
|
|
189
|
+
<LinearGradient id="gradient" x1="0" y1="0" x2={SCREEN_WIDTH} y2="0" gradientUnits="userSpaceOnUse">
|
|
190
|
+
<Stop stopColor={get("linearGradientColors")![0]} />
|
|
191
|
+
<Stop offset="1" stopColor={get("linearGradientColors")![1]} />
|
|
192
|
+
</LinearGradient>
|
|
193
|
+
</Defs>
|
|
194
|
+
{rowShapesBottom}
|
|
195
|
+
</Svg>
|
|
196
|
+
|
|
197
|
+
{/* Shimmer highlight (runs twice for smoother effect) */}
|
|
198
|
+
{[0, SCREEN_WIDTH / 2].map((offset) => (
|
|
199
|
+
<Animated.View
|
|
200
|
+
// eslint‑disable‑next‑line react/no-array-index-key
|
|
201
|
+
key={offset}
|
|
202
|
+
style={[
|
|
203
|
+
styles.shimmer,
|
|
204
|
+
{
|
|
205
|
+
transform: [
|
|
206
|
+
{ translateX: Animated.add(translateX, offset) },
|
|
207
|
+
{ translateY: -20 },
|
|
208
|
+
{ rotate: "15deg" },
|
|
209
|
+
],
|
|
210
|
+
backgroundColor: get("shimmerBackgroundColor"),
|
|
211
|
+
opacity: get("shimmerOpacity"),
|
|
212
|
+
},
|
|
213
|
+
]}
|
|
214
|
+
/>
|
|
215
|
+
))}
|
|
216
|
+
|
|
217
|
+
{/* Top solid layer (masks shimmer to placeholder shapes) */}
|
|
218
|
+
<View style={StyleSheet.absoluteFill} pointerEvents="none">
|
|
219
|
+
<Svg height={TOTAL_HEIGHT} width={SCREEN_WIDTH} fill="none" preserveAspectRatio="xMidYMid meet">
|
|
220
|
+
{rowShapesTop}
|
|
221
|
+
</Svg>
|
|
316
222
|
</View>
|
|
317
223
|
</ScrollView>
|
|
318
224
|
);
|
|
319
225
|
};
|
|
320
226
|
|
|
227
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
228
|
+
// Styles
|
|
229
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
230
|
+
|
|
321
231
|
const styles = StyleSheet.create({
|
|
322
|
-
|
|
323
|
-
|
|
232
|
+
shimmer: {
|
|
233
|
+
position: "absolute",
|
|
234
|
+
width: "25%", // Narrow highlight bar
|
|
324
235
|
top: 0,
|
|
325
236
|
bottom: 0,
|
|
326
|
-
position: "absolute",
|
|
327
237
|
},
|
|
328
238
|
});
|