@whatmore-repo/whatmore-reactnative-sdk 1.0.25 → 1.0.27
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatmore-repo/whatmore-reactnative-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "index.js",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"currency-symbol-map": "^5.1.0",
|
|
15
15
|
"react-hooks-global-state": "^2.1.0",
|
|
16
16
|
"react-native-animatable": "^1.3.3",
|
|
17
|
-
"react-native-intersection-observer": "^0.0.9"
|
|
18
|
-
"react-native-snap-carousel": "^3.9.1"
|
|
17
|
+
"react-native-intersection-observer": "^0.0.9"
|
|
19
18
|
},
|
|
20
19
|
"devDependencies": {
|
|
21
20
|
"@babel/core": "^7.20.0"
|
|
@@ -2,7 +2,6 @@ import React, { useState, useEffect, lazy } from 'react';
|
|
|
2
2
|
import { WHATMORE_BACKEND_BASE_URL } from '../constants/AppGlobalVars';
|
|
3
3
|
import { extractEvents, removeInvalidEvents } from '../utils/EventSanityUtils';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
|
-
// import EventTileWithProduct from './carousel-view/EventTileWithProduct.js';
|
|
6
5
|
|
|
7
6
|
const EventTileWithProduct = lazy(() => import('./carousel-view/EventTileWithProduct.js'));
|
|
8
7
|
const EventClickComponent = lazy(() => import('./EventClickComponent'));
|
|
@@ -35,7 +34,8 @@ export default function WhatmoreRootComponent(props) {
|
|
|
35
34
|
var brandId = props.shopId;
|
|
36
35
|
const [data, setData] = useState();
|
|
37
36
|
const [error, setError] = useState();
|
|
38
|
-
const [
|
|
37
|
+
const isInstaReelView = ["27358003275", "STR60LW4WMA"];
|
|
38
|
+
const [isModalOpen, setIsModalOpen] = useState(!isInstaReelView.includes(brandId));
|
|
39
39
|
const [initialEventIndex, setInitialEventIndex] = useState(0)
|
|
40
40
|
|
|
41
41
|
var eventStatuses = "live,upcoming";
|
|
@@ -89,8 +89,8 @@ export default function WhatmoreRootComponent(props) {
|
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
91
|
<>
|
|
92
|
-
{brandId
|
|
93
|
-
{(isModalOpen
|
|
92
|
+
{isInstaReelView.includes(brandId) && <EventTileWithProduct isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen} events={data} setInitialEventIndex={setInitialEventIndex} />}
|
|
93
|
+
{(isModalOpen) && <EventClickComponent isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen} events={data} initialEventIndex={initialEventIndex} onAction={props.onAction} /> }
|
|
94
94
|
</>
|
|
95
95
|
);
|
|
96
96
|
}
|
|
@@ -4,6 +4,7 @@ import Video from 'react-native-video';
|
|
|
4
4
|
import { useState, useRef } from 'react';
|
|
5
5
|
import ChevronRightIcon from '../../icons/icon-components/ChevronRight';
|
|
6
6
|
import ChevronLeftIcon from '../../icons/icon-components/ChevronLeft';
|
|
7
|
+
import { getGlobalState } from '../../globals/useAppState_APP';
|
|
7
8
|
|
|
8
9
|
export default function EventTileWithProduct(props) {
|
|
9
10
|
const [activeIndex, setActiveIndex] = useState(1);
|
|
@@ -11,18 +12,27 @@ export default function EventTileWithProduct(props) {
|
|
|
11
12
|
const { width } = Dimensions.get('window');
|
|
12
13
|
const ITEM_WIDTH = width * 0.33;
|
|
13
14
|
const CARD_HEIGHT = 200;
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
const styles = StyleSheet.create({
|
|
16
17
|
container: {
|
|
18
|
+
position: 'relative',
|
|
17
19
|
width: '100%',
|
|
18
20
|
height: 250,
|
|
19
21
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
arrowContainerRight: {
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
top: 90,
|
|
25
|
+
right: 0,
|
|
26
|
+
width: 28,
|
|
27
|
+
height: 28,
|
|
28
|
+
marginHorizontal: 5,
|
|
29
|
+
},
|
|
30
|
+
arrowContainerLeft: {
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
top: 90,
|
|
33
|
+
width: 28,
|
|
34
|
+
height: 28,
|
|
35
|
+
marginHorizontal: 5,
|
|
26
36
|
}
|
|
27
37
|
});
|
|
28
38
|
|
|
@@ -32,83 +42,102 @@ export default function EventTileWithProduct(props) {
|
|
|
32
42
|
};
|
|
33
43
|
|
|
34
44
|
const { events, isModalOpen, setInitialEventIndex, setIsModalOpen } = props;
|
|
35
|
-
const [pausedVideos, setPausedVideos] = useState({});
|
|
36
|
-
const handleVideoLoad = (index) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
// const [pausedVideos, setPausedVideos] = useState({});
|
|
46
|
+
// const handleVideoLoad = (index) => {
|
|
47
|
+
// setPausedVideos((prevState) => ({
|
|
48
|
+
// ...prevState,
|
|
49
|
+
// [index]: true
|
|
50
|
+
// }));
|
|
51
|
+
// };
|
|
52
|
+
const videoRef = useRef(null);
|
|
53
|
+
|
|
54
|
+
const scrollLeft = () => {
|
|
55
|
+
if (activeIndex > 0) {
|
|
56
|
+
const newIndex = Math.max(0, activeIndex - 2);
|
|
57
|
+
flatListRef.current.scrollToIndex({ index: newIndex, animated: true });
|
|
58
|
+
setActiveIndex(newIndex);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const scrollRight = () => {
|
|
63
|
+
setRenderedEvents(prev => prev + 2);
|
|
64
|
+
if (activeIndex < events.length - 1) {
|
|
65
|
+
const newIndex = activeIndex + 2;
|
|
66
|
+
flatListRef.current.scrollToIndex({ index: newIndex, animated: true });
|
|
67
|
+
setActiveIndex(newIndex);
|
|
68
|
+
}
|
|
41
69
|
};
|
|
42
70
|
|
|
71
|
+
// useEffect(() => {
|
|
72
|
+
// setPausedVideos(pausedVideos[index] && index !== activeIndex);
|
|
73
|
+
// }, [pausedVideos, index, activeIndex]);
|
|
74
|
+
|
|
75
|
+
// React.useEffect(()=>{
|
|
76
|
+
// if(videoRef.current){
|
|
77
|
+
// // videoRef.current.pauseAsync()
|
|
78
|
+
// }
|
|
79
|
+
// },[])
|
|
43
80
|
const renderItem = ({ item, index }) => {
|
|
44
81
|
return (
|
|
45
82
|
<TouchableOpacity onPress={() => handleClick(index)} key={index}>
|
|
46
|
-
<Animated.View style={[styles.cardContainer]}>
|
|
47
|
-
{
|
|
48
|
-
<Image src={item.poster_image}/>
|
|
49
|
-
}
|
|
50
83
|
<Video
|
|
84
|
+
ref={videoRef}
|
|
51
85
|
source={{ uri: item?.thumbnail_image }}
|
|
52
86
|
controls={false}
|
|
53
87
|
repeat
|
|
54
88
|
muted
|
|
55
89
|
resizeMode={"cover"}
|
|
56
|
-
paused={
|
|
57
|
-
onLoad={() => handleVideoLoad(index)}
|
|
90
|
+
// paused={index !== activeIndex}
|
|
91
|
+
// onLoad={() => handleVideoLoad(index)}
|
|
58
92
|
|
|
59
93
|
style={{
|
|
60
94
|
aspectRatio: 0.5625,
|
|
61
|
-
width: "100%",
|
|
62
|
-
height: '100%',
|
|
63
95
|
borderRadius: 10,
|
|
64
|
-
transform: [{ scale: 1.1 }]
|
|
96
|
+
transform: [{ scale: 1.1 }],
|
|
97
|
+
width: ITEM_WIDTH,
|
|
98
|
+
height: CARD_HEIGHT,
|
|
99
|
+
marginHorizontal: 8,
|
|
100
|
+
top: 20,
|
|
101
|
+
// elevation: 1
|
|
65
102
|
}}
|
|
66
103
|
/>
|
|
67
|
-
</Animated.View>
|
|
68
104
|
</TouchableOpacity>
|
|
69
105
|
);
|
|
70
106
|
};
|
|
71
107
|
const flatListRef = useRef(null);
|
|
72
|
-
const
|
|
73
|
-
const offsetX = event.nativeEvent.contentOffset.x;
|
|
74
|
-
const index = Math.round(offsetX / ITEM_WIDTH);
|
|
75
|
-
setRenderedEvents(prev => prev + 1)
|
|
76
|
-
setActiveIndex(index);
|
|
77
|
-
};
|
|
108
|
+
const brandDomainContext = getGlobalState('brandDomainContext')
|
|
78
109
|
return (
|
|
79
110
|
<SafeAreaView style={styles.container}>
|
|
80
111
|
<Animated.FlatList
|
|
81
112
|
horizontal
|
|
113
|
+
style={{paddingLeft: 10}}
|
|
82
114
|
data={events.slice(0,renderedEvents)}
|
|
83
115
|
renderItem={renderItem}
|
|
84
|
-
keyExtractor={(item, index) => index.toString()}
|
|
85
116
|
contentInsetAdjustmentBehavior="never"
|
|
86
117
|
decelerationRate="fast"
|
|
118
|
+
scrollEnabled={brandDomainContext != "appmaker"}
|
|
87
119
|
automaticallyAdjustContentInsets={false}
|
|
88
120
|
showsHorizontalScrollIndicator={false}
|
|
89
|
-
onScroll={handleScroll}
|
|
90
121
|
scrollEventThrottle={16}
|
|
91
122
|
ref={flatListRef}
|
|
92
123
|
/>
|
|
124
|
+
<TouchableOpacity style={styles.arrowContainerLeft} onPress={scrollLeft}>
|
|
125
|
+
<ChevronLeftIcon />
|
|
126
|
+
</TouchableOpacity>
|
|
127
|
+
<TouchableOpacity style={styles.arrowContainerRight} onPress={scrollRight}>
|
|
128
|
+
<ChevronRightIcon />
|
|
129
|
+
</TouchableOpacity>
|
|
93
130
|
</SafeAreaView>
|
|
94
131
|
);
|
|
95
132
|
}
|
|
96
133
|
|
|
134
|
+
// const handleScroll = (event) => {
|
|
135
|
+
// const offsetX = event.nativeEvent.contentOffset.x;
|
|
136
|
+
// const index = Math.round((offsetX + ITEM_WIDTH)/ ITEM_WIDTH);
|
|
137
|
+
// setRenderedEvents(prev => prev + 1)
|
|
138
|
+
// setActiveIndex(index);
|
|
139
|
+
// };
|
|
97
140
|
|
|
98
|
-
// onScroll={Animated.event(
|
|
99
|
-
// [{ nativeEvent: { contentOffset: { x: scrollX } } }],
|
|
100
|
-
// { useNativeDriver: true }
|
|
101
|
-
// )}
|
|
102
141
|
|
|
103
|
-
// snapToAlignment="center"
|
|
104
|
-
// const scale = scrollX.interpolate({
|
|
105
|
-
// inputRange,
|
|
106
|
-
// outputRange: [0.9, 1.1, 0.9],
|
|
107
|
-
// extrapolate: 'clamp',
|
|
108
|
-
// });
|
|
109
142
|
|
|
110
|
-
|
|
111
|
-
// (index - 1) * ITEM_WIDTH,
|
|
112
|
-
// index * ITEM_WIDTH,
|
|
113
|
-
// (index +1) * ITEM_WIDTH,
|
|
114
|
-
// ];
|
|
143
|
+
// "react-native-video": "github:freeboub/react-native-video#chore/fixAppBoot"
|