@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,429 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Naresh Dhamu
|
|
3
|
-
* @lastModified Mon 30 Jun 2025 at 10:46 PM
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, {
|
|
7
|
-
useRef,
|
|
8
|
-
useLayoutEffect,
|
|
9
|
-
useEffect,
|
|
10
|
-
useCallback,
|
|
11
|
-
useMemo,
|
|
12
|
-
useState,
|
|
13
|
-
} from 'react';
|
|
14
|
-
import {
|
|
15
|
-
View,
|
|
16
|
-
FlatList,
|
|
17
|
-
TouchableOpacity,
|
|
18
|
-
StyleSheet,
|
|
19
|
-
Dimensions,
|
|
20
|
-
InteractionManager,
|
|
21
|
-
Platform,
|
|
22
|
-
Vibration,
|
|
23
|
-
type LayoutChangeEvent,
|
|
24
|
-
type ListRenderItemInfo,
|
|
25
|
-
} from 'react-native';
|
|
26
|
-
import { Text } from '../../../Text';
|
|
27
|
-
import { useInternalTheme } from '../../../../theme/hook/useInternalTheme';
|
|
28
|
-
import { scale, verticalScale } from 'react-native-size-matters';
|
|
29
|
-
import SkeletonPlaceholder from 'react-native-skeleton-placeholder';
|
|
30
|
-
import type { ThemeOverride } from '../../../../theme/themes';
|
|
31
|
-
import { RFValue } from 'react-native-responsive-fontsize';
|
|
32
|
-
|
|
33
|
-
export type ICategory = {
|
|
34
|
-
_id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
slug: string;
|
|
37
|
-
description: string;
|
|
38
|
-
order: number;
|
|
39
|
-
icon: string | null;
|
|
40
|
-
show_in_menu: boolean;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type CategoryCardTwoProps = {
|
|
44
|
-
category?: ICategory[];
|
|
45
|
-
activeCategory?: ICategory;
|
|
46
|
-
onPressCategory?: (category: ICategory) => void;
|
|
47
|
-
theme?: ThemeOverride;
|
|
48
|
-
mode?: 'text' | 'filled';
|
|
49
|
-
isLoading?: boolean;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const ITEM_WIDTH = scale(80);
|
|
53
|
-
const CONTAINER_PADDING = scale(14);
|
|
54
|
-
const { width: SCREEN_WIDTH } = Dimensions.get('window');
|
|
55
|
-
|
|
56
|
-
import { usePrevious } from '../../../../hooks/usePrevious';
|
|
57
|
-
import { useSkeletonItems } from '../../../../hooks/useSkeletonItems';
|
|
58
|
-
import { debounce } from 'lodash';
|
|
59
|
-
|
|
60
|
-
const CategoryCardTwo = React.memo(
|
|
61
|
-
({
|
|
62
|
-
category = [],
|
|
63
|
-
activeCategory,
|
|
64
|
-
onPressCategory,
|
|
65
|
-
theme,
|
|
66
|
-
mode = 'text',
|
|
67
|
-
isLoading = false,
|
|
68
|
-
}: CategoryCardTwoProps) => {
|
|
69
|
-
const { theme: appliedTheme } = useInternalTheme(theme);
|
|
70
|
-
const flatListRef = useRef<FlatList<ICategory>>(null);
|
|
71
|
-
const [itemWidths, setItemWidths] = useState<number[]>([]);
|
|
72
|
-
const isScrollingRef = useRef(false);
|
|
73
|
-
const lastPressedIndexRef = useRef<number | null>(null);
|
|
74
|
-
|
|
75
|
-
// Memoize theme colors
|
|
76
|
-
const themeColors = useMemo(
|
|
77
|
-
() => ({
|
|
78
|
-
primary: appliedTheme.colors.primary,
|
|
79
|
-
outline: appliedTheme.colors.outline,
|
|
80
|
-
buttonText: appliedTheme.colors.buttonText,
|
|
81
|
-
textPrimary: appliedTheme.colors.textPrimary,
|
|
82
|
-
skeletonBaseColor: appliedTheme.colors.skeletonBaseColor,
|
|
83
|
-
skeletonHighlightColor: appliedTheme.colors.skeletonHighlightColor,
|
|
84
|
-
}),
|
|
85
|
-
[appliedTheme.colors]
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const selectedCategory = useMemo(
|
|
89
|
-
() => activeCategory || category?.[0] || null,
|
|
90
|
-
[activeCategory, category]
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const prevCategoryId = usePrevious(selectedCategory?._id);
|
|
94
|
-
|
|
95
|
-
// Memoize skeleton items
|
|
96
|
-
const skeletonItems = useSkeletonItems(5);
|
|
97
|
-
|
|
98
|
-
// Memoize skeleton item style
|
|
99
|
-
const skeletonItemStyle = useMemo(
|
|
100
|
-
() => ({
|
|
101
|
-
width: ITEM_WIDTH - scale(20),
|
|
102
|
-
height: verticalScale(26),
|
|
103
|
-
borderRadius: scale(8),
|
|
104
|
-
marginRight: scale(8),
|
|
105
|
-
}),
|
|
106
|
-
[]
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
// Memoize list container style with flexDirection
|
|
110
|
-
const listContainerStyle = useMemo(
|
|
111
|
-
() => [styles.listContainer, { flexDirection: 'row' as const }],
|
|
112
|
-
[]
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// Haptic feedback utility
|
|
116
|
-
const triggerHapticFeedback = useCallback(() => {
|
|
117
|
-
if (Platform.OS === 'ios') {
|
|
118
|
-
// iOS haptic feedback (light impact)
|
|
119
|
-
Vibration.vibrate(1);
|
|
120
|
-
} else if (Platform.OS === 'android') {
|
|
121
|
-
// Android haptic feedback (short vibration)
|
|
122
|
-
Vibration.vibrate(10);
|
|
123
|
-
}
|
|
124
|
-
}, []);
|
|
125
|
-
|
|
126
|
-
const scrollToCategory = useCallback(
|
|
127
|
-
(index: number, animated: boolean) => {
|
|
128
|
-
if (
|
|
129
|
-
!flatListRef.current ||
|
|
130
|
-
index < 0 ||
|
|
131
|
-
index >= category.length ||
|
|
132
|
-
isScrollingRef.current
|
|
133
|
-
)
|
|
134
|
-
return;
|
|
135
|
-
|
|
136
|
-
isScrollingRef.current = true;
|
|
137
|
-
const RIGHT_SCROLL_BIAS = scale(40);
|
|
138
|
-
const offset = itemWidths.length
|
|
139
|
-
? itemWidths.slice(0, index).reduce((sum, w) => sum + w, 0) +
|
|
140
|
-
(itemWidths[index] ?? ITEM_WIDTH) / 2 -
|
|
141
|
-
SCREEN_WIDTH / 2 +
|
|
142
|
-
RIGHT_SCROLL_BIAS
|
|
143
|
-
: index * ITEM_WIDTH +
|
|
144
|
-
ITEM_WIDTH / 2 -
|
|
145
|
-
SCREEN_WIDTH / 2 +
|
|
146
|
-
RIGHT_SCROLL_BIAS;
|
|
147
|
-
|
|
148
|
-
InteractionManager.runAfterInteractions(() => {
|
|
149
|
-
flatListRef.current?.scrollToOffset({
|
|
150
|
-
offset: Math.max(0, offset),
|
|
151
|
-
animated,
|
|
152
|
-
});
|
|
153
|
-
// Reset scrolling flag after animation completes
|
|
154
|
-
if (animated) {
|
|
155
|
-
setTimeout(() => {
|
|
156
|
-
isScrollingRef.current = false;
|
|
157
|
-
}, 300);
|
|
158
|
-
} else {
|
|
159
|
-
isScrollingRef.current = false;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
[category, itemWidths]
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
// Debounced scroll function to prevent rapid scrolling
|
|
167
|
-
const debouncedScrollToCategory = useMemo(
|
|
168
|
-
() =>
|
|
169
|
-
debounce((index: number, animated: boolean) => {
|
|
170
|
-
scrollToCategory(index, animated);
|
|
171
|
-
}, 100),
|
|
172
|
-
[scrollToCategory]
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
// Cleanup debounced function on unmount
|
|
176
|
-
useEffect(() => {
|
|
177
|
-
return () => {
|
|
178
|
-
debouncedScrollToCategory.cancel();
|
|
179
|
-
};
|
|
180
|
-
}, [debouncedScrollToCategory]);
|
|
181
|
-
|
|
182
|
-
const onItemLayout = useCallback(
|
|
183
|
-
(event: LayoutChangeEvent, index: number) => {
|
|
184
|
-
const { width } = event.nativeEvent.layout;
|
|
185
|
-
setItemWidths((prev) => {
|
|
186
|
-
const newWidths = [...prev];
|
|
187
|
-
newWidths[index] = width;
|
|
188
|
-
return newWidths;
|
|
189
|
-
});
|
|
190
|
-
},
|
|
191
|
-
[]
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
useLayoutEffect(() => {
|
|
195
|
-
if (
|
|
196
|
-
selectedCategory &&
|
|
197
|
-
category.length > 0 &&
|
|
198
|
-
selectedCategory._id !== prevCategoryId
|
|
199
|
-
) {
|
|
200
|
-
const index = category.findIndex(
|
|
201
|
-
(cat) => cat._id === selectedCategory._id
|
|
202
|
-
);
|
|
203
|
-
if (index >= 0 && index !== lastPressedIndexRef.current) {
|
|
204
|
-
// Use debounced scroll for external category changes
|
|
205
|
-
debouncedScrollToCategory(index, true);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}, [selectedCategory, category, debouncedScrollToCategory, prevCategoryId]);
|
|
209
|
-
|
|
210
|
-
const handlePress = useCallback(
|
|
211
|
-
(item: ICategory) => {
|
|
212
|
-
// Prevent rapid successive taps on the same item
|
|
213
|
-
const index = category.findIndex((cat) => cat._id === item._id);
|
|
214
|
-
if (index < 0) return;
|
|
215
|
-
|
|
216
|
-
// Check if same item is being pressed rapidly
|
|
217
|
-
if (lastPressedIndexRef.current === index && isScrollingRef.current) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
lastPressedIndexRef.current = index;
|
|
222
|
-
|
|
223
|
-
// Trigger haptic feedback for better UX
|
|
224
|
-
triggerHapticFeedback();
|
|
225
|
-
|
|
226
|
-
// Call the callback
|
|
227
|
-
onPressCategory?.(item);
|
|
228
|
-
|
|
229
|
-
// Scroll to category with slight delay for smoother UX
|
|
230
|
-
requestAnimationFrame(() => {
|
|
231
|
-
scrollToCategory(index, true);
|
|
232
|
-
});
|
|
233
|
-
},
|
|
234
|
-
[category, onPressCategory, scrollToCategory, triggerHapticFeedback]
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
// Memoize filled mode selected style
|
|
238
|
-
const filledSelectedStyle = useMemo(
|
|
239
|
-
() => ({
|
|
240
|
-
borderRadius: scale(8),
|
|
241
|
-
borderWidth: scale(1),
|
|
242
|
-
borderColor: themeColors.primary,
|
|
243
|
-
backgroundColor: themeColors.primary,
|
|
244
|
-
}),
|
|
245
|
-
[themeColors.primary]
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
// Memoize filled mode unselected style
|
|
249
|
-
const filledUnselectedStyle = useMemo(
|
|
250
|
-
() => ({
|
|
251
|
-
borderRadius: scale(8),
|
|
252
|
-
borderWidth: scale(1),
|
|
253
|
-
borderColor: themeColors.outline,
|
|
254
|
-
backgroundColor: 'transparent',
|
|
255
|
-
}),
|
|
256
|
-
[themeColors.outline]
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
// Memoize underline style
|
|
260
|
-
const underlineStyle = useMemo(
|
|
261
|
-
() => [styles.underline, { backgroundColor: themeColors.primary }],
|
|
262
|
-
[themeColors.primary]
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
const renderItem = useCallback(
|
|
266
|
-
({ item, index }: ListRenderItemInfo<ICategory>) => {
|
|
267
|
-
const isSelected = item._id === selectedCategory?._id;
|
|
268
|
-
const isFilledMode = mode === 'filled';
|
|
269
|
-
|
|
270
|
-
const containerStyle = [
|
|
271
|
-
styles.tabContainer,
|
|
272
|
-
isFilledMode &&
|
|
273
|
-
(isSelected ? filledSelectedStyle : filledUnselectedStyle),
|
|
274
|
-
];
|
|
275
|
-
|
|
276
|
-
const textColor = isFilledMode
|
|
277
|
-
? isSelected
|
|
278
|
-
? themeColors.buttonText
|
|
279
|
-
: themeColors.textPrimary
|
|
280
|
-
: isSelected
|
|
281
|
-
? themeColors.primary
|
|
282
|
-
: themeColors.textPrimary;
|
|
283
|
-
|
|
284
|
-
const textStyle = [styles.tabText, { color: textColor }];
|
|
285
|
-
|
|
286
|
-
return (
|
|
287
|
-
<TouchableOpacity
|
|
288
|
-
activeOpacity={0.7}
|
|
289
|
-
onPress={() => handlePress(item)}
|
|
290
|
-
style={containerStyle}
|
|
291
|
-
onLayout={(event) => onItemLayout(event, index)}
|
|
292
|
-
accessibilityLabel={`Select category ${item.name}`}
|
|
293
|
-
accessibilityRole="button"
|
|
294
|
-
accessibilityState={{ selected: isSelected }}
|
|
295
|
-
accessibilityHint={
|
|
296
|
-
isSelected
|
|
297
|
-
? `${item.name} is currently selected`
|
|
298
|
-
: `Double tap to select ${item.name} category`
|
|
299
|
-
}
|
|
300
|
-
>
|
|
301
|
-
<Text style={textStyle}>{item.name}</Text>
|
|
302
|
-
{mode === 'text' && isSelected && <View style={underlineStyle} />}
|
|
303
|
-
</TouchableOpacity>
|
|
304
|
-
);
|
|
305
|
-
},
|
|
306
|
-
[
|
|
307
|
-
selectedCategory,
|
|
308
|
-
mode,
|
|
309
|
-
themeColors,
|
|
310
|
-
handlePress,
|
|
311
|
-
onItemLayout,
|
|
312
|
-
filledSelectedStyle,
|
|
313
|
-
filledUnselectedStyle,
|
|
314
|
-
underlineStyle,
|
|
315
|
-
]
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
const renderSkeleton = useCallback(
|
|
319
|
-
() => (
|
|
320
|
-
<SkeletonPlaceholder
|
|
321
|
-
backgroundColor={themeColors.skeletonBaseColor}
|
|
322
|
-
highlightColor={themeColors.skeletonHighlightColor}
|
|
323
|
-
>
|
|
324
|
-
<View style={listContainerStyle}>
|
|
325
|
-
{skeletonItems.map((_, index) => (
|
|
326
|
-
<View key={index} style={skeletonItemStyle} />
|
|
327
|
-
))}
|
|
328
|
-
</View>
|
|
329
|
-
</SkeletonPlaceholder>
|
|
330
|
-
),
|
|
331
|
-
[themeColors, listContainerStyle, skeletonItems, skeletonItemStyle]
|
|
332
|
-
);
|
|
333
|
-
|
|
334
|
-
const getItemLayout = useCallback(
|
|
335
|
-
(_: unknown, index: number) => ({
|
|
336
|
-
length: itemWidths[index] || ITEM_WIDTH,
|
|
337
|
-
offset: itemWidths
|
|
338
|
-
.slice(0, index)
|
|
339
|
-
.reduce((sum, width) => sum + (width || ITEM_WIDTH), 0),
|
|
340
|
-
index,
|
|
341
|
-
}),
|
|
342
|
-
[itemWidths]
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
// Memoize keyExtractor
|
|
346
|
-
const keyExtractor = useCallback((item: ICategory) => item._id, []);
|
|
347
|
-
|
|
348
|
-
return (
|
|
349
|
-
<View style={styles.container}>
|
|
350
|
-
{isLoading ? (
|
|
351
|
-
renderSkeleton()
|
|
352
|
-
) : (
|
|
353
|
-
<FlatList
|
|
354
|
-
ref={flatListRef}
|
|
355
|
-
data={category}
|
|
356
|
-
keyExtractor={keyExtractor}
|
|
357
|
-
horizontal
|
|
358
|
-
showsHorizontalScrollIndicator={false}
|
|
359
|
-
contentContainerStyle={styles.listContainer}
|
|
360
|
-
extraData={selectedCategory?._id}
|
|
361
|
-
renderItem={renderItem}
|
|
362
|
-
getItemLayout={getItemLayout}
|
|
363
|
-
decelerationRate="fast"
|
|
364
|
-
scrollEnabled
|
|
365
|
-
scrollEventThrottle={16}
|
|
366
|
-
initialNumToRender={10}
|
|
367
|
-
maxToRenderPerBatch={12}
|
|
368
|
-
windowSize={5}
|
|
369
|
-
removeClippedSubviews
|
|
370
|
-
onScrollBeginDrag={() => {
|
|
371
|
-
isScrollingRef.current = true;
|
|
372
|
-
}}
|
|
373
|
-
onScrollEndDrag={() => {
|
|
374
|
-
// Reset after a short delay to allow momentum scrolling
|
|
375
|
-
setTimeout(() => {
|
|
376
|
-
isScrollingRef.current = false;
|
|
377
|
-
}, 200);
|
|
378
|
-
}}
|
|
379
|
-
onMomentumScrollEnd={() => {
|
|
380
|
-
isScrollingRef.current = false;
|
|
381
|
-
}}
|
|
382
|
-
accessibilityLabel="Category selection list"
|
|
383
|
-
accessibilityRole="list"
|
|
384
|
-
/>
|
|
385
|
-
)}
|
|
386
|
-
</View>
|
|
387
|
-
);
|
|
388
|
-
},
|
|
389
|
-
(prev, next) =>
|
|
390
|
-
prev.category === next.category &&
|
|
391
|
-
prev.activeCategory?._id === next.activeCategory?._id &&
|
|
392
|
-
prev.isLoading === next.isLoading &&
|
|
393
|
-
prev.mode === next.mode &&
|
|
394
|
-
prev.theme === next.theme &&
|
|
395
|
-
prev.onPressCategory === next.onPressCategory
|
|
396
|
-
);
|
|
397
|
-
|
|
398
|
-
const styles = StyleSheet.create({
|
|
399
|
-
container: {
|
|
400
|
-
marginVertical: verticalScale(2),
|
|
401
|
-
paddingVertical: verticalScale(10),
|
|
402
|
-
},
|
|
403
|
-
listContainer: {
|
|
404
|
-
paddingLeft: CONTAINER_PADDING,
|
|
405
|
-
flexDirection: 'row',
|
|
406
|
-
paddingRight: CONTAINER_PADDING + scale(2),
|
|
407
|
-
},
|
|
408
|
-
tabContainer: {
|
|
409
|
-
alignItems: 'center',
|
|
410
|
-
justifyContent: 'center',
|
|
411
|
-
marginRight: scale(8),
|
|
412
|
-
paddingHorizontal: scale(12),
|
|
413
|
-
paddingVertical: verticalScale(6),
|
|
414
|
-
},
|
|
415
|
-
tabText: {
|
|
416
|
-
fontSize: RFValue(10),
|
|
417
|
-
textTransform: 'capitalize',
|
|
418
|
-
fontWeight: '500',
|
|
419
|
-
lineHeight: scale(13),
|
|
420
|
-
},
|
|
421
|
-
underline: {
|
|
422
|
-
marginTop: verticalScale(2),
|
|
423
|
-
height: scale(2),
|
|
424
|
-
width: '60%',
|
|
425
|
-
borderRadius: scale(2),
|
|
426
|
-
},
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
export default CategoryCardTwo;
|