@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.
Files changed (98) hide show
  1. package/README.md +2 -3
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +29 -44
  5. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +12 -0
  6. package/ios/FileManager.m +26 -9
  7. package/package.json +11 -36
  8. package/src/CometChatConversations/CometChatConversations.tsx +287 -147
  9. package/src/CometChatConversations/Skeleton.tsx +116 -73
  10. package/src/CometChatConversations/style.ts +17 -22
  11. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +439 -227
  12. package/src/CometChatGroupMembers/style.ts +2 -4
  13. package/src/CometChatGroups/CometChatGroups.tsx +239 -135
  14. package/src/CometChatGroups/GroupsStyle.ts +20 -17
  15. package/src/CometChatGroups/Skeleton.tsx +198 -288
  16. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +208 -73
  17. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +97 -43
  18. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -2
  19. package/src/CometChatMessageList/CometChatMessageList.tsx +200 -76
  20. package/src/CometChatMessageList/style.ts +4 -4
  21. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +77 -11
  22. package/src/CometChatThreadHeader/style.ts +2 -2
  23. package/src/CometChatUsers/CometChatUsers.tsx +203 -51
  24. package/src/CometChatUsers/Skeleton.tsx +174 -159
  25. package/src/CometChatUsers/style.ts +21 -18
  26. package/src/calls/CallingConfiguration.ts +4 -3
  27. package/src/calls/CallingExtensionDecorator.tsx +5 -3
  28. package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +4 -2
  29. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +10 -8
  30. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +240 -97
  31. package/src/calls/CometChatCallLogs/Skeleton.tsx +175 -91
  32. package/src/calls/CometChatCallLogs/index.ts +1 -0
  33. package/src/calls/CometChatCallLogs/style.ts +85 -43
  34. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +42 -29
  35. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +36 -10
  36. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +39 -12
  37. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -4
  38. package/src/extensions/Polls/PollsDecorator.tsx +30 -9
  39. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +34 -16
  40. package/src/index.ts +3 -1
  41. package/src/shared/base/Types.ts +31 -1
  42. package/src/shared/framework/DataSource.ts +64 -20
  43. package/src/shared/framework/DataSourceDecorator.tsx +46 -37
  44. package/src/shared/framework/MessageDataSource.tsx +518 -316
  45. package/src/shared/index.ts +3 -1
  46. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +3 -2
  47. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +3 -2
  48. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +3 -2
  49. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +3 -2
  50. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +3 -2
  51. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +3 -2
  52. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +3 -2
  53. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +3 -2
  54. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +3 -2
  55. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +3 -2
  56. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +3 -2
  57. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +3 -2
  58. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +3 -2
  59. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +3 -2
  60. package/src/shared/utils/MessageUtils.tsx +41 -20
  61. package/src/shared/utils/conversationUtils.ts +2 -2
  62. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +22 -1
  63. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +20 -8
  64. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +177 -123
  65. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +76 -10
  66. package/src/shared/views/CometChatConfirmDialog/style.ts +2 -2
  67. package/src/shared/views/CometChatDate/CometChatDate.tsx +26 -18
  68. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +22 -16
  69. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +17 -5
  70. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +65 -35
  71. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +22 -11
  72. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +47 -18
  73. package/src/shared/views/CometChatList/CometChatList.tsx +70 -46
  74. package/src/shared/views/CometChatList/Header.tsx +122 -37
  75. package/src/shared/views/CometChatList/styles.ts +1 -0
  76. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +116 -30
  77. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +52 -30
  78. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +36 -22
  79. package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +41 -13
  80. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +132 -17
  81. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +30 -2
  82. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +10 -6
  83. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +20 -13
  84. package/src/shared/views/CometChatStatusIndicator/styles.ts +26 -13
  85. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +25 -2
  86. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +94 -14
  87. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +52 -16
  88. package/src/shared/views/CometChatTooltipMenu/index.ts +2 -1
  89. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +29 -9
  90. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +20 -2
  91. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +29 -14
  92. package/src/shared/views/index.ts +2 -0
  93. package/src/theme/default/index.ts +5 -5
  94. package/src/theme/type.ts +2 -2
  95. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +0 -57
  96. package/src/shared/views/CometChatPanel/PanelStyle.tsx +0 -43
  97. package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
  98. 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
- backgroudColor: ColorValue;
10
- linearGradientColors: [string, string];
11
- shimmerBackgroundColor: ColorValue;
12
- shimmerOpacity: number;
13
- speed: number;
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
- selectionIconStyle: {},
71
- selectionIcon: undefined,
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" as const,
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
- backgroudColor: color.background3,
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
- backgroudColor: color.background3,
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 { Animated, Dimensions, Easing, ScrollView, StyleSheet, View } from "react-native";
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
- const { width: screenWidth } = Dimensions.get("window");
7
-
8
- // Constants for dimensions
9
- const padding = 20;
10
- const headerHeight = 35;
11
- const separatorHeight = 1;
12
- const contentRectHeight = 60;
13
- const listItemHeight = 25; // Height for username
14
- const listItemSubtitleHeight = 20; // Increased from 15 to 20 for subtitle
15
- const listItemSubtitleSpacing = 10; // Increased from 5 to 10 for spacing between username and subtitle
16
- const listItemSpacing = 30; // Increased from 54 to 60 for spacing between list items
17
- const avatarRadius = 25; // Radius for avatar
18
- const listItemCount = 14;
19
-
20
- // Calculate the total height needed for the SVG
21
- // const calculateTotalHeight = () => {
22
- // return (
23
- // padding + // Header Y position
24
- // headerHeight + // Header height
25
- // 12 + // Spacing
26
- // separatorHeight + // Separator height
27
- // 12 + // Spacing
28
- // contentRectHeight + // Content rectangle height
29
- // 24 + // Spacing
30
- // listItemCount *
31
- // (listItemHeight + listItemSubtitleSpacing + listItemSubtitleHeight + listItemSpacing) // List items with updated spacing and height
32
- // );
33
- // };
34
- const calculateTotalHeight = () => {
35
- return (
36
- padding + // Top padding
37
- listItemCount *
38
- (listItemHeight + listItemSubtitleSpacing + listItemSubtitleHeight + listItemSpacing) // List items with updated spacing and height
39
- );
40
- };
41
-
42
- const SkeletonItemBottom = () => {
43
- const theme = useTheme();
44
-
45
- const totalHeight = calculateTotalHeight();
46
-
47
- return (
48
- <Svg height={totalHeight} width={screenWidth} fill='none' preserveAspectRatio='xMidYMid meet'>
49
- {/* Header Rectangle */}
50
- {/* <Rect
51
- x={padding + 5}
52
- y={padding}
53
- width={screenWidth * 0.5}
54
- height={headerHeight}
55
- rx={6}
56
- fill='url(#paint0_linear)'
57
- /> */}
58
-
59
- {/* Separator Line */}
60
- {/* <Rect
61
- x={padding}
62
- y={padding + headerHeight + 12} // 12 units spacing below header
63
- width={screenWidth - 2 * padding}
64
- height={separatorHeight}
65
- fill='#E0E0E0'
66
- /> */}
67
-
68
- {/* Content Rectangle with Semi-Circular Corners */}
69
- {/* <Rect
70
- x={padding}
71
- y={padding + headerHeight + 12 + separatorHeight + 12} // Position below separator with spacing
72
- width={screenWidth - 2 * padding}
73
- height={contentRectHeight}
74
- rx={contentRectHeight / 2} // Semi-circular corners
75
- ry={contentRectHeight / 2} // Ensures vertical radius matches
76
- fill='url(#paint0_linear)'
77
- /> */}
78
-
79
- {/* List Items */}
80
- {Array.from({ length: listItemCount }).map((_, index) => {
81
- // const itemY =
82
- // padding +
83
- // headerHeight +
84
- // 12 +
85
- // separatorHeight +
86
- // 12 +
87
- // contentRectHeight +
88
- // 24 +
89
- // index *
90
- // (listItemHeight + listItemSubtitleSpacing + listItemSubtitleHeight + listItemSpacing);
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
- (listItemHeight + listItemSubtitleSpacing + listItemSubtitleHeight + listItemSpacing) -
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={padding + avatarRadius}
102
- cy={itemY + avatarRadius}
103
- r={avatarRadius}
104
- fill='url(#paint0_linear)'
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={padding + 2 * avatarRadius + 12} // 12 units spacing after avatar
110
- y={itemY}
111
- width={screenWidth - (padding + 2 * avatarRadius + 12 + padding)}
112
- height={listItemHeight}
113
- rx={listItemHeight / 2} // Rounded corners matching height
114
- fill='url(#paint0_linear)'
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={padding + 2 * avatarRadius + 12}
120
- y={itemY + listItemHeight + listItemSubtitleSpacing}
121
- width={(screenWidth - (padding + 2 * avatarRadius + 12 + padding)) * 0.6} // 60% width for subtitle
122
- height={listItemSubtitleHeight}
123
- rx={listItemSubtitleHeight / 2}
124
- fill='url(#paint0_linear)'
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
- {/* List Items */}
186
- {Array.from({ length: listItemCount }).map((_, index) => {
187
- // const itemY =
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
- const itemY =
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
- useEffect(() => {
245
- const startShimmer = () => {
246
- animatedValue.setValue(0);
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
- startShimmer();
258
- }, [animatedValue, theme.groupStyles.skeletonStyle.speed]);
145
+ // Animated shimmer setup -----------------------------------------------------
146
+ const shimmerTranslate = useRef(new Animated.Value(0)).current;
259
147
 
260
- const shimmerTranslateX = animatedValue.interpolate({
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: [-screenWidth * 2, screenWidth],
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: theme.groupStyles.containerStyle.backgroundColor }}
183
+ style={{ backgroundColor: get("containerBackgroundColor") }}
270
184
  >
271
- <SkeletonItemBottom />
272
- <Animated.View
273
- style={[
274
- {
275
- transform: [
276
- { translateX: shimmerTranslateX },
277
- { translateY: -20 },
278
- { rotate: "15deg" },
279
- ],
280
- },
281
- styles.animatedView,
282
- {
283
- backgroundColor: theme.groupStyles.skeletonStyle.shimmerBackgroundColor,
284
- opacity: theme.groupStyles.skeletonStyle.shimmerOpacity,
285
- },
286
- ]}
287
- />
288
- <Animated.View
289
- style={[
290
- {
291
- transform: [
292
- {
293
- translateX: Animated.add(shimmerTranslateX, screenWidth / 2),
294
- },
295
- { translateY: -20 },
296
- { rotate: "15deg" },
297
- ],
298
- },
299
- styles.animatedView,
300
- {
301
- backgroundColor: theme.groupStyles.skeletonStyle.shimmerBackgroundColor,
302
- opacity: theme.groupStyles.skeletonStyle.shimmerOpacity,
303
- },
304
- ]}
305
- />
306
- <View
307
- style={{
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
- animatedView: {
323
- width: "25%",
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
  });