@whatmore-repo/whatmore-reactnative-sdk 1.0.25 → 1.0.26

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.25",
3
+ "version": "1.0.26",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "main": "index.js",
@@ -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'));
@@ -11,9 +11,10 @@ export default function EventTileWithProduct(props) {
11
11
  const { width } = Dimensions.get('window');
12
12
  const ITEM_WIDTH = width * 0.33;
13
13
  const CARD_HEIGHT = 200;
14
-
14
+
15
15
  const styles = StyleSheet.create({
16
16
  container: {
17
+ position: 'relative',
17
18
  width: '100%',
18
19
  height: 250,
19
20
  },
@@ -22,7 +23,21 @@ export default function EventTileWithProduct(props) {
22
23
  height: CARD_HEIGHT,
23
24
  marginHorizontal: 8,
24
25
  top: 20,
25
-
26
+ },
27
+ arrowContainerRight: {
28
+ position: 'absolute',
29
+ top: 90,
30
+ right: 0,
31
+ width: 28,
32
+ height: 28,
33
+ marginHorizontal: 5,
34
+ },
35
+ arrowContainerLeft: {
36
+ position: 'absolute',
37
+ top: 90,
38
+ width: 28,
39
+ height: 28,
40
+ marginHorizontal: 5,
26
41
  }
27
42
  });
28
43
 
@@ -32,36 +47,63 @@ export default function EventTileWithProduct(props) {
32
47
  };
33
48
 
34
49
  const { events, isModalOpen, setInitialEventIndex, setIsModalOpen } = props;
35
- const [pausedVideos, setPausedVideos] = useState({});
36
- const handleVideoLoad = (index) => {
37
- setPausedVideos((prevState) => ({
38
- ...prevState,
39
- [index]: true
40
- }));
50
+ // const [pausedVideos, setPausedVideos] = useState({});
51
+ // const handleVideoLoad = (index) => {
52
+ // setPausedVideos((prevState) => ({
53
+ // ...prevState,
54
+ // [index]: true
55
+ // }));
56
+ // };
57
+ const videoRef = useRef(null);
58
+
59
+ const scrollLeft = () => {
60
+ if (activeIndex > 0) {
61
+ const newIndex = Math.max(0, activeIndex - 2);
62
+ flatListRef.current.scrollToIndex({ index: newIndex, animated: true });
63
+ setActiveIndex(newIndex);
64
+ }
65
+ };
66
+
67
+ const scrollRight = () => {
68
+ setRenderedEvents(prev => prev + 2);
69
+ if (activeIndex < events.length - 1) {
70
+ const newIndex = activeIndex + 2;
71
+ flatListRef.current.scrollToIndex({ index: newIndex, animated: true });
72
+ setActiveIndex(newIndex);
73
+ }
41
74
  };
42
75
 
76
+ // useEffect(() => {
77
+ // setPausedVideos(pausedVideos[index] && index !== activeIndex);
78
+ // }, [pausedVideos, index, activeIndex]);
79
+
80
+ // React.useEffect(()=>{
81
+ // if(videoRef.current){
82
+ // // videoRef.current.pauseAsync()
83
+ // }
84
+ // },[])
43
85
  const renderItem = ({ item, index }) => {
44
86
  return (
45
87
  <TouchableOpacity onPress={() => handleClick(index)} key={index}>
46
88
  <Animated.View style={[styles.cardContainer]}>
47
- {
48
- <Image src={item.poster_image}/>
49
- }
50
89
  <Video
90
+ ref={videoRef}
51
91
  source={{ uri: item?.thumbnail_image }}
52
92
  controls={false}
53
93
  repeat
54
94
  muted
55
95
  resizeMode={"cover"}
56
- paused={false}
57
- onLoad={() => handleVideoLoad(index)}
96
+ // paused={index !== activeIndex}
97
+ // onLoad={() => handleVideoLoad(index)}
58
98
 
59
99
  style={{
60
100
  aspectRatio: 0.5625,
61
101
  width: "100%",
62
102
  height: '100%',
63
103
  borderRadius: 10,
64
- transform: [{ scale: 1.1 }]
104
+ transform: [{ scale: 1.1 }],
105
+ // elevation: 1
106
+
65
107
  }}
66
108
  />
67
109
  </Animated.View>
@@ -69,46 +111,35 @@ export default function EventTileWithProduct(props) {
69
111
  );
70
112
  };
71
113
  const flatListRef = useRef(null);
72
- const handleScroll = (event) => {
73
- const offsetX = event.nativeEvent.contentOffset.x;
74
- const index = Math.round(offsetX / ITEM_WIDTH);
75
- setRenderedEvents(prev => prev + 1)
76
- setActiveIndex(index);
77
- };
114
+
78
115
  return (
79
116
  <SafeAreaView style={styles.container}>
80
117
  <Animated.FlatList
81
118
  horizontal
119
+ style={{paddingLeft: 10}}
82
120
  data={events.slice(0,renderedEvents)}
83
121
  renderItem={renderItem}
84
- keyExtractor={(item, index) => index.toString()}
85
122
  contentInsetAdjustmentBehavior="never"
86
123
  decelerationRate="fast"
124
+ scrollEnabled={false}
87
125
  automaticallyAdjustContentInsets={false}
88
126
  showsHorizontalScrollIndicator={false}
89
- onScroll={handleScroll}
90
127
  scrollEventThrottle={16}
91
128
  ref={flatListRef}
92
129
  />
130
+ <TouchableOpacity style={styles.arrowContainerLeft} onPress={scrollLeft}>
131
+ <ChevronLeftIcon />
132
+ </TouchableOpacity>
133
+ <TouchableOpacity style={styles.arrowContainerRight} onPress={scrollRight}>
134
+ <ChevronRightIcon />
135
+ </TouchableOpacity>
93
136
  </SafeAreaView>
94
137
  );
95
138
  }
96
139
 
97
-
98
- // onScroll={Animated.event(
99
- // [{ nativeEvent: { contentOffset: { x: scrollX } } }],
100
- // { useNativeDriver: true }
101
- // )}
102
-
103
- // snapToAlignment="center"
104
- // const scale = scrollX.interpolate({
105
- // inputRange,
106
- // outputRange: [0.9, 1.1, 0.9],
107
- // extrapolate: 'clamp',
108
- // });
109
-
110
- // const inputRange = [
111
- // (index - 1) * ITEM_WIDTH,
112
- // index * ITEM_WIDTH,
113
- // (index +1) * ITEM_WIDTH,
114
- // ];
140
+ // const handleScroll = (event) => {
141
+ // const offsetX = event.nativeEvent.contentOffset.x;
142
+ // const index = Math.round((offsetX + ITEM_WIDTH)/ ITEM_WIDTH);
143
+ // setRenderedEvents(prev => prev + 1)
144
+ // setActiveIndex(index);
145
+ // };