@zezosoft/zezo-ott-react-native-ui-kit 1.1.5 → 1.1.7
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/Content/Card/Sliders/Styles/Three.js +5 -4
- package/lib/module/components/Content/Card/Sliders/Styles/Three.js.map +1 -1
- package/lib/module/components/Headers/Four.js +1 -1
- package/lib/module/components/Headers/Three.js +2 -1
- package/lib/module/components/Headers/Three.js.map +1 -1
- package/lib/typescript/src/components/Content/Card/Sliders/Styles/Three.d.ts.map +1 -1
- package/package.json +2 -14
- package/src/Styles/globalStyles.ts +0 -70
- package/src/assets/animations/135037-payment-processing-error.json +0 -1347
- package/src/assets/animations/7227-vui-animation.json +0 -3377
- package/src/assets/animations/Failed.json +0 -2103
- package/src/assets/animations/Pending.json +0 -522
- package/src/assets/animations/Successful.json +0 -2289
- package/src/assets/animations/heart.json +0 -788
- package/src/assets/animations/succesfull-payment.json +0 -2379
- package/src/assets/animations/voice-icon.json +0 -542
- package/src/assets/img/back.png +0 -0
- package/src/assets/img/bottom-panel.png +0 -0
- package/src/assets/img/camera.png +0 -0
- package/src/assets/img/camera2.png +0 -0
- package/src/assets/img/home.png +0 -0
- package/src/assets/img/lock.png +0 -0
- package/src/assets/img/play.png +0 -0
- package/src/assets/img/profile.jpg +0 -0
- package/src/assets/img/qr-code.png +0 -0
- package/src/assets/img/shadow.png +0 -0
- package/src/assets/img/shadow2.png +0 -0
- package/src/assets/img/user.png +0 -0
- package/src/assets/svg/Account.svg +0 -4
- package/src/assets/svg/Favourite.svg +0 -14
- package/src/assets/svg/Upcoming.svg +0 -4
- package/src/assets/svg/content-error.svg +0 -28
- package/src/assets/svg/download.svg +0 -3
- package/src/assets/svg/eye-off.svg +0 -10
- package/src/assets/svg/favorites.svg +0 -3
- package/src/assets/svg/h.svg +0 -4
- package/src/assets/svg/home.svg +0 -5
- package/src/assets/svg/home1.svg +0 -3
- package/src/assets/svg/menu-bar.svg +0 -4
- package/src/assets/svg/my-space.svg +0 -14
- package/src/assets/svg/play-icon-with-bg.svg +0 -5
- package/src/assets/svg/profile.svg +0 -4
- package/src/assets/svg/search.svg +0 -5
- package/src/assets/svg/search1.svg +0 -4
- package/src/assets/svg/server-error.svg +0 -139
- package/src/components/Account/Account.tsx +0 -367
- package/src/components/Account/index.ts +0 -1
- package/src/components/Alert/AlertDialog.tsx +0 -247
- package/src/components/Alert/UAAlert.tsx +0 -170
- package/src/components/Alert/index.ts +0 -2
- package/src/components/Auth/AuthProvider/AuthProvider.tsx +0 -419
- package/src/components/Auth/One/ForgotPassword/ForgotPassword.tsx +0 -324
- package/src/components/Auth/One/Login/LoginWithEmail.tsx +0 -455
- package/src/components/Auth/One/Login/LoginWithPhone.tsx +0 -306
- package/src/components/Auth/One/OTP/OTP.tsx +0 -465
- package/src/components/Auth/One/QrLogin/QrLogin.tsx +0 -602
- package/src/components/Auth/One/QrLogin/components/QrViewArea.tsx +0 -423
- package/src/components/Auth/One/SignUp/SignUp.tsx +0 -479
- package/src/components/Auth/One/SplashScreen/SplashScreen.tsx +0 -249
- package/src/components/Auth/One/SplashScreen/components/SplashImage/SplashImage.tsx +0 -103
- package/src/components/Auth/One/SplashScreen/components/SplashLottie/SplashLottie.tsx +0 -77
- package/src/components/Auth/One/SplashScreen/components/SplashVideo/SplashVideo.tsx +0 -174
- package/src/components/Auth/One/index.ts +0 -24
- package/src/components/Auth/Two/AuthHeader/AuthHeader.tsx +0 -108
- package/src/components/Auth/Two/ForgotPassword/ForgotPassword.tsx +0 -335
- package/src/components/Auth/Two/Login/AuthLoginShell.tsx +0 -173
- package/src/components/Auth/Two/Login/LoginWithEmail.tsx +0 -279
- package/src/components/Auth/Two/Login/LoginWithPhone.tsx +0 -188
- package/src/components/Auth/Two/OTP/OTP.tsx +0 -465
- package/src/components/Auth/Two/QrLogin/QrLogin.tsx +0 -602
- package/src/components/Auth/Two/QrLogin/components/QrViewArea.tsx +0 -423
- package/src/components/Auth/Two/SignUp/SignUp.tsx +0 -472
- package/src/components/Auth/Two/SplashScreen/SplashScreen.tsx +0 -248
- package/src/components/Auth/Two/SplashScreen/components/SplashImage/SplashImage.tsx +0 -92
- package/src/components/Auth/Two/SplashScreen/components/SplashLottie/SplashLottie.tsx +0 -77
- package/src/components/Auth/Two/SplashScreen/components/SplashVideo/SplashVideo.tsx +0 -178
- package/src/components/Auth/Two/index.ts +0 -28
- package/src/components/Auth/index.ts +0 -11
- package/src/components/BackgroundLayout/BackgroundLayout.tsx +0 -174
- package/src/components/BackgroundLayout/BackgroundLayoutOne.tsx +0 -56
- package/src/components/BlogView/BlogView.tsx +0 -276
- package/src/components/BlogView/index.ts +0 -8
- package/src/components/BlurView/BlurView.tsx +0 -199
- package/src/components/BlurView/index.ts +0 -7
- package/src/components/BottomSheet/BottomSheet.tsx +0 -200
- package/src/components/BottomSheet/BottomSheetOne.tsx +0 -220
- package/src/components/BottomSheet/index.ts +0 -4
- package/src/components/Button/BackBtn.tsx +0 -168
- package/src/components/Button/MenuBtn.tsx +0 -229
- package/src/components/Button/PrimaryBtn.tsx +0 -134
- package/src/components/Button/SecondaryBtn.tsx +0 -132
- package/src/components/Button/TextButton.tsx +0 -145
- package/src/components/Button/index.ts +0 -18
- package/src/components/Content/Card/Category/Category.tsx +0 -436
- package/src/components/Content/Card/Category/CategroyTwo.tsx +0 -429
- package/src/components/Content/Card/NowWatching/NowWatching.tsx +0 -624
- package/src/components/Content/Card/Sliders/Styles/One.tsx +0 -490
- package/src/components/Content/Card/Sliders/Styles/Three.tsx +0 -935
- package/src/components/Content/Card/Sliders/Styles/Two.tsx +0 -391
- package/src/components/Content/Card/Sliders/index.ts +0 -17
- package/src/components/Content/Card/Styles/Five.tsx +0 -385
- package/src/components/Content/Card/Styles/Four.tsx +0 -379
- package/src/components/Content/Card/Styles/One.tsx +0 -386
- package/src/components/Content/Card/Styles/RotateInOut.tsx +0 -413
- package/src/components/Content/Card/Styles/Six.tsx +0 -392
- package/src/components/Content/Card/Styles/Three.tsx +0 -314
- package/src/components/Content/Card/Styles/TopTen.tsx +0 -412
- package/src/components/Content/Card/Styles/Two.tsx +0 -416
- package/src/components/Content/Card/components/AdsPoster.tsx +0 -202
- package/src/components/Content/Card/components/CardPoster.tsx +0 -377
- package/src/components/Content/Card/components/NavigateToMore.tsx +0 -97
- package/src/components/Content/Card/components/RentOrBuyIcon.tsx +0 -129
- package/src/components/Content/Card/components/ShowAllButton.tsx +0 -92
- package/src/components/Content/Card/components/ThumbnailCard.tsx +0 -234
- package/src/components/Content/Card/components/index.ts +0 -1
- package/src/components/Content/Card/index.ts +0 -30
- package/src/components/Content/Content.tsx +0 -315
- package/src/components/Content/Sections.tsx +0 -238
- package/src/components/Content/types.ts +0 -176
- package/src/components/ContentView/MoreContentList.tsx +0 -327
- package/src/components/ContentView/One/ContentViewOne.tsx +0 -243
- package/src/components/ContentView/One/components/AboutSection.tsx +0 -216
- package/src/components/ContentView/One/components/CastCard.tsx +0 -265
- package/src/components/ContentView/One/components/EpisodeCard.tsx +0 -535
- package/src/components/ContentView/One/components/GenreTags.tsx +0 -132
- package/src/components/ContentView/One/components/HeroBanner.tsx +0 -357
- package/src/components/ContentView/One/components/MiniInfo.tsx +0 -356
- package/src/components/ContentView/One/components/PlayButton.tsx +0 -56
- package/src/components/ContentView/One/components/Title.tsx +0 -149
- package/src/components/ContentView/One/components/TrailerButton.tsx +0 -76
- package/src/components/ContentView/Two/ContentViewTwo.tsx +0 -343
- package/src/components/ContentView/Two/components/AboutSection.tsx +0 -216
- package/src/components/ContentView/Two/components/Details.tsx +0 -193
- package/src/components/ContentView/Two/components/EpisodeCard.tsx +0 -602
- package/src/components/ContentView/Two/components/GenreTags.tsx +0 -123
- package/src/components/ContentView/Two/components/HeroBanner.tsx +0 -402
- package/src/components/ContentView/Two/components/LikeShareActions.tsx +0 -125
- package/src/components/ContentView/Two/components/MoreLikeThisContentList .tsx +0 -305
- package/src/components/ContentView/Two/components/PlayOrTrailer.tsx +0 -133
- package/src/components/ContentView/Two/components/SectionTabs.tsx +0 -177
- package/src/components/ContentView/Two/components/Title.tsx +0 -226
- package/src/components/ContentView/Two/components/index.ts +0 -15
- package/src/components/ContentView/index.ts +0 -13
- package/src/components/Fallbacks/NoContentFallback.tsx +0 -176
- package/src/components/Fallbacks/NotFoundFallback.tsx +0 -94
- package/src/components/Fallbacks/index.ts +0 -2
- package/src/components/Headers/AppHeader.tsx +0 -150
- package/src/components/Headers/Four.tsx +0 -83
- package/src/components/Headers/One.tsx +0 -115
- package/src/components/Headers/Three.tsx +0 -135
- package/src/components/Headers/Two.tsx +0 -100
- package/src/components/Headers/index.ts +0 -18
- package/src/components/Input/Input.ts +0 -20
- package/src/components/Input/InputOne.tsx +0 -259
- package/src/components/Input/InputThree.tsx +0 -212
- package/src/components/Input/InputTwo.tsx +0 -212
- package/src/components/Input/PhoneNumberInput.tsx +0 -431
- package/src/components/Input/PhoneNumberInputTwo.tsx +0 -418
- package/src/components/Keyboard/HideKeyboard.tsx +0 -88
- package/src/components/Loader/Loader.tsx +0 -44
- package/src/components/Logo/Logo.tsx +0 -145
- package/src/components/NewRelease/NewReleaseSheet.tsx +0 -250
- package/src/components/NewRelease/index.ts +0 -1
- package/src/components/Reels/ReelsSeries/MediaControls/BottomControls.tsx +0 -221
- package/src/components/Reels/ReelsSeries/MediaControls/MediaControlsProvider.tsx +0 -314
- package/src/components/Reels/ReelsSeries/MediaControls/MiddleControls.tsx +0 -196
- package/src/components/Reels/ReelsSeries/MediaControls/RightControls.tsx +0 -95
- package/src/components/Reels/ReelsSeries/MediaControls/TopControls.tsx +0 -163
- package/src/components/Reels/ReelsSeries/Model/DetailsModal.tsx +0 -210
- package/src/components/Reels/ReelsSeries/Model/SettingModal.tsx +0 -146
- package/src/components/Reels/ReelsSeries/Model/UnlockModal.tsx +0 -154
- package/src/components/Reels/ReelsSeries/ReelsSeries.tsx +0 -264
- package/src/components/Reels/ReelsSeries/ReelsSeriesItem.tsx +0 -494
- package/src/components/Reels/ReelsSeries/components/AnimatedThreeLines.tsx +0 -184
- package/src/components/Reels/ReelsSeries/components/Episodes.tsx +0 -154
- package/src/components/Reels/ReelsSeries/components/GradientOverlay.tsx +0 -41
- package/src/components/Reels/ReelsSeries/components/Like.tsx +0 -40
- package/src/components/Reels/ReelsSeries/components/RotatingLoader.tsx +0 -79
- package/src/components/Reels/ReelsSeries/components/Synopsis.tsx +0 -332
- package/src/components/Reels/ReelsSeries/components/VideoControls/QualityControl.tsx +0 -187
- package/src/components/Reels/ReelsSeries/components/VideoControls/SpeedControl.tsx +0 -80
- package/src/components/Reels/ReelsSeries/components/VideoControls/index.ts +0 -2
- package/src/components/Reels/ReelsSeries/types.ts +0 -54
- package/src/components/Reels/ReelsSeries/useReelsWatchProgress.ts +0 -85
- package/src/components/Reels/ReelsSeries/utils/quality.ts +0 -48
- package/src/components/Reels/index.ts +0 -9
- package/src/components/Reels/utils/Controls/gestureUtils.ts +0 -42
- package/src/components/Reels/utils/Controls/index.ts +0 -4
- package/src/components/Reels/utils/Controls/overlayUtils.ts +0 -35
- package/src/components/Reels/utils/Controls/videoControlsConstants.ts +0 -25
- package/src/components/Reels/utils/Controls/videoRef.ts +0 -4
- package/src/components/Reels/utils/index.ts +0 -1
- package/src/components/Reels/utils/timeoutUtils.ts +0 -29
- package/src/components/Search/One.tsx +0 -256
- package/src/components/Search/components/RecentSearchesSection.tsx +0 -181
- package/src/components/Search/components/SearchCard.tsx +0 -275
- package/src/components/Search/index.ts +0 -16
- package/src/components/Settings/AppSettings.tsx +0 -428
- package/src/components/Settings/index.ts +0 -1
- package/src/components/Subscription/SubOne.tsx +0 -874
- package/src/components/Subscription/index.ts +0 -12
- package/src/components/TabBar/One.tsx +0 -148
- package/src/components/TabBar/Three.tsx +0 -169
- package/src/components/TabBar/Two.tsx +0 -189
- package/src/components/TabBar/index.ts +0 -20
- package/src/components/Text/Text.tsx +0 -85
- package/src/components/Text/index.ts +0 -5
- package/src/components/User/DeviceSessions/DeviceSessions.tsx +0 -468
- package/src/components/User/ProfileUpdate/ProfileUpdate.tsx +0 -278
- package/src/components/User/PurchaseHistory/PurchaseHistory.tsx +0 -494
- package/src/components/User/WatchHistory/WatchHistory.tsx +0 -227
- package/src/components/User/WatchLater/WatchLater.tsx +0 -397
- package/src/components/User/components/UserAvatar.tsx +0 -120
- package/src/components/User/components/UserSection.tsx +0 -228
- package/src/components/User/index.ts +0 -18
- package/src/components/View/View.tsx +0 -37
- package/src/components/View/index.ts +0 -5
- package/src/components/common/AppStatusBar.tsx +0 -57
- package/src/components/index.ts +0 -29
- package/src/components/layout/SafeAreaWrapper.tsx +0 -45
- package/src/components/layout/index.ts +0 -1
- package/src/constants/dummySections.ts +0 -98
- package/src/hooks/Images/index.ts +0 -2
- package/src/hooks/Images/useImageLoader.ts +0 -206
- package/src/hooks/Images/useImageValidation.ts +0 -36
- package/src/hooks/index.ts +0 -17
- package/src/hooks/useAdTracking.ts +0 -349
- package/src/hooks/useCards.ts +0 -228
- package/src/hooks/useDebounce.ts +0 -35
- package/src/hooks/useKeyboard.ts +0 -43
- package/src/hooks/useNavigationMode.ts +0 -46
- package/src/hooks/usePaginatedSection.ts +0 -101
- package/src/hooks/usePrevious.ts +0 -28
- package/src/hooks/useSafeCallback.ts +0 -43
- package/src/hooks/useSkeletonItems.ts +0 -30
- package/src/hooks/useSplashCache.ts +0 -186
- package/src/hooks/useThemeColors.ts +0 -51
- package/src/index.tsx +0 -8
- package/src/store/RecentSearchesStore.ts +0 -78
- package/src/store/splashStore.ts +0 -91
- package/src/store/themeStore.ts +0 -43
- package/src/theme/ThemeProvider.tsx +0 -112
- package/src/theme/hook/index.ts +0 -1
- package/src/theme/hook/useInternalTheme.ts +0 -98
- package/src/theme/index.ts +0 -7
- package/src/theme/themes.ts +0 -336
- package/src/theme/utils/validateColor.ts +0 -127
- package/src/types/content/content-view.types.ts +0 -206
- package/src/types/hook/index.ts +0 -5
- package/src/types/hook/usePaginatedSetion.ts +0 -19
- package/src/types/index.ts +0 -7
- package/src/types/sections/index.ts +0 -84
- package/src/utils/Display.ts +0 -14
- package/src/utils/Formater.ts +0 -14
- package/src/utils/PlatformSelector.ts +0 -29
- package/src/utils/SizeMatters.ts +0 -7
- package/src/utils/Spacing.ts +0 -27
- package/src/utils/colorUtils.ts +0 -70
|
@@ -1,935 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
StatusBar,
|
|
3
|
-
StyleSheet,
|
|
4
|
-
TouchableOpacity,
|
|
5
|
-
View,
|
|
6
|
-
useWindowDimensions,
|
|
7
|
-
type ViewToken,
|
|
8
|
-
type AccessibilityProps,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import React, {
|
|
11
|
-
memo,
|
|
12
|
-
useCallback,
|
|
13
|
-
useEffect,
|
|
14
|
-
useMemo,
|
|
15
|
-
useRef,
|
|
16
|
-
useState,
|
|
17
|
-
} from 'react';
|
|
18
|
-
import LinearGradient from 'react-native-linear-gradient';
|
|
19
|
-
import { moderateScale, verticalScale } from 'react-native-size-matters';
|
|
20
|
-
import Animated, {
|
|
21
|
-
Extrapolation,
|
|
22
|
-
interpolate,
|
|
23
|
-
useAnimatedScrollHandler,
|
|
24
|
-
useAnimatedStyle,
|
|
25
|
-
useSharedValue,
|
|
26
|
-
type SharedValue,
|
|
27
|
-
} from 'react-native-reanimated';
|
|
28
|
-
import FastImage from 'react-native-fast-image';
|
|
29
|
-
import { ActivityIndicator } from 'react-native';
|
|
30
|
-
import { Play, Plus, CheckCircle2, Info } from 'lucide-react-native';
|
|
31
|
-
import { Text } from '../../../../Text';
|
|
32
|
-
import type { IContentData } from '@zezosoft/zezo-ott-api-client';
|
|
33
|
-
import SkeletonPlaceholder from 'react-native-skeleton-placeholder';
|
|
34
|
-
import type { ISectionContent } from '../../../../../types';
|
|
35
|
-
import type { ITheme, ThemeOverride } from '../../../../../theme/themes';
|
|
36
|
-
import { useInternalTheme } from '../../../../../theme/hook/useInternalTheme';
|
|
37
|
-
|
|
38
|
-
type SkeletonItem = {
|
|
39
|
-
_id: string;
|
|
40
|
-
isSkeleton: true;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const SkeletonGradient = memo<{ theme: ITheme }>(({ theme }) => {
|
|
44
|
-
const gradients = [
|
|
45
|
-
{
|
|
46
|
-
colors: [theme.colors.background, 'rgba(0,0,0,0)'],
|
|
47
|
-
style: {
|
|
48
|
-
top: 0,
|
|
49
|
-
height: verticalScale(SLIDER_HEIGHT) / GRADIENT_DIVIDER_BOTTOM,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
colors: ['rgba(0,0,0,0)', theme.colors.background],
|
|
54
|
-
style: { bottom: 0 },
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<>
|
|
60
|
-
{gradients.map((g, i) => (
|
|
61
|
-
<LinearGradient
|
|
62
|
-
key={i}
|
|
63
|
-
colors={g.colors}
|
|
64
|
-
pointerEvents="none"
|
|
65
|
-
style={[StyleSheet.absoluteFillObject, g.style]}
|
|
66
|
-
/>
|
|
67
|
-
))}
|
|
68
|
-
</>
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
SkeletonGradient.displayName = 'SkeletonGradient';
|
|
73
|
-
|
|
74
|
-
const S = SkeletonPlaceholder.Item;
|
|
75
|
-
|
|
76
|
-
const ContentInfoSkeleton = memo<{ theme: ITheme }>(({ theme }) => {
|
|
77
|
-
const circle = moderateScale(44);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<View
|
|
81
|
-
style={[
|
|
82
|
-
styles.contentInfoContainer,
|
|
83
|
-
{ backgroundColor: theme.colors.background },
|
|
84
|
-
]}
|
|
85
|
-
>
|
|
86
|
-
<SkeletonPlaceholder
|
|
87
|
-
backgroundColor={theme.colors.skeletonBaseColor}
|
|
88
|
-
highlightColor={theme.colors.skeletonHighlightColor}
|
|
89
|
-
>
|
|
90
|
-
<S
|
|
91
|
-
width={moderateScale(140)}
|
|
92
|
-
height={moderateScale(10)}
|
|
93
|
-
borderRadius={6}
|
|
94
|
-
alignSelf="center"
|
|
95
|
-
marginBottom={verticalScale(18)}
|
|
96
|
-
/>
|
|
97
|
-
<S
|
|
98
|
-
height={verticalScale(60)}
|
|
99
|
-
justifyContent="center"
|
|
100
|
-
alignItems="center"
|
|
101
|
-
>
|
|
102
|
-
<S
|
|
103
|
-
width={circle}
|
|
104
|
-
height={circle}
|
|
105
|
-
borderRadius={circle / 2}
|
|
106
|
-
position="absolute"
|
|
107
|
-
left={moderateScale(16)}
|
|
108
|
-
/>
|
|
109
|
-
<S
|
|
110
|
-
width={moderateScale(140)}
|
|
111
|
-
height={verticalScale(48)}
|
|
112
|
-
borderRadius={6}
|
|
113
|
-
/>
|
|
114
|
-
<S
|
|
115
|
-
width={circle}
|
|
116
|
-
height={circle}
|
|
117
|
-
borderRadius={circle / 2}
|
|
118
|
-
position="absolute"
|
|
119
|
-
right={moderateScale(16)}
|
|
120
|
-
/>
|
|
121
|
-
</S>
|
|
122
|
-
</SkeletonPlaceholder>
|
|
123
|
-
</View>
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
ContentInfoSkeleton.displayName = 'ContentInfoSkeleton';
|
|
128
|
-
|
|
129
|
-
const SLIDER_HEIGHT = 370;
|
|
130
|
-
const TITLE_IMAGE_HEIGHT = 55;
|
|
131
|
-
const TITLE_IMAGE_WIDTH_PERCENT = '80%';
|
|
132
|
-
// const SKELETON_COUNT = 1;
|
|
133
|
-
const AUTO_PLAY_INTERVAL = 5000;
|
|
134
|
-
const LOOP_MULTIPLIER = 3;
|
|
135
|
-
const VIEWABILITY_THRESHOLD = 50;
|
|
136
|
-
const GRADIENT_DIVIDER_BOTTOM = 2;
|
|
137
|
-
const GRADIENT_DIVIDER_TOP = 1.1;
|
|
138
|
-
|
|
139
|
-
type SliderThreeProps = {
|
|
140
|
-
index?: number;
|
|
141
|
-
data: ISectionContent | null;
|
|
142
|
-
onPressItem?: (item: IContentData) => void;
|
|
143
|
-
isLoading?: boolean;
|
|
144
|
-
theme?: ThemeOverride;
|
|
145
|
-
onToggleWatchlist?: (
|
|
146
|
-
item: IContentData,
|
|
147
|
-
{ isFavorite }: { isFavorite: boolean }
|
|
148
|
-
) => void;
|
|
149
|
-
checkWatchlistStatus?: (
|
|
150
|
-
itemIds: string[]
|
|
151
|
-
) => Record<string, boolean> | Promise<Record<string, boolean>>;
|
|
152
|
-
} & AccessibilityProps;
|
|
153
|
-
|
|
154
|
-
type BackImageProps = {
|
|
155
|
-
item: IContentData;
|
|
156
|
-
index: number;
|
|
157
|
-
x: SharedValue<number>;
|
|
158
|
-
theme: ITheme;
|
|
159
|
-
sliderDataLength: number;
|
|
160
|
-
width: number;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
type GradientProps = {
|
|
164
|
-
theme: ITheme;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
type RenderItemProps = {
|
|
168
|
-
item: IContentData | SkeletonItem;
|
|
169
|
-
index: number;
|
|
170
|
-
x: SharedValue<number>;
|
|
171
|
-
theme: ITheme;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
type ContentInfoProps = {
|
|
175
|
-
theme: ITheme;
|
|
176
|
-
item: IContentData;
|
|
177
|
-
onPressItem?: (item: IContentData) => void;
|
|
178
|
-
isFavorite?: boolean;
|
|
179
|
-
onToggleWatchlist?: (
|
|
180
|
-
item: IContentData,
|
|
181
|
-
{ isFavorite }: { isFavorite: boolean }
|
|
182
|
-
) => void;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const SliderThree: React.FC<SliderThreeProps> = ({
|
|
186
|
-
index = 0,
|
|
187
|
-
data,
|
|
188
|
-
onPressItem,
|
|
189
|
-
isLoading = false,
|
|
190
|
-
theme,
|
|
191
|
-
onToggleWatchlist,
|
|
192
|
-
checkWatchlistStatus,
|
|
193
|
-
accessibilityLabel = 'Netflix style slider',
|
|
194
|
-
accessibilityHint = 'Swipe to view content',
|
|
195
|
-
}) => {
|
|
196
|
-
const { width } = useWindowDimensions();
|
|
197
|
-
const { theme: appliedTheme } = useInternalTheme(theme);
|
|
198
|
-
const scrollX = useSharedValue(0);
|
|
199
|
-
const flatListRef =
|
|
200
|
-
useRef<Animated.FlatList<IContentData | SkeletonItem>>(null);
|
|
201
|
-
|
|
202
|
-
const autoPlayIntervalRef = useRef<NodeJS.Timeout | null>(null);
|
|
203
|
-
const currentIndexRef = useRef(0);
|
|
204
|
-
const isDraggingRef = useRef(false);
|
|
205
|
-
const watchlistCache = useRef<Map<string, boolean>>(new Map());
|
|
206
|
-
const isCheckingRef = useRef<boolean>(false);
|
|
207
|
-
const [isInWatchlist, setIsInWatchlist] = useState<boolean>(false);
|
|
208
|
-
const skeletonItems = useMemo<SkeletonItem[]>(
|
|
209
|
-
() =>
|
|
210
|
-
Array.from({ length: 3 }).map((_, i) => ({
|
|
211
|
-
_id: `skeleton-${i}`,
|
|
212
|
-
isSkeleton: true,
|
|
213
|
-
})),
|
|
214
|
-
[]
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
const sliderData = useMemo<(IContentData | SkeletonItem)[]>(() => {
|
|
218
|
-
if (isLoading) return skeletonItems;
|
|
219
|
-
|
|
220
|
-
return (data?.data ?? []).filter(
|
|
221
|
-
(item): item is IContentData => !('type' in item && item.type === 'ads')
|
|
222
|
-
);
|
|
223
|
-
}, [data, isLoading, skeletonItems]);
|
|
224
|
-
|
|
225
|
-
const [currentIndex, setCurrentIndex] = useState(0);
|
|
226
|
-
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
if (
|
|
229
|
-
!checkWatchlistStatus ||
|
|
230
|
-
sliderData.length === 0 ||
|
|
231
|
-
isCheckingRef.current
|
|
232
|
-
) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const itemIds = sliderData
|
|
237
|
-
.filter((item): item is IContentData => item !== null && !!item._id)
|
|
238
|
-
.map((item) => item._id);
|
|
239
|
-
|
|
240
|
-
if (itemIds.length === 0) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const uncachedIds = itemIds.filter((id) => !watchlistCache.current.has(id));
|
|
245
|
-
|
|
246
|
-
if (uncachedIds.length === 0) {
|
|
247
|
-
if (sliderData[currentIndex]?._id) {
|
|
248
|
-
setIsInWatchlist(
|
|
249
|
-
watchlistCache.current.get(sliderData[currentIndex]._id) ?? false
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
isCheckingRef.current = true;
|
|
256
|
-
(async () => {
|
|
257
|
-
try {
|
|
258
|
-
const result = checkWatchlistStatus(uncachedIds);
|
|
259
|
-
const statusResult = result instanceof Promise ? await result : result;
|
|
260
|
-
Object.entries(statusResult)?.forEach?.(([itemId, status]) => {
|
|
261
|
-
watchlistCache.current.set(itemId, status);
|
|
262
|
-
});
|
|
263
|
-
if (sliderData[currentIndex]?._id) {
|
|
264
|
-
setIsInWatchlist(
|
|
265
|
-
watchlistCache.current.get(sliderData[currentIndex]._id) ?? false
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
} catch (error) {
|
|
269
|
-
console.error('Error checking watchlist status:', error);
|
|
270
|
-
uncachedIds?.forEach?.((id) => watchlistCache.current.set(id, false));
|
|
271
|
-
if (sliderData[currentIndex]?._id) {
|
|
272
|
-
setIsInWatchlist(false);
|
|
273
|
-
}
|
|
274
|
-
} finally {
|
|
275
|
-
isCheckingRef.current = false;
|
|
276
|
-
}
|
|
277
|
-
})();
|
|
278
|
-
}, [sliderData, checkWatchlistStatus, currentIndex]);
|
|
279
|
-
|
|
280
|
-
const infiniteData = useMemo(() => {
|
|
281
|
-
if (!sliderData.length) return [];
|
|
282
|
-
|
|
283
|
-
if (isLoading) return sliderData;
|
|
284
|
-
|
|
285
|
-
return Array.from({ length: LOOP_MULTIPLIER }).flatMap(() => sliderData);
|
|
286
|
-
}, [sliderData, isLoading]);
|
|
287
|
-
|
|
288
|
-
const initialScrollIndex = useMemo(
|
|
289
|
-
() => (isLoading ? 0 : sliderData.length),
|
|
290
|
-
[isLoading, sliderData.length]
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
const [autoPlay, setAutoPlay] = useState(true);
|
|
294
|
-
|
|
295
|
-
const normalizeIndex = useCallback(
|
|
296
|
-
(idx: number) => (sliderData.length ? idx % sliderData.length : 0),
|
|
297
|
-
[sliderData.length]
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
const resetToMiddleSection = useCallback(() => {
|
|
301
|
-
const totalItems = sliderData.length;
|
|
302
|
-
const rawIndex = currentIndexRef.current;
|
|
303
|
-
const maxIndex = infiniteData.length - 1;
|
|
304
|
-
|
|
305
|
-
if (rawIndex < totalItems || rawIndex >= totalItems * 2) {
|
|
306
|
-
const middleIndex = totalItems + normalizeIndex(rawIndex);
|
|
307
|
-
if (middleIndex >= 0 && middleIndex <= maxIndex && flatListRef.current) {
|
|
308
|
-
flatListRef.current.scrollToIndex({
|
|
309
|
-
index: middleIndex,
|
|
310
|
-
animated: false,
|
|
311
|
-
});
|
|
312
|
-
currentIndexRef.current = middleIndex;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}, [sliderData.length, normalizeIndex, infiniteData.length]);
|
|
316
|
-
|
|
317
|
-
const onViewableItemsChangedRef = useRef<
|
|
318
|
-
({ viewableItems }: { viewableItems: ViewToken[] }) => void
|
|
319
|
-
>(() => {});
|
|
320
|
-
|
|
321
|
-
const onViewableItemsChanged = useCallback(
|
|
322
|
-
({ viewableItems }: { viewableItems: ViewToken[] }) => {
|
|
323
|
-
if (!viewableItems.length) return;
|
|
324
|
-
|
|
325
|
-
const rawIndex = viewableItems[0]?.index ?? 0;
|
|
326
|
-
currentIndexRef.current = rawIndex;
|
|
327
|
-
setCurrentIndex(normalizeIndex(rawIndex));
|
|
328
|
-
},
|
|
329
|
-
[normalizeIndex]
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
useEffect(() => {
|
|
333
|
-
onViewableItemsChangedRef.current = onViewableItemsChanged;
|
|
334
|
-
}, [onViewableItemsChanged]);
|
|
335
|
-
|
|
336
|
-
const stableOnViewableItemsChanged = useCallback(
|
|
337
|
-
({ viewableItems }: { viewableItems: ViewToken[] }) => {
|
|
338
|
-
onViewableItemsChangedRef.current?.({ viewableItems });
|
|
339
|
-
},
|
|
340
|
-
[]
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
const viewabilityConfigCallbackPairs = useRef([
|
|
344
|
-
{
|
|
345
|
-
viewabilityConfig: {
|
|
346
|
-
itemVisiblePercentThreshold: VIEWABILITY_THRESHOLD,
|
|
347
|
-
waitForInteraction: false,
|
|
348
|
-
},
|
|
349
|
-
onViewableItemsChanged: stableOnViewableItemsChanged,
|
|
350
|
-
},
|
|
351
|
-
]);
|
|
352
|
-
|
|
353
|
-
const onScroll = useAnimatedScrollHandler({
|
|
354
|
-
onScroll: (event) => {
|
|
355
|
-
scrollX.value = event.contentOffset.x;
|
|
356
|
-
},
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
const handleScrollBeginDrag = useCallback(() => {
|
|
360
|
-
setAutoPlay(false);
|
|
361
|
-
isDraggingRef.current = true;
|
|
362
|
-
}, []);
|
|
363
|
-
|
|
364
|
-
const handleMomentumScrollEnd = useCallback(() => {
|
|
365
|
-
isDraggingRef.current = false;
|
|
366
|
-
resetToMiddleSection();
|
|
367
|
-
setAutoPlay(true);
|
|
368
|
-
}, [resetToMiddleSection]);
|
|
369
|
-
const handleToggleWatchlist = useCallback(
|
|
370
|
-
async (item: IContentData, { isFavorite }: { isFavorite: boolean }) => {
|
|
371
|
-
if (!item._id) return;
|
|
372
|
-
|
|
373
|
-
const newStatus = !isFavorite;
|
|
374
|
-
setIsInWatchlist(newStatus);
|
|
375
|
-
watchlistCache.current.set(item._id, newStatus);
|
|
376
|
-
|
|
377
|
-
try {
|
|
378
|
-
if (onToggleWatchlist) {
|
|
379
|
-
await onToggleWatchlist(item, { isFavorite });
|
|
380
|
-
}
|
|
381
|
-
} catch (error) {
|
|
382
|
-
console.error('Error toggling watchlist:', error);
|
|
383
|
-
const revertedStatus = isFavorite;
|
|
384
|
-
setIsInWatchlist(revertedStatus);
|
|
385
|
-
watchlistCache.current.set(item._id, revertedStatus);
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
[onToggleWatchlist]
|
|
389
|
-
);
|
|
390
|
-
|
|
391
|
-
// Initial sync (scrollX, currentIndexRef) + debounced currentIndex; single effect to limit useEffect count
|
|
392
|
-
useEffect(() => {
|
|
393
|
-
if (sliderData.length > 0) {
|
|
394
|
-
currentIndexRef.current = initialScrollIndex;
|
|
395
|
-
if (!isLoading && width > 0) scrollX.value = initialScrollIndex * width;
|
|
396
|
-
}
|
|
397
|
-
if (!sliderData.length) return;
|
|
398
|
-
const t = setTimeout(
|
|
399
|
-
() => setCurrentIndex(normalizeIndex(currentIndexRef.current)),
|
|
400
|
-
150
|
|
401
|
-
);
|
|
402
|
-
return () => clearTimeout(t);
|
|
403
|
-
}, [
|
|
404
|
-
sliderData.length,
|
|
405
|
-
initialScrollIndex,
|
|
406
|
-
isLoading,
|
|
407
|
-
width,
|
|
408
|
-
normalizeIndex,
|
|
409
|
-
scrollX,
|
|
410
|
-
]);
|
|
411
|
-
|
|
412
|
-
useEffect(() => {
|
|
413
|
-
onViewableItemsChangedRef.current = onViewableItemsChanged;
|
|
414
|
-
}, [onViewableItemsChanged]);
|
|
415
|
-
|
|
416
|
-
// Auto-play interval + deferred image preload (single effect to limit useEffect count)
|
|
417
|
-
useEffect(() => {
|
|
418
|
-
if (isLoading || sliderData.length === 0) return;
|
|
419
|
-
|
|
420
|
-
const preloadId = setTimeout(() => {
|
|
421
|
-
const uris: string[] = [];
|
|
422
|
-
const indices = [
|
|
423
|
-
currentIndex,
|
|
424
|
-
(currentIndex - 1 + sliderData.length) % sliderData.length,
|
|
425
|
-
(currentIndex + 1) % sliderData.length,
|
|
426
|
-
];
|
|
427
|
-
for (const i of indices) {
|
|
428
|
-
const slideItem = sliderData[i];
|
|
429
|
-
if (slideItem && !('isSkeleton' in slideItem)) {
|
|
430
|
-
const poster = slideItem.poster?.trim?.();
|
|
431
|
-
if (poster?.length) uris.push(poster);
|
|
432
|
-
const title = slideItem.title_image?.trim?.();
|
|
433
|
-
if (title?.length) uris.push(title);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (uris.length > 0) FastImage.preload(uris.map((uri) => ({ uri })));
|
|
437
|
-
}, 0);
|
|
438
|
-
|
|
439
|
-
if (!autoPlay || sliderData.length <= 1) {
|
|
440
|
-
return () => clearTimeout(preloadId);
|
|
441
|
-
}
|
|
442
|
-
autoPlayIntervalRef.current = setInterval(() => {
|
|
443
|
-
if (!isDraggingRef.current && flatListRef.current) {
|
|
444
|
-
const nextIndex = currentIndexRef.current + 1;
|
|
445
|
-
const maxIndex = infiniteData.length - 1;
|
|
446
|
-
if (nextIndex >= 0 && nextIndex <= maxIndex) {
|
|
447
|
-
flatListRef.current.scrollToIndex({
|
|
448
|
-
index: nextIndex,
|
|
449
|
-
animated: true,
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}, AUTO_PLAY_INTERVAL);
|
|
454
|
-
return () => {
|
|
455
|
-
clearTimeout(preloadId);
|
|
456
|
-
if (autoPlayIntervalRef.current) {
|
|
457
|
-
clearInterval(autoPlayIntervalRef.current);
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
}, [
|
|
461
|
-
autoPlay,
|
|
462
|
-
sliderData.length,
|
|
463
|
-
infiniteData.length,
|
|
464
|
-
currentIndex,
|
|
465
|
-
sliderData,
|
|
466
|
-
isLoading,
|
|
467
|
-
]);
|
|
468
|
-
|
|
469
|
-
const renderItem = useCallback(
|
|
470
|
-
({
|
|
471
|
-
item: listItem,
|
|
472
|
-
index: itemIndex,
|
|
473
|
-
}: {
|
|
474
|
-
item: IContentData | SkeletonItem;
|
|
475
|
-
index: number;
|
|
476
|
-
}) => (
|
|
477
|
-
<RenderItem
|
|
478
|
-
item={listItem}
|
|
479
|
-
index={itemIndex}
|
|
480
|
-
x={scrollX}
|
|
481
|
-
theme={appliedTheme}
|
|
482
|
-
/>
|
|
483
|
-
),
|
|
484
|
-
[scrollX, appliedTheme]
|
|
485
|
-
);
|
|
486
|
-
|
|
487
|
-
const keyExtractor = useCallback(
|
|
488
|
-
(listItem: IContentData | SkeletonItem, i: number) =>
|
|
489
|
-
`item-${listItem._id ?? i}-${i}`,
|
|
490
|
-
[]
|
|
491
|
-
);
|
|
492
|
-
|
|
493
|
-
const getItemLayout = useCallback(
|
|
494
|
-
(
|
|
495
|
-
_: ArrayLike<IContentData | SkeletonItem> | null | undefined,
|
|
496
|
-
i: number
|
|
497
|
-
) => ({
|
|
498
|
-
length: width,
|
|
499
|
-
offset: width * i,
|
|
500
|
-
index: i,
|
|
501
|
-
}),
|
|
502
|
-
[width]
|
|
503
|
-
);
|
|
504
|
-
|
|
505
|
-
const backImageList = useMemo(() => {
|
|
506
|
-
if (isLoading) return null;
|
|
507
|
-
return sliderData.map((item, i) => (
|
|
508
|
-
<BackImage
|
|
509
|
-
key={`bg-${i}-${index}`}
|
|
510
|
-
item={item as IContentData}
|
|
511
|
-
index={i}
|
|
512
|
-
x={scrollX}
|
|
513
|
-
theme={appliedTheme}
|
|
514
|
-
sliderDataLength={sliderData.length}
|
|
515
|
-
width={width}
|
|
516
|
-
/>
|
|
517
|
-
));
|
|
518
|
-
}, [isLoading, sliderData, index, scrollX, appliedTheme, width]);
|
|
519
|
-
|
|
520
|
-
if (!data) {
|
|
521
|
-
return null;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
return (
|
|
525
|
-
<View
|
|
526
|
-
style={styles.container}
|
|
527
|
-
accessibilityLabel={accessibilityLabel}
|
|
528
|
-
accessibilityHint={accessibilityHint}
|
|
529
|
-
>
|
|
530
|
-
<StatusBar translucent backgroundColor="transparent" />
|
|
531
|
-
|
|
532
|
-
{backImageList}
|
|
533
|
-
|
|
534
|
-
<Gradient theme={appliedTheme} />
|
|
535
|
-
|
|
536
|
-
<Animated.FlatList
|
|
537
|
-
ref={flatListRef}
|
|
538
|
-
data={infiniteData}
|
|
539
|
-
horizontal
|
|
540
|
-
pagingEnabled
|
|
541
|
-
bounces={false}
|
|
542
|
-
showsHorizontalScrollIndicator={false}
|
|
543
|
-
initialScrollIndex={initialScrollIndex}
|
|
544
|
-
getItemLayout={getItemLayout}
|
|
545
|
-
onScroll={onScroll}
|
|
546
|
-
scrollEventThrottle={16}
|
|
547
|
-
viewabilityConfigCallbackPairs={viewabilityConfigCallbackPairs.current}
|
|
548
|
-
onScrollBeginDrag={handleScrollBeginDrag}
|
|
549
|
-
onMomentumScrollEnd={handleMomentumScrollEnd}
|
|
550
|
-
renderItem={renderItem}
|
|
551
|
-
keyExtractor={keyExtractor}
|
|
552
|
-
removeClippedSubviews={true}
|
|
553
|
-
maxToRenderPerBatch={5}
|
|
554
|
-
windowSize={5}
|
|
555
|
-
initialNumToRender={3}
|
|
556
|
-
updateCellsBatchingPeriod={100}
|
|
557
|
-
/>
|
|
558
|
-
|
|
559
|
-
{isLoading ? (
|
|
560
|
-
<ContentInfoSkeleton theme={appliedTheme} />
|
|
561
|
-
) : (
|
|
562
|
-
sliderData[currentIndex] &&
|
|
563
|
-
!('isSkeleton' in sliderData[currentIndex]) && (
|
|
564
|
-
<ContentInfo
|
|
565
|
-
theme={appliedTheme}
|
|
566
|
-
item={sliderData[currentIndex]}
|
|
567
|
-
onPressItem={onPressItem}
|
|
568
|
-
isFavorite={isInWatchlist}
|
|
569
|
-
onToggleWatchlist={handleToggleWatchlist}
|
|
570
|
-
/>
|
|
571
|
-
)
|
|
572
|
-
)}
|
|
573
|
-
</View>
|
|
574
|
-
);
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
export default memo(SliderThree);
|
|
578
|
-
|
|
579
|
-
const BackImage = memo<BackImageProps>(
|
|
580
|
-
({ item, index, x, theme, sliderDataLength, width }) => {
|
|
581
|
-
const [loadError, setLoadError] = useState(false);
|
|
582
|
-
const posterUri = item.poster?.trim?.() ?? '';
|
|
583
|
-
const hasValidUri = posterUri.length > 0;
|
|
584
|
-
const prevPosterUriRef = useRef(posterUri);
|
|
585
|
-
|
|
586
|
-
const handleLoad = useCallback(() => setLoadError(false), []);
|
|
587
|
-
const handleError = useCallback(() => setLoadError(true), []);
|
|
588
|
-
|
|
589
|
-
// Reset error when URI changes; retry once after load error (transient failures)
|
|
590
|
-
useEffect(() => {
|
|
591
|
-
if (prevPosterUriRef.current !== posterUri) {
|
|
592
|
-
prevPosterUriRef.current = posterUri;
|
|
593
|
-
setLoadError(false);
|
|
594
|
-
}
|
|
595
|
-
if (!loadError || !hasValidUri) return;
|
|
596
|
-
const id = setTimeout(() => setLoadError(false), 1000);
|
|
597
|
-
return () => clearTimeout(id);
|
|
598
|
-
}, [posterUri, loadError, hasValidUri]);
|
|
599
|
-
|
|
600
|
-
const animatedStyle = useAnimatedStyle(() => {
|
|
601
|
-
'worklet';
|
|
602
|
-
const totalWidth = sliderDataLength * width;
|
|
603
|
-
if (totalWidth <= 0 || width <= 0) {
|
|
604
|
-
return { opacity: index === 0 ? 1 : 0 };
|
|
605
|
-
}
|
|
606
|
-
const scrollInWidth = ((x.value % totalWidth) + totalWidth) % totalWidth;
|
|
607
|
-
const normalizedScroll = scrollInWidth / width - 1;
|
|
608
|
-
const distance = Math.abs(normalizedScroll - index);
|
|
609
|
-
if (distance < 0.01) return { opacity: 1 };
|
|
610
|
-
const raw = distance <= 1 ? 1 - distance : 0;
|
|
611
|
-
const opacity = Math.min(1, Math.max(0, raw));
|
|
612
|
-
return { opacity };
|
|
613
|
-
});
|
|
614
|
-
|
|
615
|
-
return (
|
|
616
|
-
<Animated.View
|
|
617
|
-
style={[
|
|
618
|
-
StyleSheet.absoluteFillObject,
|
|
619
|
-
{
|
|
620
|
-
width,
|
|
621
|
-
height: verticalScale(SLIDER_HEIGHT),
|
|
622
|
-
},
|
|
623
|
-
animatedStyle,
|
|
624
|
-
]}
|
|
625
|
-
>
|
|
626
|
-
{hasValidUri && !loadError && (
|
|
627
|
-
<FastImage
|
|
628
|
-
key={`poster-${item._id}-${posterUri}`}
|
|
629
|
-
source={{
|
|
630
|
-
uri: posterUri,
|
|
631
|
-
priority: FastImage.priority.normal,
|
|
632
|
-
cache: FastImage.cacheControl.immutable,
|
|
633
|
-
}}
|
|
634
|
-
style={[
|
|
635
|
-
StyleSheet.absoluteFillObject,
|
|
636
|
-
{
|
|
637
|
-
width,
|
|
638
|
-
height: verticalScale(SLIDER_HEIGHT),
|
|
639
|
-
backgroundColor: theme.colors.black,
|
|
640
|
-
},
|
|
641
|
-
]}
|
|
642
|
-
resizeMode={FastImage.resizeMode.cover}
|
|
643
|
-
onLoad={handleLoad}
|
|
644
|
-
onError={handleError}
|
|
645
|
-
/>
|
|
646
|
-
)}
|
|
647
|
-
{(!hasValidUri || loadError) && (
|
|
648
|
-
<View
|
|
649
|
-
style={[
|
|
650
|
-
StyleSheet.absoluteFillObject,
|
|
651
|
-
{
|
|
652
|
-
width,
|
|
653
|
-
height: verticalScale(SLIDER_HEIGHT),
|
|
654
|
-
backgroundColor: theme.colors.black,
|
|
655
|
-
},
|
|
656
|
-
]}
|
|
657
|
-
/>
|
|
658
|
-
)}
|
|
659
|
-
</Animated.View>
|
|
660
|
-
);
|
|
661
|
-
}
|
|
662
|
-
);
|
|
663
|
-
|
|
664
|
-
BackImage.displayName = 'BackImage';
|
|
665
|
-
|
|
666
|
-
const Gradient = memo<GradientProps>(({ theme }) => {
|
|
667
|
-
const { width } = useWindowDimensions();
|
|
668
|
-
|
|
669
|
-
return (
|
|
670
|
-
<View
|
|
671
|
-
pointerEvents="none"
|
|
672
|
-
style={[
|
|
673
|
-
styles.gradientContainer,
|
|
674
|
-
{ width, height: verticalScale(SLIDER_HEIGHT) },
|
|
675
|
-
]}
|
|
676
|
-
>
|
|
677
|
-
<LinearGradient
|
|
678
|
-
colors={[theme.colors.background, 'rgba(0,0,0,0)']}
|
|
679
|
-
style={styles.gradientBottom}
|
|
680
|
-
pointerEvents="none"
|
|
681
|
-
/>
|
|
682
|
-
<LinearGradient
|
|
683
|
-
colors={['rgba(0,0,0,0)', theme.colors.background]}
|
|
684
|
-
style={styles.gradientTop}
|
|
685
|
-
pointerEvents="none"
|
|
686
|
-
/>
|
|
687
|
-
</View>
|
|
688
|
-
);
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
Gradient.displayName = 'Gradient';
|
|
692
|
-
|
|
693
|
-
const RenderItem = memo<RenderItemProps>(({ item, index, x, theme }) => {
|
|
694
|
-
const { width } = useWindowDimensions();
|
|
695
|
-
const titleUri =
|
|
696
|
-
'isSkeleton' in item ? '' : (item.title_image?.trim?.() ?? '');
|
|
697
|
-
const hasTitleUri = titleUri.length > 0;
|
|
698
|
-
const [titleLoadError, setTitleLoadError] = useState(false);
|
|
699
|
-
|
|
700
|
-
useEffect(() => {
|
|
701
|
-
setTitleLoadError(false);
|
|
702
|
-
}, [titleUri]);
|
|
703
|
-
|
|
704
|
-
const handleTitleLoad = useCallback(() => setTitleLoadError(false), []);
|
|
705
|
-
const handleTitleError = useCallback(() => setTitleLoadError(true), []);
|
|
706
|
-
|
|
707
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
708
|
-
opacity: interpolate(
|
|
709
|
-
x.value,
|
|
710
|
-
[(index - 1) * width, index * width, (index + 1) * width],
|
|
711
|
-
[-0.5, 1, -0.5],
|
|
712
|
-
Extrapolation.CLAMP
|
|
713
|
-
),
|
|
714
|
-
}));
|
|
715
|
-
|
|
716
|
-
if ('isSkeleton' in item) {
|
|
717
|
-
return (
|
|
718
|
-
<View
|
|
719
|
-
style={{
|
|
720
|
-
width,
|
|
721
|
-
height: verticalScale(SLIDER_HEIGHT),
|
|
722
|
-
position: 'relative',
|
|
723
|
-
overflow: 'hidden',
|
|
724
|
-
}}
|
|
725
|
-
>
|
|
726
|
-
<SkeletonPlaceholder
|
|
727
|
-
backgroundColor={theme.colors.skeletonBaseColor}
|
|
728
|
-
highlightColor={theme.colors.skeletonHighlightColor}
|
|
729
|
-
>
|
|
730
|
-
<SkeletonPlaceholder.Item
|
|
731
|
-
width={width}
|
|
732
|
-
height={verticalScale(SLIDER_HEIGHT)}
|
|
733
|
-
/>
|
|
734
|
-
</SkeletonPlaceholder>
|
|
735
|
-
|
|
736
|
-
<SkeletonGradient theme={theme} />
|
|
737
|
-
</View>
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
return (
|
|
742
|
-
<View style={{ width, height: verticalScale(SLIDER_HEIGHT) }}>
|
|
743
|
-
{hasTitleUri && !titleLoadError && (
|
|
744
|
-
<Animated.View style={[styles.titleImage, animatedStyle]}>
|
|
745
|
-
<FastImage
|
|
746
|
-
key={`title-${item._id}-${titleUri}`}
|
|
747
|
-
source={{
|
|
748
|
-
uri: titleUri,
|
|
749
|
-
priority: FastImage.priority.normal,
|
|
750
|
-
cache: FastImage.cacheControl.immutable,
|
|
751
|
-
}}
|
|
752
|
-
style={{ width: '100%', height: '100%' }}
|
|
753
|
-
resizeMode={FastImage.resizeMode.contain}
|
|
754
|
-
onLoad={handleTitleLoad}
|
|
755
|
-
onError={handleTitleError}
|
|
756
|
-
/>
|
|
757
|
-
</Animated.View>
|
|
758
|
-
)}
|
|
759
|
-
</View>
|
|
760
|
-
);
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
RenderItem.displayName = 'RenderItem';
|
|
764
|
-
|
|
765
|
-
const ContentInfo = memo<ContentInfoProps>(
|
|
766
|
-
({ theme, item, onPressItem, isFavorite = false, onToggleWatchlist }) => {
|
|
767
|
-
const [isWatchlistLoading, setIsWatchlistLoading] =
|
|
768
|
-
useState<boolean>(false);
|
|
769
|
-
const handleWatchlistPress = useCallback(async () => {
|
|
770
|
-
if (!item._id) return;
|
|
771
|
-
|
|
772
|
-
setIsWatchlistLoading(true);
|
|
773
|
-
|
|
774
|
-
try {
|
|
775
|
-
await onToggleWatchlist?.(item, { isFavorite });
|
|
776
|
-
} catch (error) {
|
|
777
|
-
console.error('Error toggling watchlist:', error);
|
|
778
|
-
} finally {
|
|
779
|
-
setIsWatchlistLoading(false);
|
|
780
|
-
}
|
|
781
|
-
}, [item, isFavorite, onToggleWatchlist]);
|
|
782
|
-
const handlePlayPress = useCallback(() => {
|
|
783
|
-
onPressItem?.(item);
|
|
784
|
-
}, [item, onPressItem]);
|
|
785
|
-
|
|
786
|
-
const handleInfoPress = useCallback(() => {
|
|
787
|
-
onPressItem?.(item);
|
|
788
|
-
}, [item, onPressItem]);
|
|
789
|
-
|
|
790
|
-
const genresText = useMemo(
|
|
791
|
-
() => item.genres?.map((g) => g.name).join(' • ') ?? '',
|
|
792
|
-
[item.genres]
|
|
793
|
-
);
|
|
794
|
-
|
|
795
|
-
return (
|
|
796
|
-
<View
|
|
797
|
-
style={[
|
|
798
|
-
styles.contentInfoContainer,
|
|
799
|
-
{ backgroundColor: theme.colors.background },
|
|
800
|
-
]}
|
|
801
|
-
>
|
|
802
|
-
{genresText ? (
|
|
803
|
-
<Text style={[styles.genreText, { color: theme.colors.white }]}>
|
|
804
|
-
{genresText}
|
|
805
|
-
</Text>
|
|
806
|
-
) : null}
|
|
807
|
-
|
|
808
|
-
<View style={styles.btnContainer}>
|
|
809
|
-
<TouchableOpacity
|
|
810
|
-
style={styles.mylistBtn}
|
|
811
|
-
onPress={handleWatchlistPress}
|
|
812
|
-
accessibilityRole="button"
|
|
813
|
-
accessibilityLabel={
|
|
814
|
-
isFavorite ? 'Remove from My List' : 'Add to My List'
|
|
815
|
-
}
|
|
816
|
-
>
|
|
817
|
-
{isWatchlistLoading ? (
|
|
818
|
-
<ActivityIndicator color={theme.colors.textPrimary} />
|
|
819
|
-
) : isFavorite ? (
|
|
820
|
-
<CheckCircle2 size={22} color={theme.colors.textPrimary} />
|
|
821
|
-
) : (
|
|
822
|
-
<Plus size={22} color={theme.colors.textPrimary} />
|
|
823
|
-
)}
|
|
824
|
-
<Text style={{ color: theme.colors.textPrimary }}>My List</Text>
|
|
825
|
-
</TouchableOpacity>
|
|
826
|
-
|
|
827
|
-
<TouchableOpacity
|
|
828
|
-
style={[styles.playBtn, { backgroundColor: theme.colors.button }]}
|
|
829
|
-
onPress={handlePlayPress}
|
|
830
|
-
accessibilityRole="button"
|
|
831
|
-
accessibilityLabel="Play content"
|
|
832
|
-
>
|
|
833
|
-
<Play size={20} color={theme.colors.buttonText} />
|
|
834
|
-
<Text style={[styles.playText, { color: theme.colors.buttonText }]}>
|
|
835
|
-
Play
|
|
836
|
-
</Text>
|
|
837
|
-
</TouchableOpacity>
|
|
838
|
-
|
|
839
|
-
<TouchableOpacity
|
|
840
|
-
style={styles.infoBtn}
|
|
841
|
-
onPress={handleInfoPress}
|
|
842
|
-
activeOpacity={0.8}
|
|
843
|
-
accessibilityRole="button"
|
|
844
|
-
accessibilityLabel="View content information"
|
|
845
|
-
>
|
|
846
|
-
<Info size={22} color={theme.colors.textPrimary} />
|
|
847
|
-
<Text style={{ color: theme.colors.textPrimary }}>Info</Text>
|
|
848
|
-
</TouchableOpacity>
|
|
849
|
-
</View>
|
|
850
|
-
</View>
|
|
851
|
-
);
|
|
852
|
-
}
|
|
853
|
-
);
|
|
854
|
-
|
|
855
|
-
ContentInfo.displayName = 'ContentInfo';
|
|
856
|
-
|
|
857
|
-
const styles = StyleSheet.create({
|
|
858
|
-
container: {
|
|
859
|
-
flex: 1,
|
|
860
|
-
},
|
|
861
|
-
gradientContainer: {
|
|
862
|
-
...StyleSheet.absoluteFillObject,
|
|
863
|
-
},
|
|
864
|
-
gradientBottom: {
|
|
865
|
-
position: 'absolute',
|
|
866
|
-
top: 0,
|
|
867
|
-
height: verticalScale(SLIDER_HEIGHT) / GRADIENT_DIVIDER_BOTTOM,
|
|
868
|
-
width: '100%',
|
|
869
|
-
},
|
|
870
|
-
gradientTop: {
|
|
871
|
-
position: 'absolute',
|
|
872
|
-
bottom: 0,
|
|
873
|
-
height: verticalScale(SLIDER_HEIGHT) / GRADIENT_DIVIDER_TOP,
|
|
874
|
-
width: '100%',
|
|
875
|
-
},
|
|
876
|
-
titleImage: {
|
|
877
|
-
position: 'absolute',
|
|
878
|
-
bottom: 0,
|
|
879
|
-
height: verticalScale(TITLE_IMAGE_HEIGHT),
|
|
880
|
-
width: TITLE_IMAGE_WIDTH_PERCENT,
|
|
881
|
-
alignSelf: 'center',
|
|
882
|
-
},
|
|
883
|
-
contentInfoContainer: {
|
|
884
|
-
paddingHorizontal: moderateScale(16),
|
|
885
|
-
paddingTop: moderateScale(12),
|
|
886
|
-
paddingBottom: verticalScale(15),
|
|
887
|
-
},
|
|
888
|
-
genreText: {
|
|
889
|
-
fontSize: moderateScale(12),
|
|
890
|
-
textAlign: 'center',
|
|
891
|
-
marginBottom: verticalScale(16),
|
|
892
|
-
},
|
|
893
|
-
btnContainer: {
|
|
894
|
-
flexDirection: 'row',
|
|
895
|
-
justifyContent: 'center',
|
|
896
|
-
alignItems: 'center',
|
|
897
|
-
position: 'relative',
|
|
898
|
-
minHeight: verticalScale(50),
|
|
899
|
-
paddingVertical: verticalScale(4),
|
|
900
|
-
},
|
|
901
|
-
mylistBtn: {
|
|
902
|
-
alignItems: 'center',
|
|
903
|
-
justifyContent: 'center',
|
|
904
|
-
gap: verticalScale(6),
|
|
905
|
-
position: 'absolute',
|
|
906
|
-
left: moderateScale(16),
|
|
907
|
-
paddingVertical: verticalScale(8),
|
|
908
|
-
paddingHorizontal: moderateScale(4),
|
|
909
|
-
},
|
|
910
|
-
playBtn: {
|
|
911
|
-
flexDirection: 'row',
|
|
912
|
-
alignItems: 'center',
|
|
913
|
-
justifyContent: 'center',
|
|
914
|
-
backgroundColor: '#fff',
|
|
915
|
-
paddingHorizontal: moderateScale(28),
|
|
916
|
-
paddingVertical: verticalScale(10),
|
|
917
|
-
borderRadius: 4,
|
|
918
|
-
gap: moderateScale(8),
|
|
919
|
-
minWidth: moderateScale(90),
|
|
920
|
-
},
|
|
921
|
-
playText: {
|
|
922
|
-
color: '#000',
|
|
923
|
-
fontSize: moderateScale(18),
|
|
924
|
-
fontWeight: '600',
|
|
925
|
-
},
|
|
926
|
-
infoBtn: {
|
|
927
|
-
alignItems: 'center',
|
|
928
|
-
justifyContent: 'center',
|
|
929
|
-
gap: verticalScale(6),
|
|
930
|
-
position: 'absolute',
|
|
931
|
-
right: moderateScale(16),
|
|
932
|
-
paddingVertical: verticalScale(8),
|
|
933
|
-
paddingHorizontal: moderateScale(4),
|
|
934
|
-
},
|
|
935
|
-
});
|