@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.
- package/lib/module/components/Auth/QrLogin/QrLogin.js +304 -138
- package/lib/module/components/Auth/QrLogin/QrLogin.js.map +1 -1
- package/lib/module/components/Auth/QrLogin/components/QrViewArea.js +193 -141
- package/lib/module/components/Auth/QrLogin/components/QrViewArea.js.map +1 -1
- package/lib/module/components/Content/Card/Category/Category.js +83 -11
- package/lib/module/components/Content/Card/Category/Category.js.map +1 -1
- package/lib/module/components/Content/Card/NowWatching/NowWatching.js +237 -108
- package/lib/module/components/Content/Card/NowWatching/NowWatching.js.map +1 -1
- package/lib/module/components/Content/Card/Sliders/Styles/One.js +185 -126
- package/lib/module/components/Content/Card/Sliders/Styles/One.js.map +1 -1
- package/lib/module/components/Content/Card/Sliders/Styles/Two.js +139 -92
- package/lib/module/components/Content/Card/Sliders/Styles/Two.js.map +1 -1
- package/lib/module/components/Content/Card/Styles/Five.js +131 -48
- package/lib/module/components/Content/Card/Styles/Five.js.map +1 -1
- package/lib/module/components/Content/Card/Styles/Four.js +126 -59
- package/lib/module/components/Content/Card/Styles/Four.js.map +1 -1
- package/lib/module/components/Content/Card/Styles/One.js +125 -50
- package/lib/module/components/Content/Card/Styles/One.js.map +1 -1
- package/lib/module/components/Content/Card/Styles/RotateInOut.js +138 -53
- package/lib/module/components/Content/Card/Styles/RotateInOut.js.map +1 -1
- package/lib/module/components/Content/Card/Styles/Six.js +207 -115
- package/lib/module/components/Content/Card/Styles/Six.js.map +1 -1
- package/lib/module/components/Content/Card/Styles/Three.js +134 -79
- package/lib/module/components/Content/Card/Styles/Three.js.map +1 -1
- package/lib/module/components/Content/Card/Styles/TopTen.js +186 -171
- package/lib/module/components/Content/Card/Styles/TopTen.js.map +1 -1
- package/lib/module/components/Content/Card/Styles/Two.js +144 -64
- package/lib/module/components/Content/Card/Styles/Two.js.map +1 -1
- package/lib/module/components/Content/Card/components/AdsPoster.js +162 -0
- package/lib/module/components/Content/Card/components/AdsPoster.js.map +1 -0
- package/lib/module/components/Content/Card/components/CardPoster.js +120 -136
- package/lib/module/components/Content/Card/components/CardPoster.js.map +1 -1
- package/lib/module/components/Content/Card/components/index.js +4 -0
- package/lib/module/components/Content/Card/components/index.js.map +1 -0
- package/lib/module/components/Content/Content.js +67 -27
- package/lib/module/components/Content/Content.js.map +1 -1
- package/lib/module/components/Content/Sections.js +32 -11
- package/lib/module/components/Content/Sections.js.map +1 -1
- package/lib/module/constants/dummySections.js +44 -4
- package/lib/module/constants/dummySections.js.map +1 -1
- package/lib/module/hooks/Images/index.js +5 -0
- package/lib/module/hooks/Images/index.js.map +1 -0
- package/lib/module/hooks/Images/useImageLoader.js +168 -0
- package/lib/module/hooks/Images/useImageLoader.js.map +1 -0
- package/lib/module/hooks/Images/useImageValidation.js +36 -0
- package/lib/module/hooks/Images/useImageValidation.js.map +1 -0
- package/lib/module/hooks/index.js +3 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useAdTracking.js +270 -0
- package/lib/module/hooks/useAdTracking.js.map +1 -0
- package/lib/module/hooks/useCards.js +164 -0
- package/lib/module/hooks/useCards.js.map +1 -0
- package/lib/module/hooks/usePaginatedSection.js +11 -6
- package/lib/module/hooks/usePaginatedSection.js.map +1 -1
- package/lib/typescript/src/components/Auth/QrLogin/QrLogin.d.ts +2 -0
- package/lib/typescript/src/components/Auth/QrLogin/QrLogin.d.ts.map +1 -1
- package/lib/typescript/src/components/Auth/QrLogin/components/QrViewArea.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Category/Category.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/NowWatching/NowWatching.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Sliders/Styles/One.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Sliders/Styles/Two.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Styles/Five.d.ts +13 -1
- package/lib/typescript/src/components/Content/Card/Styles/Five.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Styles/Four.d.ts +13 -1
- package/lib/typescript/src/components/Content/Card/Styles/Four.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Styles/One.d.ts +15 -3
- package/lib/typescript/src/components/Content/Card/Styles/One.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Styles/RotateInOut.d.ts +13 -1
- package/lib/typescript/src/components/Content/Card/Styles/RotateInOut.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Styles/Six.d.ts +1 -0
- package/lib/typescript/src/components/Content/Card/Styles/Six.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Styles/Three.d.ts +13 -5
- package/lib/typescript/src/components/Content/Card/Styles/Three.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Styles/TopTen.d.ts +1 -0
- package/lib/typescript/src/components/Content/Card/Styles/TopTen.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/Styles/Two.d.ts +13 -1
- package/lib/typescript/src/components/Content/Card/Styles/Two.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/components/AdsPoster.d.ts +26 -0
- package/lib/typescript/src/components/Content/Card/components/AdsPoster.d.ts.map +1 -0
- package/lib/typescript/src/components/Content/Card/components/CardPoster.d.ts +3 -1
- package/lib/typescript/src/components/Content/Card/components/CardPoster.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Card/components/index.d.ts +2 -0
- package/lib/typescript/src/components/Content/Card/components/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Content/Card/index.d.ts +76 -6
- package/lib/typescript/src/components/Content/Card/index.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Content.d.ts +4 -3
- package/lib/typescript/src/components/Content/Content.d.ts.map +1 -1
- package/lib/typescript/src/components/Content/Sections.d.ts +20 -6
- package/lib/typescript/src/components/Content/Sections.d.ts.map +1 -1
- package/lib/typescript/src/constants/dummySections.d.ts +5 -0
- package/lib/typescript/src/constants/dummySections.d.ts.map +1 -1
- package/lib/typescript/src/hooks/Images/index.d.ts +3 -0
- package/lib/typescript/src/hooks/Images/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/Images/useImageLoader.d.ts +36 -0
- package/lib/typescript/src/hooks/Images/useImageLoader.d.ts.map +1 -0
- package/lib/typescript/src/hooks/Images/useImageValidation.d.ts +17 -0
- package/lib/typescript/src/hooks/Images/useImageValidation.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +3 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useAdTracking.d.ts +39 -0
- package/lib/typescript/src/hooks/useAdTracking.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCards.d.ts +36 -0
- package/lib/typescript/src/hooks/useCards.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePaginatedSection.d.ts +12 -2
- package/lib/typescript/src/hooks/usePaginatedSection.d.ts.map +1 -1
- package/lib/typescript/src/types/sections/index.d.ts +7 -4
- package/lib/typescript/src/types/sections/index.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/components/Auth/QrLogin/QrLogin.tsx +382 -122
- package/src/components/Auth/QrLogin/components/QrViewArea.tsx +291 -197
- package/src/components/Content/Card/Category/Category.tsx +95 -8
- package/src/components/Content/Card/NowWatching/NowWatching.tsx +281 -136
- package/src/components/Content/Card/Sliders/Styles/One.tsx +244 -148
- package/src/components/Content/Card/Sliders/Styles/Two.tsx +171 -102
- package/src/components/Content/Card/Styles/Five.tsx +161 -62
- package/src/components/Content/Card/Styles/Four.tsx +164 -85
- package/src/components/Content/Card/Styles/One.tsx +161 -71
- package/src/components/Content/Card/Styles/RotateInOut.tsx +157 -60
- package/src/components/Content/Card/Styles/Six.tsx +242 -142
- package/src/components/Content/Card/Styles/Three.tsx +166 -133
- package/src/components/Content/Card/Styles/TopTen.tsx +230 -191
- package/src/components/Content/Card/Styles/Two.tsx +182 -79
- package/src/components/Content/Card/components/AdsPoster.tsx +202 -0
- package/src/components/Content/Card/components/CardPoster.tsx +134 -154
- package/src/components/Content/Card/components/index.ts +1 -0
- package/src/components/Content/Content.tsx +83 -45
- package/src/components/Content/Sections.tsx +51 -10
- package/src/constants/dummySections.ts +48 -1
- package/src/hooks/Images/index.ts +2 -0
- package/src/hooks/Images/useImageLoader.ts +206 -0
- package/src/hooks/Images/useImageValidation.ts +36 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useAdTracking.ts +349 -0
- package/src/hooks/useCards.ts +228 -0
- package/src/hooks/usePaginatedSection.ts +26 -7
- package/src/types/sections/index.ts +7 -4
|
@@ -14,29 +14,48 @@ import {
|
|
|
14
14
|
type ViewStyle,
|
|
15
15
|
type TextStyle,
|
|
16
16
|
type AccessibilityProps,
|
|
17
|
-
type ListRenderItemInfo,
|
|
18
17
|
} from 'react-native';
|
|
18
|
+
|
|
19
19
|
import SkeletonPlaceholder from 'react-native-skeleton-placeholder';
|
|
20
20
|
import { moderateScale, verticalScale } from 'react-native-size-matters';
|
|
21
21
|
import FastImage from 'react-native-fast-image';
|
|
22
|
+
import { RFValue } from 'react-native-responsive-fontsize';
|
|
22
23
|
|
|
23
24
|
import CardPoster from '../components/CardPoster';
|
|
24
25
|
import NavigateToMore from '../components/NavigateToMore';
|
|
25
|
-
import {
|
|
26
|
+
import { AdsPoster } from '../components';
|
|
26
27
|
import { useInternalTheme } from '../../../../theme/hook/useInternalTheme';
|
|
27
28
|
import type { ITheme, ThemeOverride } from '../../../../theme/themes';
|
|
28
29
|
import type {
|
|
30
|
+
IAdItem,
|
|
29
31
|
IGetSectionData,
|
|
30
32
|
ISectionContent,
|
|
31
33
|
MoreFetchData,
|
|
32
34
|
} from '../../../../types';
|
|
33
|
-
import {
|
|
34
|
-
import
|
|
35
|
+
import type { IContentData, IServeAd } from '@zezosoft/zezo-ott-api-client';
|
|
36
|
+
import { useCards } from '../../../../hooks';
|
|
35
37
|
|
|
38
|
+
// Constants
|
|
36
39
|
const DEFAULT_ITEM_WIDTH = moderateScale(140);
|
|
37
40
|
const DEFAULT_BORDER_RADIUS = moderateScale(5);
|
|
38
41
|
const DEFAULT_SKELETON_COUNT = 3;
|
|
42
|
+
const ASPECT_RATIO = 0.67;
|
|
43
|
+
const END_REACHED_THRESHOLD = 0.5;
|
|
44
|
+
const ITEM_ACTIVE_OPACITY = 0.8;
|
|
45
|
+
const INITIAL_NUM_TO_RENDER = 5;
|
|
46
|
+
const SKELETON_TITLE_WIDTH = moderateScale(100);
|
|
47
|
+
const SKELETON_TITLE_HEIGHT = moderateScale(20);
|
|
48
|
+
const SKELETON_TITLE_BORDER_RADIUS = moderateScale(4);
|
|
49
|
+
const SKELETON_TITLE_MARGIN_HORIZONTAL = moderateScale(15);
|
|
50
|
+
const SKELETON_TITLE_MARGIN_BOTTOM = verticalScale(6);
|
|
51
|
+
const SKELETON_ITEM_MARGIN_LEFT = moderateScale(12);
|
|
52
|
+
const SKELETON_ITEM_MARGIN_RIGHT = moderateScale(12);
|
|
53
|
+
const ITEM_MARGIN_LEFT = moderateScale(10);
|
|
54
|
+
const ITEM_MARGIN_BOTTOM = verticalScale(2);
|
|
55
|
+
const LIST_CONTENT_PADDING_RIGHT = moderateScale(15);
|
|
56
|
+
const SKELETON_LIST_PADDING_RIGHT = moderateScale(15);
|
|
39
57
|
|
|
58
|
+
// Types
|
|
40
59
|
type MovieCardFiveProps = {
|
|
41
60
|
theme?: ThemeOverride;
|
|
42
61
|
title: string;
|
|
@@ -57,18 +76,28 @@ type MovieCardFiveProps = {
|
|
|
57
76
|
itemWidth?: number;
|
|
58
77
|
borderRadius?: number;
|
|
59
78
|
skeletonCount?: number;
|
|
79
|
+
paginationSkeletonCount?: number;
|
|
60
80
|
containerStyle?: StyleProp<ViewStyle>;
|
|
61
81
|
titleStyle?: StyleProp<TextStyle>;
|
|
62
82
|
itemStyle?: StyleProp<ViewStyle>;
|
|
63
83
|
isLoading?: boolean;
|
|
84
|
+
onDisplayAds?: (ad: IServeAd) => void;
|
|
85
|
+
screenDimensions?: { width: number; height: number };
|
|
86
|
+
viewportOffsets?: {
|
|
87
|
+
top: number;
|
|
88
|
+
bottom: number;
|
|
89
|
+
left: number;
|
|
90
|
+
right: number;
|
|
91
|
+
};
|
|
64
92
|
} & AccessibilityProps;
|
|
65
93
|
|
|
94
|
+
// Main Component
|
|
66
95
|
const MovieCardFive: React.FC<MovieCardFiveProps> = ({
|
|
67
96
|
theme,
|
|
68
97
|
title,
|
|
69
98
|
section_id,
|
|
70
99
|
type,
|
|
71
|
-
data:
|
|
100
|
+
data: externalData,
|
|
72
101
|
moreFetchData,
|
|
73
102
|
onPressItem,
|
|
74
103
|
onPressMore,
|
|
@@ -76,32 +105,48 @@ const MovieCardFive: React.FC<MovieCardFiveProps> = ({
|
|
|
76
105
|
itemWidth = DEFAULT_ITEM_WIDTH,
|
|
77
106
|
borderRadius = DEFAULT_BORDER_RADIUS,
|
|
78
107
|
skeletonCount = DEFAULT_SKELETON_COUNT,
|
|
108
|
+
paginationSkeletonCount,
|
|
79
109
|
containerStyle,
|
|
80
110
|
titleStyle,
|
|
81
111
|
itemStyle,
|
|
82
112
|
isLoading = false,
|
|
83
113
|
accessibilityLabel,
|
|
84
114
|
accessibilityHint,
|
|
115
|
+
onDisplayAds,
|
|
116
|
+
screenDimensions,
|
|
117
|
+
viewportOffsets,
|
|
85
118
|
}) => {
|
|
86
|
-
|
|
87
|
-
const flatListRef = useRef<FlatList<IContentData>>(null);
|
|
119
|
+
// Refs
|
|
120
|
+
const flatListRef = useRef<FlatList<IContentData | IAdItem>>(null);
|
|
88
121
|
const onEndReachedCalledDuringMomentum = useRef(false);
|
|
122
|
+
|
|
123
|
+
// Theme
|
|
124
|
+
const { theme: appliedTheme } = useInternalTheme(theme);
|
|
125
|
+
|
|
126
|
+
// Styles
|
|
89
127
|
const styles = useMemo(
|
|
90
128
|
() => getStyles(appliedTheme, itemWidth, borderRadius),
|
|
91
129
|
[appliedTheme, itemWidth, borderRadius]
|
|
92
130
|
);
|
|
93
131
|
|
|
132
|
+
// Data Management
|
|
94
133
|
const {
|
|
95
|
-
|
|
134
|
+
listData,
|
|
96
135
|
pagination,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
136
|
+
loadMore,
|
|
137
|
+
isEmpty,
|
|
138
|
+
isPaging: isPaginating,
|
|
139
|
+
} = useCards({
|
|
140
|
+
sectionId: section_id,
|
|
141
|
+
data: externalData,
|
|
142
|
+
fetchMore: moreFetchData,
|
|
143
|
+
loading: isLoading,
|
|
144
|
+
initialSkeleton: skeletonCount,
|
|
145
|
+
pagingSkeleton: paginationSkeletonCount,
|
|
146
|
+
adsRender: true,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Event Handlers
|
|
105
150
|
const handleItemPress = useCallback(
|
|
106
151
|
(item: IContentData) => onPressItem?.(item),
|
|
107
152
|
[onPressItem]
|
|
@@ -118,29 +163,70 @@ const MovieCardFive: React.FC<MovieCardFiveProps> = ({
|
|
|
118
163
|
pagination?.nextPage
|
|
119
164
|
) {
|
|
120
165
|
onEndReachedCalledDuringMomentum.current = true;
|
|
121
|
-
|
|
166
|
+
loadMore(pagination.nextPage);
|
|
122
167
|
}
|
|
123
|
-
}, [
|
|
168
|
+
}, [loadMore, pagination]);
|
|
169
|
+
|
|
170
|
+
const handleScrollBeginDrag = useCallback(() => {
|
|
171
|
+
onEndReachedCalledDuringMomentum.current = false;
|
|
172
|
+
}, []);
|
|
124
173
|
|
|
174
|
+
const handleMomentumScrollBegin = useCallback(() => {
|
|
175
|
+
onEndReachedCalledDuringMomentum.current = false;
|
|
176
|
+
}, []);
|
|
177
|
+
|
|
178
|
+
// Render Functions
|
|
125
179
|
const renderItem = useCallback(
|
|
126
|
-
({ item, index }:
|
|
180
|
+
({ item, index }: { item: IContentData | IAdItem; index: number }) => {
|
|
181
|
+
// Handle ads
|
|
182
|
+
if ('type' in item && item.type === 'ads') {
|
|
183
|
+
const adItem = item as IAdItem;
|
|
184
|
+
return (
|
|
185
|
+
<View
|
|
186
|
+
key={`ad-${adItem.tracking?.impression || index}`}
|
|
187
|
+
style={[styles.item, itemStyle]}
|
|
188
|
+
>
|
|
189
|
+
<AdsPoster
|
|
190
|
+
ad={adItem}
|
|
191
|
+
theme={appliedTheme}
|
|
192
|
+
isLoading={isLoading}
|
|
193
|
+
containerStyle={{ width: itemWidth, aspectRatio: ASPECT_RATIO }}
|
|
194
|
+
imageStyle={styles.image}
|
|
195
|
+
borderRadius={borderRadius}
|
|
196
|
+
onDisplayAds={onDisplayAds}
|
|
197
|
+
screenDimensions={screenDimensions}
|
|
198
|
+
viewportOffsets={viewportOffsets}
|
|
199
|
+
/>
|
|
200
|
+
</View>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
// Handle content items
|
|
204
|
+
const contentItem = item as IContentData;
|
|
205
|
+
const isSkeleton =
|
|
206
|
+
contentItem._id?.startsWith?.('pagination-skeleton') ?? false;
|
|
207
|
+
|
|
127
208
|
return (
|
|
128
209
|
<TouchableOpacity
|
|
210
|
+
key={contentItem._id}
|
|
129
211
|
style={[styles.item, itemStyle]}
|
|
130
|
-
onPress={() =>
|
|
131
|
-
|
|
212
|
+
onPress={() => {
|
|
213
|
+
if (!isSkeleton && !isLoading) {
|
|
214
|
+
handleItemPress(contentItem);
|
|
215
|
+
}
|
|
216
|
+
}}
|
|
217
|
+
activeOpacity={ITEM_ACTIVE_OPACITY}
|
|
132
218
|
>
|
|
133
219
|
{renderItemImage ? (
|
|
134
220
|
renderItemImage({ item, index })
|
|
135
221
|
) : (
|
|
136
222
|
<CardPoster
|
|
137
|
-
content_offering_type={
|
|
138
|
-
posterUri={
|
|
223
|
+
content_offering_type={contentItem.content_offering_type}
|
|
224
|
+
posterUri={contentItem.poster}
|
|
139
225
|
theme={appliedTheme}
|
|
140
226
|
borderRadius={borderRadius}
|
|
141
227
|
posterWrapperStyle={styles.image}
|
|
142
228
|
resizeMode={FastImage.resizeMode.cover}
|
|
143
|
-
isLoading={isLoading}
|
|
229
|
+
isLoading={isSkeleton || isLoading}
|
|
144
230
|
/>
|
|
145
231
|
)}
|
|
146
232
|
</TouchableOpacity>
|
|
@@ -155,29 +241,44 @@ const MovieCardFive: React.FC<MovieCardFiveProps> = ({
|
|
|
155
241
|
borderRadius,
|
|
156
242
|
isLoading,
|
|
157
243
|
handleItemPress,
|
|
244
|
+
itemWidth,
|
|
245
|
+
onDisplayAds,
|
|
246
|
+
screenDimensions,
|
|
247
|
+
viewportOffsets,
|
|
158
248
|
]
|
|
159
249
|
);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
250
|
+
|
|
251
|
+
const renderSkeletonItem = useCallback(
|
|
252
|
+
({ index }: { index: number }) => (
|
|
253
|
+
<SkeletonPlaceholder
|
|
254
|
+
key={`skeleton-${index}`}
|
|
255
|
+
highlightColor={appliedTheme.colors.skeletonHighlightColor}
|
|
256
|
+
backgroundColor={appliedTheme.colors.skeletonBaseColor}
|
|
257
|
+
>
|
|
258
|
+
<SkeletonPlaceholder.Item
|
|
259
|
+
width={itemWidth}
|
|
260
|
+
aspectRatio={ASPECT_RATIO}
|
|
261
|
+
borderRadius={borderRadius}
|
|
262
|
+
marginLeft={index === 0 ? SKELETON_ITEM_MARGIN_LEFT : 0}
|
|
263
|
+
marginRight={SKELETON_ITEM_MARGIN_RIGHT}
|
|
264
|
+
/>
|
|
265
|
+
</SkeletonPlaceholder>
|
|
266
|
+
),
|
|
267
|
+
[appliedTheme, itemWidth, borderRadius]
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
const keyExtractor = useCallback(
|
|
271
|
+
(item: IContentData | IAdItem, index: number) => {
|
|
272
|
+
return '_id' in item ? item._id : `ad-${index}`;
|
|
273
|
+
},
|
|
274
|
+
[]
|
|
177
275
|
);
|
|
178
276
|
|
|
179
|
-
|
|
277
|
+
// Early Returns
|
|
278
|
+
if (!externalData) return null;
|
|
279
|
+
if (!isLoading && listData.length === 0 && !isEmpty) return null;
|
|
180
280
|
|
|
281
|
+
// Main Render
|
|
181
282
|
return (
|
|
182
283
|
<View
|
|
183
284
|
style={[styles.root, containerStyle]}
|
|
@@ -191,11 +292,11 @@ const MovieCardFive: React.FC<MovieCardFiveProps> = ({
|
|
|
191
292
|
backgroundColor={appliedTheme.colors.skeletonBaseColor}
|
|
192
293
|
>
|
|
193
294
|
<SkeletonPlaceholder.Item
|
|
194
|
-
width={
|
|
195
|
-
height={
|
|
196
|
-
borderRadius={
|
|
197
|
-
marginHorizontal={
|
|
198
|
-
marginBottom={
|
|
295
|
+
width={SKELETON_TITLE_WIDTH}
|
|
296
|
+
height={SKELETON_TITLE_HEIGHT}
|
|
297
|
+
borderRadius={SKELETON_TITLE_BORDER_RADIUS}
|
|
298
|
+
marginHorizontal={SKELETON_TITLE_MARGIN_HORIZONTAL}
|
|
299
|
+
marginBottom={SKELETON_TITLE_MARGIN_BOTTOM}
|
|
199
300
|
/>
|
|
200
301
|
</SkeletonPlaceholder>
|
|
201
302
|
|
|
@@ -222,23 +323,20 @@ const MovieCardFive: React.FC<MovieCardFiveProps> = ({
|
|
|
222
323
|
containerStyle={styles.navigateToMoreContainer}
|
|
223
324
|
showAllProps={{ iconColor: appliedTheme.colors.textPrimary, theme }}
|
|
224
325
|
/>
|
|
326
|
+
|
|
225
327
|
<FlatList
|
|
226
328
|
ref={flatListRef}
|
|
227
|
-
data={
|
|
329
|
+
data={listData}
|
|
228
330
|
horizontal
|
|
229
|
-
keyExtractor={
|
|
331
|
+
keyExtractor={keyExtractor}
|
|
230
332
|
renderItem={renderItem}
|
|
231
333
|
showsHorizontalScrollIndicator={false}
|
|
232
334
|
contentContainerStyle={styles.listContent}
|
|
233
|
-
initialNumToRender={
|
|
335
|
+
initialNumToRender={INITIAL_NUM_TO_RENDER}
|
|
234
336
|
onEndReached={handleEndReached}
|
|
235
|
-
onEndReachedThreshold={
|
|
236
|
-
onScrollBeginDrag={
|
|
237
|
-
|
|
238
|
-
}}
|
|
239
|
-
onMomentumScrollBegin={() => {
|
|
240
|
-
onEndReachedCalledDuringMomentum.current = false;
|
|
241
|
-
}}
|
|
337
|
+
onEndReachedThreshold={END_REACHED_THRESHOLD}
|
|
338
|
+
onScrollBeginDrag={handleScrollBeginDrag}
|
|
339
|
+
onMomentumScrollBegin={handleMomentumScrollBegin}
|
|
242
340
|
ListFooterComponent={
|
|
243
341
|
isPaginating ? renderSkeletonItem({ index: 0 }) : null
|
|
244
342
|
}
|
|
@@ -249,18 +347,19 @@ const MovieCardFive: React.FC<MovieCardFiveProps> = ({
|
|
|
249
347
|
);
|
|
250
348
|
};
|
|
251
349
|
|
|
350
|
+
// Styles
|
|
252
351
|
const getStyles = (theme: ITheme, width: number, radius: number) =>
|
|
253
352
|
StyleSheet.create({
|
|
254
353
|
root: {
|
|
255
354
|
marginVertical: verticalScale(6),
|
|
256
355
|
},
|
|
257
356
|
item: {
|
|
258
|
-
marginLeft:
|
|
259
|
-
marginBottom:
|
|
357
|
+
marginLeft: ITEM_MARGIN_LEFT,
|
|
358
|
+
marginBottom: ITEM_MARGIN_BOTTOM,
|
|
260
359
|
},
|
|
261
360
|
image: {
|
|
262
361
|
width,
|
|
263
|
-
aspectRatio:
|
|
362
|
+
aspectRatio: ASPECT_RATIO,
|
|
264
363
|
borderRadius: radius,
|
|
265
364
|
backgroundColor: theme.colors.surfaceVariant,
|
|
266
365
|
},
|
|
@@ -273,12 +372,12 @@ const getStyles = (theme: ITheme, width: number, radius: number) =>
|
|
|
273
372
|
fontWeight: '600',
|
|
274
373
|
},
|
|
275
374
|
listContent: {
|
|
276
|
-
paddingRight:
|
|
375
|
+
paddingRight: LIST_CONTENT_PADDING_RIGHT,
|
|
277
376
|
},
|
|
278
377
|
skeletonList: {
|
|
279
378
|
flexDirection: 'row',
|
|
280
379
|
alignItems: 'flex-start',
|
|
281
|
-
paddingRight:
|
|
380
|
+
paddingRight: SKELETON_LIST_PADDING_RIGHT,
|
|
282
381
|
},
|
|
283
382
|
});
|
|
284
383
|
|