@zezosoft/zezo-ott-react-native-ui-kit 1.1.2 → 1.1.3

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 (136) hide show
  1. package/lib/module/components/Auth/QrLogin/QrLogin.js +304 -138
  2. package/lib/module/components/Auth/QrLogin/QrLogin.js.map +1 -1
  3. package/lib/module/components/Auth/QrLogin/components/QrViewArea.js +193 -141
  4. package/lib/module/components/Auth/QrLogin/components/QrViewArea.js.map +1 -1
  5. package/lib/module/components/Content/Card/Category/Category.js +83 -11
  6. package/lib/module/components/Content/Card/Category/Category.js.map +1 -1
  7. package/lib/module/components/Content/Card/NowWatching/NowWatching.js +237 -108
  8. package/lib/module/components/Content/Card/NowWatching/NowWatching.js.map +1 -1
  9. package/lib/module/components/Content/Card/Sliders/Styles/One.js +185 -126
  10. package/lib/module/components/Content/Card/Sliders/Styles/One.js.map +1 -1
  11. package/lib/module/components/Content/Card/Sliders/Styles/Two.js +139 -92
  12. package/lib/module/components/Content/Card/Sliders/Styles/Two.js.map +1 -1
  13. package/lib/module/components/Content/Card/Styles/Five.js +131 -48
  14. package/lib/module/components/Content/Card/Styles/Five.js.map +1 -1
  15. package/lib/module/components/Content/Card/Styles/Four.js +126 -59
  16. package/lib/module/components/Content/Card/Styles/Four.js.map +1 -1
  17. package/lib/module/components/Content/Card/Styles/One.js +125 -50
  18. package/lib/module/components/Content/Card/Styles/One.js.map +1 -1
  19. package/lib/module/components/Content/Card/Styles/RotateInOut.js +138 -53
  20. package/lib/module/components/Content/Card/Styles/RotateInOut.js.map +1 -1
  21. package/lib/module/components/Content/Card/Styles/Six.js +207 -115
  22. package/lib/module/components/Content/Card/Styles/Six.js.map +1 -1
  23. package/lib/module/components/Content/Card/Styles/Three.js +134 -79
  24. package/lib/module/components/Content/Card/Styles/Three.js.map +1 -1
  25. package/lib/module/components/Content/Card/Styles/TopTen.js +186 -171
  26. package/lib/module/components/Content/Card/Styles/TopTen.js.map +1 -1
  27. package/lib/module/components/Content/Card/Styles/Two.js +144 -64
  28. package/lib/module/components/Content/Card/Styles/Two.js.map +1 -1
  29. package/lib/module/components/Content/Card/components/AdsPoster.js +162 -0
  30. package/lib/module/components/Content/Card/components/AdsPoster.js.map +1 -0
  31. package/lib/module/components/Content/Card/components/CardPoster.js +120 -136
  32. package/lib/module/components/Content/Card/components/CardPoster.js.map +1 -1
  33. package/lib/module/components/Content/Card/components/index.js +4 -0
  34. package/lib/module/components/Content/Card/components/index.js.map +1 -0
  35. package/lib/module/components/Content/Content.js +67 -27
  36. package/lib/module/components/Content/Content.js.map +1 -1
  37. package/lib/module/components/Content/Sections.js +32 -11
  38. package/lib/module/components/Content/Sections.js.map +1 -1
  39. package/lib/module/constants/dummySections.js +44 -4
  40. package/lib/module/constants/dummySections.js.map +1 -1
  41. package/lib/module/hooks/Images/index.js +5 -0
  42. package/lib/module/hooks/Images/index.js.map +1 -0
  43. package/lib/module/hooks/Images/useImageLoader.js +168 -0
  44. package/lib/module/hooks/Images/useImageLoader.js.map +1 -0
  45. package/lib/module/hooks/Images/useImageValidation.js +36 -0
  46. package/lib/module/hooks/Images/useImageValidation.js.map +1 -0
  47. package/lib/module/hooks/index.js +3 -0
  48. package/lib/module/hooks/index.js.map +1 -1
  49. package/lib/module/hooks/useAdTracking.js +270 -0
  50. package/lib/module/hooks/useAdTracking.js.map +1 -0
  51. package/lib/module/hooks/useCards.js +164 -0
  52. package/lib/module/hooks/useCards.js.map +1 -0
  53. package/lib/module/hooks/usePaginatedSection.js +11 -6
  54. package/lib/module/hooks/usePaginatedSection.js.map +1 -1
  55. package/lib/typescript/src/components/Auth/QrLogin/QrLogin.d.ts +2 -0
  56. package/lib/typescript/src/components/Auth/QrLogin/QrLogin.d.ts.map +1 -1
  57. package/lib/typescript/src/components/Auth/QrLogin/components/QrViewArea.d.ts.map +1 -1
  58. package/lib/typescript/src/components/Content/Card/Category/Category.d.ts.map +1 -1
  59. package/lib/typescript/src/components/Content/Card/NowWatching/NowWatching.d.ts.map +1 -1
  60. package/lib/typescript/src/components/Content/Card/Sliders/Styles/One.d.ts.map +1 -1
  61. package/lib/typescript/src/components/Content/Card/Sliders/Styles/Two.d.ts.map +1 -1
  62. package/lib/typescript/src/components/Content/Card/Styles/Five.d.ts +13 -1
  63. package/lib/typescript/src/components/Content/Card/Styles/Five.d.ts.map +1 -1
  64. package/lib/typescript/src/components/Content/Card/Styles/Four.d.ts +13 -1
  65. package/lib/typescript/src/components/Content/Card/Styles/Four.d.ts.map +1 -1
  66. package/lib/typescript/src/components/Content/Card/Styles/One.d.ts +15 -3
  67. package/lib/typescript/src/components/Content/Card/Styles/One.d.ts.map +1 -1
  68. package/lib/typescript/src/components/Content/Card/Styles/RotateInOut.d.ts +13 -1
  69. package/lib/typescript/src/components/Content/Card/Styles/RotateInOut.d.ts.map +1 -1
  70. package/lib/typescript/src/components/Content/Card/Styles/Six.d.ts +1 -0
  71. package/lib/typescript/src/components/Content/Card/Styles/Six.d.ts.map +1 -1
  72. package/lib/typescript/src/components/Content/Card/Styles/Three.d.ts +13 -5
  73. package/lib/typescript/src/components/Content/Card/Styles/Three.d.ts.map +1 -1
  74. package/lib/typescript/src/components/Content/Card/Styles/TopTen.d.ts +1 -0
  75. package/lib/typescript/src/components/Content/Card/Styles/TopTen.d.ts.map +1 -1
  76. package/lib/typescript/src/components/Content/Card/Styles/Two.d.ts +13 -1
  77. package/lib/typescript/src/components/Content/Card/Styles/Two.d.ts.map +1 -1
  78. package/lib/typescript/src/components/Content/Card/components/AdsPoster.d.ts +26 -0
  79. package/lib/typescript/src/components/Content/Card/components/AdsPoster.d.ts.map +1 -0
  80. package/lib/typescript/src/components/Content/Card/components/CardPoster.d.ts +3 -1
  81. package/lib/typescript/src/components/Content/Card/components/CardPoster.d.ts.map +1 -1
  82. package/lib/typescript/src/components/Content/Card/components/index.d.ts +2 -0
  83. package/lib/typescript/src/components/Content/Card/components/index.d.ts.map +1 -0
  84. package/lib/typescript/src/components/Content/Card/index.d.ts +76 -6
  85. package/lib/typescript/src/components/Content/Card/index.d.ts.map +1 -1
  86. package/lib/typescript/src/components/Content/Content.d.ts +4 -3
  87. package/lib/typescript/src/components/Content/Content.d.ts.map +1 -1
  88. package/lib/typescript/src/components/Content/Sections.d.ts +20 -6
  89. package/lib/typescript/src/components/Content/Sections.d.ts.map +1 -1
  90. package/lib/typescript/src/constants/dummySections.d.ts +5 -0
  91. package/lib/typescript/src/constants/dummySections.d.ts.map +1 -1
  92. package/lib/typescript/src/hooks/Images/index.d.ts +3 -0
  93. package/lib/typescript/src/hooks/Images/index.d.ts.map +1 -0
  94. package/lib/typescript/src/hooks/Images/useImageLoader.d.ts +36 -0
  95. package/lib/typescript/src/hooks/Images/useImageLoader.d.ts.map +1 -0
  96. package/lib/typescript/src/hooks/Images/useImageValidation.d.ts +17 -0
  97. package/lib/typescript/src/hooks/Images/useImageValidation.d.ts.map +1 -0
  98. package/lib/typescript/src/hooks/index.d.ts +3 -0
  99. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  100. package/lib/typescript/src/hooks/useAdTracking.d.ts +39 -0
  101. package/lib/typescript/src/hooks/useAdTracking.d.ts.map +1 -0
  102. package/lib/typescript/src/hooks/useCards.d.ts +36 -0
  103. package/lib/typescript/src/hooks/useCards.d.ts.map +1 -0
  104. package/lib/typescript/src/hooks/usePaginatedSection.d.ts +12 -2
  105. package/lib/typescript/src/hooks/usePaginatedSection.d.ts.map +1 -1
  106. package/lib/typescript/src/types/sections/index.d.ts +7 -4
  107. package/lib/typescript/src/types/sections/index.d.ts.map +1 -1
  108. package/package.json +6 -3
  109. package/src/components/Auth/QrLogin/QrLogin.tsx +382 -122
  110. package/src/components/Auth/QrLogin/components/QrViewArea.tsx +291 -197
  111. package/src/components/Content/Card/Category/Category.tsx +95 -8
  112. package/src/components/Content/Card/NowWatching/NowWatching.tsx +281 -136
  113. package/src/components/Content/Card/Sliders/Styles/One.tsx +244 -148
  114. package/src/components/Content/Card/Sliders/Styles/Two.tsx +171 -102
  115. package/src/components/Content/Card/Styles/Five.tsx +161 -62
  116. package/src/components/Content/Card/Styles/Four.tsx +164 -85
  117. package/src/components/Content/Card/Styles/One.tsx +161 -71
  118. package/src/components/Content/Card/Styles/RotateInOut.tsx +157 -60
  119. package/src/components/Content/Card/Styles/Six.tsx +242 -142
  120. package/src/components/Content/Card/Styles/Three.tsx +166 -133
  121. package/src/components/Content/Card/Styles/TopTen.tsx +230 -191
  122. package/src/components/Content/Card/Styles/Two.tsx +182 -79
  123. package/src/components/Content/Card/components/AdsPoster.tsx +202 -0
  124. package/src/components/Content/Card/components/CardPoster.tsx +134 -154
  125. package/src/components/Content/Card/components/index.ts +1 -0
  126. package/src/components/Content/Content.tsx +83 -45
  127. package/src/components/Content/Sections.tsx +51 -10
  128. package/src/constants/dummySections.ts +48 -1
  129. package/src/hooks/Images/index.ts +2 -0
  130. package/src/hooks/Images/useImageLoader.ts +206 -0
  131. package/src/hooks/Images/useImageValidation.ts +36 -0
  132. package/src/hooks/index.ts +3 -0
  133. package/src/hooks/useAdTracking.ts +349 -0
  134. package/src/hooks/useCards.ts +228 -0
  135. package/src/hooks/usePaginatedSection.ts +26 -7
  136. package/src/types/sections/index.ts +7 -4
@@ -22,10 +22,11 @@ import { debounce } from 'lodash';
22
22
  import { useInternalTheme } from '../../../../theme/hook/useInternalTheme';
23
23
  import CardPoster from '../components/CardPoster';
24
24
  import NavigateToMore from '../components/NavigateToMore';
25
+ import { AdsPoster } from '../components';
25
26
 
26
- import { usePaginatedSection } from '../../../../hooks/usePaginatedSection';
27
27
  import { useSkeletonItems } from '../../../../hooks/useSkeletonItems';
28
28
  import type {
29
+ IAdItem,
29
30
  IGetSectionData,
30
31
  ISectionContent,
31
32
  MoreFetchData,
@@ -33,14 +34,35 @@ import type {
33
34
  import type { ThemeOverride } from '../../../../theme/themes';
34
35
  import { RFValue } from 'react-native-responsive-fontsize';
35
36
  import type { IContentData } from '@zezosoft/zezo-ott-api-client';
37
+ import { useCards } from '../../../../hooks';
36
38
 
39
+ // Constants
37
40
  const { width, height } = Dimensions.get('window');
38
-
39
- const DEFAULT_ITEM_WIDTH = width * 0.42;
40
- const DEFAULT_ITEM_HEIGHT = height * 0.28;
41
+ const ITEM_WIDTH_RATIO = 0.42;
42
+ const ITEM_HEIGHT_RATIO = 0.28;
43
+ const DEFAULT_ITEM_WIDTH = width * ITEM_WIDTH_RATIO;
44
+ const DEFAULT_ITEM_HEIGHT = height * ITEM_HEIGHT_RATIO;
41
45
  const DEFAULT_BORDER_RADIUS = moderateScale(10);
46
+ const DEFAULT_SKELETON_COUNT = 5;
47
+ const DEBOUNCE_DELAY = 300;
48
+ const ITEM_ACTIVE_OPACITY = 0.8;
49
+ const CAROUSEL_FIRST_ITEM = 1;
50
+ const CAROUSEL_INACTIVE_OPACITY = 0.6;
51
+ const CAROUSEL_INACTIVE_SCALE = 0.9;
52
+ const PAGINATION_TRIGGER_OFFSET = 2;
53
+ const SKELETON_TITLE_WIDTH = moderateScale(100);
54
+ const SKELETON_TITLE_HEIGHT = verticalScale(14);
55
+ const SKELETON_TITLE_BORDER_RADIUS = moderateScale(4);
56
+ const SKELETON_TITLE_MARGIN_LEFT = moderateScale(12);
57
+ const SKELETON_TITLE_MARGIN_BOTTOM = verticalScale(6);
58
+ const SKELETON_ITEM_MARGIN_RIGHT = moderateScale(12);
59
+ const DEFAULT_SKELETON_BACKGROUND_COLOR = '#222';
60
+ const SHADOW_ELEVATION = 0;
61
+ const SHADOW_OFFSET = { width: 0, height: 0 };
62
+ const SHADOW_OPACITY = 0;
63
+ const SHADOW_RADIUS = 0;
42
64
 
43
- // Static styles defined outside getStyles to avoid recalculation
65
+ // Static Styles
44
66
  const staticStyles = StyleSheet.create({
45
67
  root: {
46
68
  marginVertical: verticalScale(6),
@@ -57,12 +79,14 @@ const staticStyles = StyleSheet.create({
57
79
  },
58
80
  });
59
81
 
82
+ // Types
60
83
  type Props = {
61
84
  title: string;
62
85
  section_id: string;
63
86
  data: ISectionContent | null;
64
- type: IGetSectionData['type'];
65
87
  moreFetchData?: MoreFetchData<IContentData>;
88
+ type: IGetSectionData['type'];
89
+ paginationSkeletonCount?: number;
66
90
  onPressItem?: (item: IContentData) => void;
67
91
  onPressMore?: (params: {
68
92
  section_id: IGetSectionData['_id'];
@@ -82,13 +106,22 @@ type Props = {
82
106
  itemStyle?: StyleProp<ViewStyle>;
83
107
  isLoading?: boolean;
84
108
  theme?: ThemeOverride;
109
+ onDisplayAds?: (ad: any) => void;
110
+ screenDimensions?: { width: number; height: number };
111
+ viewportOffsets?: {
112
+ top: number;
113
+ bottom: number;
114
+ left: number;
115
+ right: number;
116
+ };
85
117
  };
86
118
 
119
+ // Main Component
87
120
  const RotateCarousel: React.FC<Props> = ({
88
121
  title,
89
122
  section_id,
90
123
  type,
91
- data: initialData,
124
+ data: externalData,
92
125
  moreFetchData,
93
126
  onPressMore,
94
127
  onPressItem,
@@ -96,17 +129,24 @@ const RotateCarousel: React.FC<Props> = ({
96
129
  itemWidth = DEFAULT_ITEM_WIDTH,
97
130
  itemHeight = DEFAULT_ITEM_HEIGHT,
98
131
  borderRadius = DEFAULT_BORDER_RADIUS,
99
- skeletonCount = 5,
132
+ skeletonCount = DEFAULT_SKELETON_COUNT,
100
133
  containerStyle,
101
134
  titleStyle,
135
+ paginationSkeletonCount,
102
136
  itemStyle,
103
137
  isLoading = false,
104
138
  theme,
139
+ onDisplayAds,
140
+ screenDimensions,
141
+ viewportOffsets,
105
142
  }) => {
106
- const { theme: appliedTheme } = useInternalTheme(theme);
143
+ // Refs
107
144
  const carouselRef = useRef<any>(null);
108
145
 
109
- // Memoized dynamic styles
146
+ // Theme
147
+ const { theme: appliedTheme } = useInternalTheme(theme);
148
+
149
+ // Styles
110
150
  const styles = useMemo(
111
151
  () =>
112
152
  StyleSheet.create({
@@ -115,66 +155,74 @@ const RotateCarousel: React.FC<Props> = ({
115
155
  height: itemHeight,
116
156
  borderRadius,
117
157
  overflow: 'hidden',
118
- elevation: 0,
158
+ elevation: SHADOW_ELEVATION,
119
159
  shadowColor: 'transparent',
120
- shadowOffset: { width: 0, height: 0 },
121
- shadowOpacity: 0,
122
- shadowRadius: 0,
160
+ shadowOffset: SHADOW_OFFSET,
161
+ shadowOpacity: SHADOW_OPACITY,
162
+ shadowRadius: SHADOW_RADIUS,
123
163
  },
124
164
  image: {
125
165
  width: '100%',
126
166
  height: '100%',
127
- backgroundColor: appliedTheme.colors.skeletonBaseColor ?? '#222',
167
+ backgroundColor:
168
+ appliedTheme.colors.skeletonBaseColor ??
169
+ DEFAULT_SKELETON_BACKGROUND_COLOR,
128
170
  },
129
171
  skeleton: {
130
172
  width: itemWidth,
131
173
  height: itemHeight,
132
174
  borderRadius,
133
175
  overflow: 'hidden',
134
- marginRight: moderateScale(12),
176
+ marginRight: SKELETON_ITEM_MARGIN_RIGHT,
135
177
  },
136
178
  }),
137
179
  [appliedTheme.colors.skeletonBaseColor, itemWidth, itemHeight, borderRadius]
138
180
  );
139
181
 
182
+ // Data Management
140
183
  const {
141
- data,
142
- loading: isPaginating,
184
+ listData,
143
185
  pagination,
144
- loadMoreData,
145
- } = usePaginatedSection(
146
- section_id,
147
- moreFetchData,
148
- initialData?.data || [],
149
- isLoading
150
- );
186
+ loadMore,
187
+ isEmpty,
188
+ isPaging: isPaginating,
189
+ } = useCards({
190
+ sectionId: section_id,
191
+ data: externalData,
192
+ fetchMore: moreFetchData,
193
+ loading: isLoading,
194
+ initialSkeleton: skeletonCount,
195
+ pagingSkeleton: paginationSkeletonCount,
196
+ adsRender: true,
197
+ });
151
198
 
152
- // Memoized skeleton items
199
+ // Skeleton Data
153
200
  const skeletonCountMemo = useMemo(
154
201
  () => (isLoading ? skeletonCount : isPaginating ? 1 : 0),
155
202
  [isLoading, isPaginating, skeletonCount]
156
203
  );
157
204
  const skeletonItems = useSkeletonItems(skeletonCountMemo);
158
205
 
159
- // Optimized finalData to avoid unnecessary spread
160
206
  const finalData = useMemo(
161
207
  () =>
162
208
  isLoading
163
209
  ? skeletonItems
164
210
  : skeletonItems.length > 0
165
- ? [...data, ...skeletonItems]
166
- : data,
167
- [isLoading, data, skeletonItems]
211
+ ? [...listData, ...skeletonItems]
212
+ : listData,
213
+ [isLoading, listData, skeletonItems]
168
214
  );
169
- // Debounced loadMoreData to prevent excessive calls
215
+
216
+ // Debounced Functions
170
217
  const debouncedLoadMore = useMemo(
171
218
  () =>
172
219
  debounce((nextPage: number) => {
173
- return loadMoreData(nextPage);
174
- }, 300),
175
- [loadMoreData]
220
+ return loadMore(nextPage);
221
+ }, DEBOUNCE_DELAY),
222
+ [loadMore]
176
223
  );
177
224
 
225
+ // Event Handlers
178
226
  const handleItemPress = useCallback(
179
227
  (item: IContentData) => {
180
228
  onPressItem?.(item);
@@ -190,14 +238,16 @@ const RotateCarousel: React.FC<Props> = ({
190
238
  });
191
239
  }, [onPressMore, section_id, title, type]);
192
240
 
241
+ // Render Functions
193
242
  const renderItem = useCallback(
194
243
  ({
195
244
  item,
196
245
  index,
197
246
  }: {
198
- item: IContentData | { isSkeleton: true; _id: string };
247
+ item: IContentData | IAdItem | { isSkeleton: true; _id: string };
199
248
  index: number;
200
249
  }) => {
250
+ // Handle skeleton items
201
251
  if ('isSkeleton' in item) {
202
252
  return (
203
253
  <View key={item._id} style={styles.skeleton}>
@@ -215,25 +265,57 @@ const RotateCarousel: React.FC<Props> = ({
215
265
  );
216
266
  }
217
267
 
268
+ // Handle ads
269
+ if ('type' in item && item.type === 'ads') {
270
+ const adItem = item as IAdItem;
271
+ return (
272
+ <View
273
+ key={`ad-${adItem.tracking?.impression || index}`}
274
+ style={[styles.item, itemStyle]}
275
+ >
276
+ <AdsPoster
277
+ ad={adItem}
278
+ theme={appliedTheme}
279
+ isLoading={isLoading}
280
+ containerStyle={{ width: itemWidth, height: itemHeight }}
281
+ imageStyle={styles.image}
282
+ borderRadius={borderRadius}
283
+ onDisplayAds={onDisplayAds}
284
+ screenDimensions={screenDimensions}
285
+ viewportOffsets={viewportOffsets}
286
+ />
287
+ </View>
288
+ );
289
+ }
290
+
291
+ // Handle content items
292
+ const contentItem = item as IContentData;
293
+ const isSkeleton =
294
+ contentItem._id?.startsWith?.('pagination-skeleton') ?? false;
295
+
218
296
  return (
219
297
  <TouchableOpacity
220
- key={item._id || `item-${index}`}
221
- activeOpacity={0.8}
298
+ key={contentItem._id || `item-${index}`}
299
+ activeOpacity={ITEM_ACTIVE_OPACITY}
222
300
  style={[styles.item, itemStyle]}
223
- disabled={!item || !onPressItem || isLoading}
224
- onPress={() => handleItemPress(item)}
301
+ disabled={!contentItem || !onPressItem || isLoading || isSkeleton}
302
+ onPress={() => {
303
+ if (!isSkeleton && !isLoading) {
304
+ handleItemPress(contentItem);
305
+ }
306
+ }}
225
307
  >
226
308
  {renderItemImage ? (
227
- renderItemImage({ item, index })
309
+ renderItemImage({ item: contentItem, index })
228
310
  ) : (
229
311
  <CardPoster
230
- content_offering_type={item.content_offering_type}
231
- posterUri={item.poster}
312
+ content_offering_type={contentItem.content_offering_type}
313
+ posterUri={contentItem.poster}
232
314
  theme={appliedTheme}
233
315
  borderRadius={borderRadius}
234
316
  posterWrapperStyle={styles.image}
235
317
  resizeMode={FastImage.resizeMode.cover}
236
- isLoading={isLoading}
318
+ isLoading={isSkeleton || isLoading}
237
319
  />
238
320
  )}
239
321
  </TouchableOpacity>
@@ -252,13 +334,34 @@ const RotateCarousel: React.FC<Props> = ({
252
334
  itemWidth,
253
335
  itemHeight,
254
336
  handleItemPress,
337
+ onDisplayAds,
338
+ screenDimensions,
339
+ viewportOffsets,
255
340
  ]
256
341
  );
257
- if (!initialData) {
342
+
343
+ const handleSnapToItem = useCallback(
344
+ (index: number) => {
345
+ if (isLoading || !pagination?.hasNextPage || !pagination?.nextPage) {
346
+ return;
347
+ }
348
+ if (index >= finalData.length - PAGINATION_TRIGGER_OFFSET) {
349
+ debouncedLoadMore(pagination.nextPage);
350
+ }
351
+ },
352
+ [isLoading, pagination, finalData.length, debouncedLoadMore]
353
+ );
354
+
355
+ // Early Returns
356
+ if (
357
+ !externalData ||
358
+ (!isLoading && listData.length === 0) ||
359
+ (!isLoading && isEmpty)
360
+ ) {
258
361
  return null;
259
362
  }
260
- if (!isLoading && (!data || data.length === 0)) return null;
261
363
 
364
+ // Main Render
262
365
  return (
263
366
  <View
264
367
  style={[staticStyles.root, containerStyle]}
@@ -270,11 +373,11 @@ const RotateCarousel: React.FC<Props> = ({
270
373
  backgroundColor={appliedTheme.colors.skeletonBaseColor}
271
374
  >
272
375
  <SkeletonPlaceholder.Item
273
- width={moderateScale(100)}
274
- height={verticalScale(14)}
275
- borderRadius={moderateScale(4)}
276
- marginLeft={moderateScale(12)}
277
- marginBottom={verticalScale(6)}
376
+ width={SKELETON_TITLE_WIDTH}
377
+ height={SKELETON_TITLE_HEIGHT}
378
+ borderRadius={SKELETON_TITLE_BORDER_RADIUS}
379
+ marginLeft={SKELETON_TITLE_MARGIN_LEFT}
380
+ marginBottom={SKELETON_TITLE_MARGIN_BOTTOM}
278
381
  />
279
382
  </SkeletonPlaceholder>
280
383
  ) : (
@@ -295,18 +398,12 @@ const RotateCarousel: React.FC<Props> = ({
295
398
  data={finalData as any}
296
399
  vertical={false}
297
400
  renderItem={renderItem}
298
- firstItem={2}
299
- inactiveSlideOpacity={0.6}
300
- inactiveSlideScale={0.9}
401
+ firstItem={CAROUSEL_FIRST_ITEM}
402
+ inactiveSlideOpacity={CAROUSEL_INACTIVE_OPACITY}
403
+ inactiveSlideScale={CAROUSEL_INACTIVE_SCALE}
301
404
  sliderWidth={width}
302
405
  itemWidth={itemWidth}
303
- onSnapToItem={(index) => {
304
- if (isLoading || !pagination?.hasNextPage || !pagination?.nextPage)
305
- return;
306
- if (index >= finalData.length - 2) {
307
- debouncedLoadMore(pagination.nextPage);
308
- }
309
- }}
406
+ onSnapToItem={handleSnapToItem}
310
407
  />
311
408
  </View>
312
409
  );