@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
|
@@ -10,51 +10,88 @@ import { View, FlatList, TouchableOpacity, StyleSheet } from 'react-native';
|
|
|
10
10
|
import SkeletonPlaceholder from 'react-native-skeleton-placeholder';
|
|
11
11
|
import FastImage from 'react-native-fast-image';
|
|
12
12
|
import { moderateScale, verticalScale } from 'react-native-size-matters';
|
|
13
|
+
import { RFValue } from 'react-native-responsive-fontsize';
|
|
13
14
|
import { useInternalTheme } from "../../../../theme/hook/useInternalTheme.js";
|
|
14
15
|
import CardPoster from "../components/CardPoster.js";
|
|
15
16
|
import NavigateToMore from "../components/NavigateToMore.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
17
|
+
import { AdsPoster } from "../components/index.js";
|
|
18
|
+
import { useCards } from "../../../../hooks/index.js";
|
|
19
|
+
|
|
19
20
|
// Constants
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
22
|
const DEFAULT_ITEM_WIDTH = moderateScale(105);
|
|
21
23
|
const DEFAULT_ITEM_HEIGHT = moderateScale(160);
|
|
22
24
|
const DEFAULT_BORDER_RADIUS = moderateScale(6);
|
|
23
25
|
const DEFAULT_SKELETON_COUNT = 5;
|
|
26
|
+
const END_REACHED_THRESHOLD = 0.5;
|
|
27
|
+
const SKELETON_TITLE_WIDTH = moderateScale(100);
|
|
28
|
+
const SKELETON_TITLE_HEIGHT = verticalScale(14);
|
|
29
|
+
const SKELETON_TITLE_BORDER_RADIUS = moderateScale(4);
|
|
30
|
+
const SKELETON_ITEM_MARGIN = moderateScale(12);
|
|
31
|
+
const ITEM_ACTIVE_OPACITY = 0.8;
|
|
32
|
+
|
|
33
|
+
// Types
|
|
34
|
+
|
|
35
|
+
// Main Component
|
|
24
36
|
const MovieCard = ({
|
|
25
37
|
title,
|
|
26
38
|
section_id,
|
|
27
39
|
type,
|
|
28
|
-
data:
|
|
40
|
+
data: externalData,
|
|
29
41
|
moreFetchData,
|
|
30
|
-
onPressMore,
|
|
31
42
|
onPressItem,
|
|
43
|
+
onPressMore,
|
|
32
44
|
renderItemImage,
|
|
33
45
|
itemWidth = DEFAULT_ITEM_WIDTH,
|
|
34
46
|
itemHeight = DEFAULT_ITEM_HEIGHT,
|
|
35
47
|
borderRadius = DEFAULT_BORDER_RADIUS,
|
|
36
48
|
skeletonCount = DEFAULT_SKELETON_COUNT,
|
|
49
|
+
paginationSkeletonCount,
|
|
37
50
|
containerStyle,
|
|
38
51
|
titleStyle,
|
|
39
52
|
itemStyle,
|
|
40
53
|
isLoading = false,
|
|
41
54
|
theme,
|
|
42
55
|
accessibilityLabel,
|
|
43
|
-
accessibilityHint
|
|
56
|
+
accessibilityHint,
|
|
57
|
+
onDisplayAds,
|
|
58
|
+
screenDimensions,
|
|
59
|
+
viewportOffsets
|
|
44
60
|
}) => {
|
|
61
|
+
// Refs
|
|
45
62
|
const flatListRef = useRef(null);
|
|
63
|
+
const containerRef = useRef(null);
|
|
46
64
|
const onEndReachedCalledDuringMomentum = useRef(false);
|
|
65
|
+
|
|
66
|
+
// Theme
|
|
47
67
|
const {
|
|
48
68
|
theme: appliedTheme
|
|
49
69
|
} = useInternalTheme(theme);
|
|
70
|
+
|
|
71
|
+
// Styles
|
|
50
72
|
const styles = useMemo(() => getStyles(appliedTheme, itemWidth, itemHeight, borderRadius), [appliedTheme, itemWidth, itemHeight, borderRadius]);
|
|
73
|
+
|
|
74
|
+
// Data Management
|
|
51
75
|
const {
|
|
52
|
-
|
|
76
|
+
listData,
|
|
53
77
|
pagination,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
loadMore,
|
|
79
|
+
isEmpty,
|
|
80
|
+
isPaging: isPaginating
|
|
81
|
+
} = useCards({
|
|
82
|
+
sectionId: section_id,
|
|
83
|
+
data: externalData,
|
|
84
|
+
fetchMore: moreFetchData,
|
|
85
|
+
loading: isLoading,
|
|
86
|
+
initialSkeleton: skeletonCount,
|
|
87
|
+
pagingSkeleton: paginationSkeletonCount,
|
|
88
|
+
adsRender: true
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Event Handlers
|
|
92
|
+
const handleItemPress = useCallback(item => {
|
|
93
|
+
onPressItem?.(item);
|
|
94
|
+
}, [onPressItem]);
|
|
58
95
|
const handlePressMore = useCallback(() => {
|
|
59
96
|
onPressMore?.({
|
|
60
97
|
section_id,
|
|
@@ -65,32 +102,67 @@ const MovieCard = ({
|
|
|
65
102
|
const handleEndReached = useCallback(() => {
|
|
66
103
|
if (!onEndReachedCalledDuringMomentum.current && pagination?.hasNextPage && pagination?.nextPage) {
|
|
67
104
|
onEndReachedCalledDuringMomentum.current = true;
|
|
68
|
-
|
|
105
|
+
loadMore(pagination.nextPage);
|
|
69
106
|
}
|
|
70
|
-
}, [
|
|
107
|
+
}, [pagination, loadMore]);
|
|
108
|
+
const handleMomentumScrollBegin = useCallback(() => {
|
|
109
|
+
onEndReachedCalledDuringMomentum.current = false;
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
// Render Functions
|
|
71
113
|
const renderItem = useCallback(({
|
|
72
114
|
item,
|
|
73
115
|
index
|
|
74
116
|
}) => {
|
|
117
|
+
// Handle ads
|
|
118
|
+
if ('type' in item && item.type === 'ads') {
|
|
119
|
+
const adItem = item;
|
|
120
|
+
return /*#__PURE__*/_jsx(View, {
|
|
121
|
+
style: [styles.item, itemStyle],
|
|
122
|
+
children: /*#__PURE__*/_jsx(AdsPoster, {
|
|
123
|
+
ad: adItem,
|
|
124
|
+
theme: appliedTheme,
|
|
125
|
+
isLoading: isLoading,
|
|
126
|
+
containerStyle: {
|
|
127
|
+
width: itemWidth,
|
|
128
|
+
height: itemHeight
|
|
129
|
+
},
|
|
130
|
+
imageStyle: styles.image,
|
|
131
|
+
onPress: () => handleItemPress(adItem),
|
|
132
|
+
borderRadius: borderRadius,
|
|
133
|
+
onDisplayAds: onDisplayAds,
|
|
134
|
+
screenDimensions: screenDimensions,
|
|
135
|
+
viewportOffsets: viewportOffsets
|
|
136
|
+
})
|
|
137
|
+
}, `ad-${adItem.tracking?.impression || index}`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Handle content items
|
|
141
|
+
const contentItem = item;
|
|
142
|
+
const isSkeleton = contentItem._id?.startsWith?.('pagination-skeleton') ?? false;
|
|
75
143
|
return /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
76
144
|
style: [styles.item, itemStyle],
|
|
77
|
-
|
|
78
|
-
|
|
145
|
+
activeOpacity: ITEM_ACTIVE_OPACITY,
|
|
146
|
+
onPress: () => {
|
|
147
|
+
if (!isSkeleton && !isLoading) {
|
|
148
|
+
handleItemPress(contentItem);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
79
151
|
children: renderItemImage ? renderItemImage({
|
|
80
152
|
item,
|
|
81
153
|
index
|
|
82
154
|
}) : /*#__PURE__*/_jsx(CardPoster, {
|
|
83
|
-
|
|
84
|
-
|
|
155
|
+
posterUri: contentItem.poster,
|
|
156
|
+
content_offering_type: contentItem.content_offering_type,
|
|
85
157
|
theme: appliedTheme,
|
|
86
158
|
borderRadius: borderRadius,
|
|
87
159
|
posterWrapperStyle: styles.image,
|
|
88
160
|
resizeMode: FastImage.resizeMode.cover,
|
|
89
|
-
isLoading: isLoading
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
}, [styles.item, styles.image, itemStyle, renderItemImage, appliedTheme, borderRadius, isLoading, handleItemPress]);
|
|
93
|
-
const renderSkeletonItem = ({
|
|
161
|
+
isLoading: isSkeleton || isLoading
|
|
162
|
+
})
|
|
163
|
+
}, contentItem._id);
|
|
164
|
+
}, [styles.item, styles.image, itemStyle, renderItemImage, appliedTheme, borderRadius, isLoading, itemWidth, itemHeight, onDisplayAds, screenDimensions, viewportOffsets, handleItemPress]);
|
|
165
|
+
const renderSkeletonItem = useCallback(({
|
|
94
166
|
index
|
|
95
167
|
}) => /*#__PURE__*/_jsx(SkeletonPlaceholder, {
|
|
96
168
|
highlightColor: appliedTheme.colors.skeletonHighlightColor,
|
|
@@ -99,32 +171,39 @@ const MovieCard = ({
|
|
|
99
171
|
width: itemWidth,
|
|
100
172
|
height: itemHeight,
|
|
101
173
|
borderRadius: borderRadius,
|
|
102
|
-
marginLeft: index === 0 ?
|
|
103
|
-
marginRight:
|
|
174
|
+
marginLeft: index === 0 ? SKELETON_ITEM_MARGIN : 0,
|
|
175
|
+
marginRight: SKELETON_ITEM_MARGIN
|
|
104
176
|
})
|
|
105
|
-
}, `skeleton-${index}`);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
177
|
+
}, `skeleton-${index}`), [appliedTheme, itemWidth, itemHeight, borderRadius]);
|
|
178
|
+
const keyExtractor = useCallback((item, index) => {
|
|
179
|
+
if ('type' in item && item.type === 'ads') {
|
|
180
|
+
return `ad-${item.tracking?.impression || index}`;
|
|
181
|
+
}
|
|
182
|
+
return item._id || `item-${index}`;
|
|
183
|
+
}, []);
|
|
184
|
+
|
|
185
|
+
// Early Returns
|
|
186
|
+
if (!externalData) return null;
|
|
187
|
+
if (!isLoading && listData.length === 0 && !isEmpty) return null;
|
|
188
|
+
|
|
189
|
+
// Loading State
|
|
110
190
|
if (isLoading) {
|
|
111
191
|
return /*#__PURE__*/_jsxs(View, {
|
|
112
192
|
style: [styles.root, containerStyle],
|
|
113
|
-
testID: `movie-card-skeleton-${section_id}`,
|
|
114
193
|
children: [/*#__PURE__*/_jsx(SkeletonPlaceholder, {
|
|
115
194
|
highlightColor: appliedTheme.colors.skeletonHighlightColor,
|
|
116
195
|
backgroundColor: appliedTheme.colors.skeletonBaseColor,
|
|
117
196
|
children: /*#__PURE__*/_jsx(SkeletonPlaceholder.Item, {
|
|
118
|
-
width:
|
|
119
|
-
height:
|
|
120
|
-
borderRadius:
|
|
121
|
-
marginLeft:
|
|
197
|
+
width: SKELETON_TITLE_WIDTH,
|
|
198
|
+
height: SKELETON_TITLE_HEIGHT,
|
|
199
|
+
borderRadius: SKELETON_TITLE_BORDER_RADIUS,
|
|
200
|
+
marginLeft: SKELETON_ITEM_MARGIN,
|
|
122
201
|
marginBottom: verticalScale(6)
|
|
123
202
|
})
|
|
124
203
|
}), /*#__PURE__*/_jsx(FlatList, {
|
|
125
204
|
data: Array.from({
|
|
126
205
|
length: skeletonCount
|
|
127
|
-
}
|
|
206
|
+
}),
|
|
128
207
|
horizontal: true,
|
|
129
208
|
keyExtractor: (_, index) => `skeleton-${index}`,
|
|
130
209
|
renderItem: renderSkeletonItem,
|
|
@@ -133,11 +212,14 @@ const MovieCard = ({
|
|
|
133
212
|
})]
|
|
134
213
|
});
|
|
135
214
|
}
|
|
215
|
+
|
|
216
|
+
// Main Render
|
|
136
217
|
return /*#__PURE__*/_jsxs(View, {
|
|
218
|
+
ref: containerRef,
|
|
137
219
|
style: [styles.root, containerStyle],
|
|
138
|
-
testID: `movie-card-${section_id}`,
|
|
139
220
|
accessibilityLabel: accessibilityLabel || `Movie section: ${title}`,
|
|
140
|
-
accessibilityHint: accessibilityHint || 'Scroll to view
|
|
221
|
+
accessibilityHint: accessibilityHint || 'Scroll to view items',
|
|
222
|
+
testID: `movie-card-${section_id}`,
|
|
141
223
|
children: [/*#__PURE__*/_jsx(NavigateToMore, {
|
|
142
224
|
title: title,
|
|
143
225
|
onPress: handlePressMore,
|
|
@@ -151,27 +233,23 @@ const MovieCard = ({
|
|
|
151
233
|
}
|
|
152
234
|
}), /*#__PURE__*/_jsx(FlatList, {
|
|
153
235
|
ref: flatListRef,
|
|
154
|
-
data:
|
|
236
|
+
data: listData,
|
|
155
237
|
horizontal: true,
|
|
156
|
-
keyExtractor:
|
|
238
|
+
keyExtractor: keyExtractor,
|
|
157
239
|
renderItem: renderItem,
|
|
158
240
|
showsHorizontalScrollIndicator: false,
|
|
159
241
|
contentContainerStyle: styles.listContent,
|
|
160
|
-
initialNumToRender: 5,
|
|
161
242
|
onEndReached: handleEndReached,
|
|
162
|
-
onEndReachedThreshold:
|
|
163
|
-
|
|
164
|
-
onEndReachedCalledDuringMomentum.current = false;
|
|
165
|
-
},
|
|
166
|
-
onMomentumScrollBegin: () => {
|
|
167
|
-
onEndReachedCalledDuringMomentum.current = false;
|
|
168
|
-
},
|
|
243
|
+
onEndReachedThreshold: END_REACHED_THRESHOLD,
|
|
244
|
+
onMomentumScrollBegin: handleMomentumScrollBegin,
|
|
169
245
|
ListFooterComponent: isPaginating ? renderSkeletonItem({
|
|
170
246
|
index: 0
|
|
171
247
|
}) : null
|
|
172
248
|
})]
|
|
173
249
|
});
|
|
174
250
|
};
|
|
251
|
+
|
|
252
|
+
// Styles
|
|
175
253
|
const getStyles = (theme, width, height, radius) => StyleSheet.create({
|
|
176
254
|
root: {
|
|
177
255
|
marginVertical: verticalScale(6)
|
|
@@ -185,9 +263,6 @@ const getStyles = (theme, width, height, radius) => StyleSheet.create({
|
|
|
185
263
|
borderRadius: radius,
|
|
186
264
|
backgroundColor: theme.colors.surfaceVariant
|
|
187
265
|
},
|
|
188
|
-
imageWrapper: {
|
|
189
|
-
position: 'relative'
|
|
190
|
-
},
|
|
191
266
|
navigateToMoreContainer: {
|
|
192
267
|
paddingHorizontal: moderateScale(10),
|
|
193
268
|
marginBottom: verticalScale(8)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","memo","useCallback","useMemo","useRef","View","FlatList","TouchableOpacity","StyleSheet","SkeletonPlaceholder","FastImage","moderateScale","verticalScale","useInternalTheme","CardPoster","NavigateToMore","
|
|
1
|
+
{"version":3,"names":["React","memo","useCallback","useMemo","useRef","View","FlatList","TouchableOpacity","StyleSheet","SkeletonPlaceholder","FastImage","moderateScale","verticalScale","RFValue","useInternalTheme","CardPoster","NavigateToMore","AdsPoster","useCards","jsx","_jsx","jsxs","_jsxs","DEFAULT_ITEM_WIDTH","DEFAULT_ITEM_HEIGHT","DEFAULT_BORDER_RADIUS","DEFAULT_SKELETON_COUNT","END_REACHED_THRESHOLD","SKELETON_TITLE_WIDTH","SKELETON_TITLE_HEIGHT","SKELETON_TITLE_BORDER_RADIUS","SKELETON_ITEM_MARGIN","ITEM_ACTIVE_OPACITY","MovieCard","title","section_id","type","data","externalData","moreFetchData","onPressItem","onPressMore","renderItemImage","itemWidth","itemHeight","borderRadius","skeletonCount","paginationSkeletonCount","containerStyle","titleStyle","itemStyle","isLoading","theme","accessibilityLabel","accessibilityHint","onDisplayAds","screenDimensions","viewportOffsets","flatListRef","containerRef","onEndReachedCalledDuringMomentum","appliedTheme","styles","getStyles","listData","pagination","loadMore","isEmpty","isPaging","isPaginating","sectionId","fetchMore","loading","initialSkeleton","pagingSkeleton","adsRender","handleItemPress","item","handlePressMore","name","handleEndReached","current","hasNextPage","nextPage","handleMomentumScrollBegin","renderItem","index","adItem","style","children","ad","width","height","imageStyle","image","onPress","tracking","impression","contentItem","isSkeleton","_id","startsWith","activeOpacity","posterUri","poster","content_offering_type","posterWrapperStyle","resizeMode","cover","renderSkeletonItem","highlightColor","colors","skeletonHighlightColor","backgroundColor","skeletonBaseColor","Item","marginLeft","marginRight","keyExtractor","length","root","marginBottom","Array","from","horizontal","_","showsHorizontalScrollIndicator","contentContainerStyle","listContent","ref","testID","color","textPrimary","navigateToMoreContainer","showAllProps","iconColor","onEndReached","onEndReachedThreshold","onMomentumScrollBegin","ListFooterComponent","radius","create","marginVertical","surfaceVariant","paddingHorizontal","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,KAAK,EAAE;IACL+G,QAAQ,EAAEpI,OAAO,CAAC,EAAE,CAAC;IACrBqI,UAAU,EAAE;EACd,CAAC;EACDlB,WAAW,EAAE;IACXmB,YAAY,EAAExI,aAAa,CAAC,EAAE;EAChC;AACF,CAAC,CAAC;AAEJ,4BAAeV,IAAI,CAACgC,SAAS,CAAC","ignoreList":[]}
|
|
@@ -15,19 +15,45 @@ import { debounce } from 'lodash';
|
|
|
15
15
|
import { useInternalTheme } from "../../../../theme/hook/useInternalTheme.js";
|
|
16
16
|
import CardPoster from "../components/CardPoster.js";
|
|
17
17
|
import NavigateToMore from "../components/NavigateToMore.js";
|
|
18
|
-
import {
|
|
18
|
+
import { AdsPoster } from "../components/index.js";
|
|
19
19
|
import { useSkeletonItems } from "../../../../hooks/useSkeletonItems.js";
|
|
20
20
|
import { RFValue } from 'react-native-responsive-fontsize';
|
|
21
|
+
import { useCards } from "../../../../hooks/index.js";
|
|
22
|
+
|
|
23
|
+
// Constants
|
|
21
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
25
|
const {
|
|
23
26
|
width,
|
|
24
27
|
height
|
|
25
28
|
} = Dimensions.get('window');
|
|
26
|
-
const
|
|
27
|
-
const
|
|
29
|
+
const ITEM_WIDTH_RATIO = 0.42;
|
|
30
|
+
const ITEM_HEIGHT_RATIO = 0.28;
|
|
31
|
+
const DEFAULT_ITEM_WIDTH = width * ITEM_WIDTH_RATIO;
|
|
32
|
+
const DEFAULT_ITEM_HEIGHT = height * ITEM_HEIGHT_RATIO;
|
|
28
33
|
const DEFAULT_BORDER_RADIUS = moderateScale(10);
|
|
34
|
+
const DEFAULT_SKELETON_COUNT = 5;
|
|
35
|
+
const DEBOUNCE_DELAY = 300;
|
|
36
|
+
const ITEM_ACTIVE_OPACITY = 0.8;
|
|
37
|
+
const CAROUSEL_FIRST_ITEM = 1;
|
|
38
|
+
const CAROUSEL_INACTIVE_OPACITY = 0.6;
|
|
39
|
+
const CAROUSEL_INACTIVE_SCALE = 0.9;
|
|
40
|
+
const PAGINATION_TRIGGER_OFFSET = 2;
|
|
41
|
+
const SKELETON_TITLE_WIDTH = moderateScale(100);
|
|
42
|
+
const SKELETON_TITLE_HEIGHT = verticalScale(14);
|
|
43
|
+
const SKELETON_TITLE_BORDER_RADIUS = moderateScale(4);
|
|
44
|
+
const SKELETON_TITLE_MARGIN_LEFT = moderateScale(12);
|
|
45
|
+
const SKELETON_TITLE_MARGIN_BOTTOM = verticalScale(6);
|
|
46
|
+
const SKELETON_ITEM_MARGIN_RIGHT = moderateScale(12);
|
|
47
|
+
const DEFAULT_SKELETON_BACKGROUND_COLOR = '#222';
|
|
48
|
+
const SHADOW_ELEVATION = 0;
|
|
49
|
+
const SHADOW_OFFSET = {
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0
|
|
52
|
+
};
|
|
53
|
+
const SHADOW_OPACITY = 0;
|
|
54
|
+
const SHADOW_RADIUS = 0;
|
|
29
55
|
|
|
30
|
-
// Static
|
|
56
|
+
// Static Styles
|
|
31
57
|
const staticStyles = StyleSheet.create({
|
|
32
58
|
root: {
|
|
33
59
|
marginVertical: verticalScale(6)
|
|
@@ -43,11 +69,15 @@ const staticStyles = StyleSheet.create({
|
|
|
43
69
|
marginVertical: moderateScale(5)
|
|
44
70
|
}
|
|
45
71
|
});
|
|
72
|
+
|
|
73
|
+
// Types
|
|
74
|
+
|
|
75
|
+
// Main Component
|
|
46
76
|
const RotateCarousel = ({
|
|
47
77
|
title,
|
|
48
78
|
section_id,
|
|
49
79
|
type,
|
|
50
|
-
data:
|
|
80
|
+
data: externalData,
|
|
51
81
|
moreFetchData,
|
|
52
82
|
onPressMore,
|
|
53
83
|
onPressItem,
|
|
@@ -55,64 +85,80 @@ const RotateCarousel = ({
|
|
|
55
85
|
itemWidth = DEFAULT_ITEM_WIDTH,
|
|
56
86
|
itemHeight = DEFAULT_ITEM_HEIGHT,
|
|
57
87
|
borderRadius = DEFAULT_BORDER_RADIUS,
|
|
58
|
-
skeletonCount =
|
|
88
|
+
skeletonCount = DEFAULT_SKELETON_COUNT,
|
|
59
89
|
containerStyle,
|
|
60
90
|
titleStyle,
|
|
91
|
+
paginationSkeletonCount,
|
|
61
92
|
itemStyle,
|
|
62
93
|
isLoading = false,
|
|
63
|
-
theme
|
|
94
|
+
theme,
|
|
95
|
+
onDisplayAds,
|
|
96
|
+
screenDimensions,
|
|
97
|
+
viewportOffsets
|
|
64
98
|
}) => {
|
|
99
|
+
// Refs
|
|
100
|
+
const carouselRef = useRef(null);
|
|
101
|
+
|
|
102
|
+
// Theme
|
|
65
103
|
const {
|
|
66
104
|
theme: appliedTheme
|
|
67
105
|
} = useInternalTheme(theme);
|
|
68
|
-
const carouselRef = useRef(null);
|
|
69
106
|
|
|
70
|
-
//
|
|
107
|
+
// Styles
|
|
71
108
|
const styles = useMemo(() => StyleSheet.create({
|
|
72
109
|
item: {
|
|
73
110
|
width: itemWidth,
|
|
74
111
|
height: itemHeight,
|
|
75
112
|
borderRadius,
|
|
76
113
|
overflow: 'hidden',
|
|
77
|
-
elevation:
|
|
114
|
+
elevation: SHADOW_ELEVATION,
|
|
78
115
|
shadowColor: 'transparent',
|
|
79
|
-
shadowOffset:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
shadowOpacity: 0,
|
|
84
|
-
shadowRadius: 0
|
|
116
|
+
shadowOffset: SHADOW_OFFSET,
|
|
117
|
+
shadowOpacity: SHADOW_OPACITY,
|
|
118
|
+
shadowRadius: SHADOW_RADIUS
|
|
85
119
|
},
|
|
86
120
|
image: {
|
|
87
121
|
width: '100%',
|
|
88
122
|
height: '100%',
|
|
89
|
-
backgroundColor: appliedTheme.colors.skeletonBaseColor ??
|
|
123
|
+
backgroundColor: appliedTheme.colors.skeletonBaseColor ?? DEFAULT_SKELETON_BACKGROUND_COLOR
|
|
90
124
|
},
|
|
91
125
|
skeleton: {
|
|
92
126
|
width: itemWidth,
|
|
93
127
|
height: itemHeight,
|
|
94
128
|
borderRadius,
|
|
95
129
|
overflow: 'hidden',
|
|
96
|
-
marginRight:
|
|
130
|
+
marginRight: SKELETON_ITEM_MARGIN_RIGHT
|
|
97
131
|
}
|
|
98
132
|
}), [appliedTheme.colors.skeletonBaseColor, itemWidth, itemHeight, borderRadius]);
|
|
133
|
+
|
|
134
|
+
// Data Management
|
|
99
135
|
const {
|
|
100
|
-
|
|
101
|
-
loading: isPaginating,
|
|
136
|
+
listData,
|
|
102
137
|
pagination,
|
|
103
|
-
|
|
104
|
-
|
|
138
|
+
loadMore,
|
|
139
|
+
isEmpty,
|
|
140
|
+
isPaging: isPaginating
|
|
141
|
+
} = useCards({
|
|
142
|
+
sectionId: section_id,
|
|
143
|
+
data: externalData,
|
|
144
|
+
fetchMore: moreFetchData,
|
|
145
|
+
loading: isLoading,
|
|
146
|
+
initialSkeleton: skeletonCount,
|
|
147
|
+
pagingSkeleton: paginationSkeletonCount,
|
|
148
|
+
adsRender: true
|
|
149
|
+
});
|
|
105
150
|
|
|
106
|
-
//
|
|
151
|
+
// Skeleton Data
|
|
107
152
|
const skeletonCountMemo = useMemo(() => isLoading ? skeletonCount : isPaginating ? 1 : 0, [isLoading, isPaginating, skeletonCount]);
|
|
108
153
|
const skeletonItems = useSkeletonItems(skeletonCountMemo);
|
|
154
|
+
const finalData = useMemo(() => isLoading ? skeletonItems : skeletonItems.length > 0 ? [...listData, ...skeletonItems] : listData, [isLoading, listData, skeletonItems]);
|
|
109
155
|
|
|
110
|
-
//
|
|
111
|
-
const finalData = useMemo(() => isLoading ? skeletonItems : skeletonItems.length > 0 ? [...data, ...skeletonItems] : data, [isLoading, data, skeletonItems]);
|
|
112
|
-
// Debounced loadMoreData to prevent excessive calls
|
|
156
|
+
// Debounced Functions
|
|
113
157
|
const debouncedLoadMore = useMemo(() => debounce(nextPage => {
|
|
114
|
-
return
|
|
115
|
-
},
|
|
158
|
+
return loadMore(nextPage);
|
|
159
|
+
}, DEBOUNCE_DELAY), [loadMore]);
|
|
160
|
+
|
|
161
|
+
// Event Handlers
|
|
116
162
|
const handleItemPress = useCallback(item => {
|
|
117
163
|
onPressItem?.(item);
|
|
118
164
|
}, [onPressItem]);
|
|
@@ -123,10 +169,13 @@ const RotateCarousel = ({
|
|
|
123
169
|
type
|
|
124
170
|
});
|
|
125
171
|
}, [onPressMore, section_id, title, type]);
|
|
172
|
+
|
|
173
|
+
// Render Functions
|
|
126
174
|
const renderItem = useCallback(({
|
|
127
175
|
item,
|
|
128
176
|
index
|
|
129
177
|
}) => {
|
|
178
|
+
// Handle skeleton items
|
|
130
179
|
if ('isSkeleton' in item) {
|
|
131
180
|
return /*#__PURE__*/_jsx(View, {
|
|
132
181
|
style: styles.skeleton,
|
|
@@ -141,29 +190,70 @@ const RotateCarousel = ({
|
|
|
141
190
|
})
|
|
142
191
|
}, item._id);
|
|
143
192
|
}
|
|
193
|
+
|
|
194
|
+
// Handle ads
|
|
195
|
+
if ('type' in item && item.type === 'ads') {
|
|
196
|
+
const adItem = item;
|
|
197
|
+
return /*#__PURE__*/_jsx(View, {
|
|
198
|
+
style: [styles.item, itemStyle],
|
|
199
|
+
children: /*#__PURE__*/_jsx(AdsPoster, {
|
|
200
|
+
ad: adItem,
|
|
201
|
+
theme: appliedTheme,
|
|
202
|
+
isLoading: isLoading,
|
|
203
|
+
containerStyle: {
|
|
204
|
+
width: itemWidth,
|
|
205
|
+
height: itemHeight
|
|
206
|
+
},
|
|
207
|
+
imageStyle: styles.image,
|
|
208
|
+
borderRadius: borderRadius,
|
|
209
|
+
onDisplayAds: onDisplayAds,
|
|
210
|
+
screenDimensions: screenDimensions,
|
|
211
|
+
viewportOffsets: viewportOffsets
|
|
212
|
+
})
|
|
213
|
+
}, `ad-${adItem.tracking?.impression || index}`);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Handle content items
|
|
217
|
+
const contentItem = item;
|
|
218
|
+
const isSkeleton = contentItem._id?.startsWith?.('pagination-skeleton') ?? false;
|
|
144
219
|
return /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
145
|
-
activeOpacity:
|
|
220
|
+
activeOpacity: ITEM_ACTIVE_OPACITY,
|
|
146
221
|
style: [styles.item, itemStyle],
|
|
147
|
-
disabled: !
|
|
148
|
-
onPress: () =>
|
|
222
|
+
disabled: !contentItem || !onPressItem || isLoading || isSkeleton,
|
|
223
|
+
onPress: () => {
|
|
224
|
+
if (!isSkeleton && !isLoading) {
|
|
225
|
+
handleItemPress(contentItem);
|
|
226
|
+
}
|
|
227
|
+
},
|
|
149
228
|
children: renderItemImage ? renderItemImage({
|
|
150
|
-
item,
|
|
229
|
+
item: contentItem,
|
|
151
230
|
index
|
|
152
231
|
}) : /*#__PURE__*/_jsx(CardPoster, {
|
|
153
|
-
content_offering_type:
|
|
154
|
-
posterUri:
|
|
232
|
+
content_offering_type: contentItem.content_offering_type,
|
|
233
|
+
posterUri: contentItem.poster,
|
|
155
234
|
theme: appliedTheme,
|
|
156
235
|
borderRadius: borderRadius,
|
|
157
236
|
posterWrapperStyle: styles.image,
|
|
158
237
|
resizeMode: FastImage.resizeMode.cover,
|
|
159
|
-
isLoading: isLoading
|
|
238
|
+
isLoading: isSkeleton || isLoading
|
|
160
239
|
})
|
|
161
|
-
},
|
|
162
|
-
}, [styles.item, styles.image, styles.skeleton, itemStyle, onPressItem, isLoading, renderItemImage, appliedTheme, borderRadius, itemWidth, itemHeight, handleItemPress]);
|
|
163
|
-
|
|
240
|
+
}, contentItem._id || `item-${index}`);
|
|
241
|
+
}, [styles.item, styles.image, styles.skeleton, itemStyle, onPressItem, isLoading, renderItemImage, appliedTheme, borderRadius, itemWidth, itemHeight, handleItemPress, onDisplayAds, screenDimensions, viewportOffsets]);
|
|
242
|
+
const handleSnapToItem = useCallback(index => {
|
|
243
|
+
if (isLoading || !pagination?.hasNextPage || !pagination?.nextPage) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (index >= finalData.length - PAGINATION_TRIGGER_OFFSET) {
|
|
247
|
+
debouncedLoadMore(pagination.nextPage);
|
|
248
|
+
}
|
|
249
|
+
}, [isLoading, pagination, finalData.length, debouncedLoadMore]);
|
|
250
|
+
|
|
251
|
+
// Early Returns
|
|
252
|
+
if (!externalData || !isLoading && listData.length === 0 || !isLoading && isEmpty) {
|
|
164
253
|
return null;
|
|
165
254
|
}
|
|
166
|
-
|
|
255
|
+
|
|
256
|
+
// Main Render
|
|
167
257
|
return /*#__PURE__*/_jsxs(View, {
|
|
168
258
|
style: [staticStyles.root, containerStyle],
|
|
169
259
|
testID: `movie-card-${section_id}`,
|
|
@@ -171,11 +261,11 @@ const RotateCarousel = ({
|
|
|
171
261
|
highlightColor: appliedTheme.colors.skeletonHighlightColor,
|
|
172
262
|
backgroundColor: appliedTheme.colors.skeletonBaseColor,
|
|
173
263
|
children: /*#__PURE__*/_jsx(SkeletonPlaceholder.Item, {
|
|
174
|
-
width:
|
|
175
|
-
height:
|
|
176
|
-
borderRadius:
|
|
177
|
-
marginLeft:
|
|
178
|
-
marginBottom:
|
|
264
|
+
width: SKELETON_TITLE_WIDTH,
|
|
265
|
+
height: SKELETON_TITLE_HEIGHT,
|
|
266
|
+
borderRadius: SKELETON_TITLE_BORDER_RADIUS,
|
|
267
|
+
marginLeft: SKELETON_TITLE_MARGIN_LEFT,
|
|
268
|
+
marginBottom: SKELETON_TITLE_MARGIN_BOTTOM
|
|
179
269
|
})
|
|
180
270
|
}) : /*#__PURE__*/_jsx(NavigateToMore, {
|
|
181
271
|
title: title,
|
|
@@ -193,17 +283,12 @@ const RotateCarousel = ({
|
|
|
193
283
|
data: finalData,
|
|
194
284
|
vertical: false,
|
|
195
285
|
renderItem: renderItem,
|
|
196
|
-
firstItem:
|
|
197
|
-
inactiveSlideOpacity:
|
|
198
|
-
inactiveSlideScale:
|
|
286
|
+
firstItem: CAROUSEL_FIRST_ITEM,
|
|
287
|
+
inactiveSlideOpacity: CAROUSEL_INACTIVE_OPACITY,
|
|
288
|
+
inactiveSlideScale: CAROUSEL_INACTIVE_SCALE,
|
|
199
289
|
sliderWidth: width,
|
|
200
290
|
itemWidth: itemWidth,
|
|
201
|
-
onSnapToItem:
|
|
202
|
-
if (isLoading || !pagination?.hasNextPage || !pagination?.nextPage) return;
|
|
203
|
-
if (index >= finalData.length - 2) {
|
|
204
|
-
debouncedLoadMore(pagination.nextPage);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
291
|
+
onSnapToItem: handleSnapToItem
|
|
207
292
|
})]
|
|
208
293
|
});
|
|
209
294
|
};
|