@whatmore-repo/whatmore-reactnative-sdk 1.0.24 → 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 +1 -1
- package/src/components/EventShoppingOverlay.js +20 -20
- package/src/components/WhatmoreRootComponent.js +0 -1
- package/src/components/carousel-view/EventTileWithProduct.js +114 -64
- package/src/icons/icon-components/ChevronLeft.jsx +11 -0
- package/src/icons/icon-components/ChevronRight.jsx +11 -0
package/package.json
CHANGED
|
@@ -8,46 +8,46 @@ import CrossIcon from '../icons/icon-components/CloseIcon.jsx';
|
|
|
8
8
|
export default function EventShoppingOverlay(props) {
|
|
9
9
|
var event = props.event;
|
|
10
10
|
return (
|
|
11
|
-
<View
|
|
11
|
+
<View
|
|
12
12
|
style={{
|
|
13
13
|
width: '100%', height: '100%',
|
|
14
|
-
flex: 1, flexDirection: 'column',
|
|
14
|
+
flex: 1, flexDirection: 'column',
|
|
15
15
|
justifyContent: 'flex-start', alignItems: 'center'
|
|
16
16
|
}}
|
|
17
17
|
>
|
|
18
18
|
{/* <Text style={{fontSize: 20, fontWeight: 'bold'}}> ABCD </Text> */}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
<View style={{
|
|
20
|
+
width: '100%',
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
justifyContent: 'space-between',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
backgroundColor: 'transparent',
|
|
25
|
+
paddingTop: 10,
|
|
26
|
+
}}>
|
|
27
|
+
<TouchableOpacity onPress={() => props.setIsModalOpen(false)} style={{ paddingLeft: 20 }}>
|
|
28
|
+
<CrossIcon />
|
|
29
29
|
</TouchableOpacity>
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
<AppMuteUnmuteIcon />
|
|
32
32
|
</View>
|
|
33
33
|
<View
|
|
34
34
|
style={{
|
|
35
|
-
width: '100%',
|
|
35
|
+
width: '100%',
|
|
36
36
|
height: 'auto',
|
|
37
37
|
flex: 1,
|
|
38
38
|
flexDirection: 'column',
|
|
39
39
|
justifyContent: 'space-between', alignItems: 'center', backgroundColor: 'transparent'
|
|
40
40
|
}}
|
|
41
|
-
>
|
|
41
|
+
>
|
|
42
42
|
<TouchableOpacity
|
|
43
43
|
style={{
|
|
44
|
-
width: '100%',
|
|
44
|
+
width: '100%',
|
|
45
45
|
height: 'auto',
|
|
46
46
|
flex: 1,
|
|
47
47
|
flexDirection: 'row',
|
|
48
48
|
justifyContent: 'center', alignItems: 'center', backgroundColor: 'transparent'
|
|
49
49
|
}}
|
|
50
|
-
onPress={()=>{
|
|
50
|
+
onPress={() => {
|
|
51
51
|
setGlobalState("isAppMuted", getGlobalState("isAppMuted") ? false : true);
|
|
52
52
|
}}
|
|
53
53
|
>
|
|
@@ -63,15 +63,15 @@ export default function EventShoppingOverlay(props) {
|
|
|
63
63
|
{
|
|
64
64
|
event.products.map((product, index) => {
|
|
65
65
|
return (
|
|
66
|
-
|
|
66
|
+
index == 0 && <ProductTileV1 setIsModalOpen={props.setIsModalOpen} key={index} onAction={props.onAction} event={event} product={product} />
|
|
67
67
|
);
|
|
68
68
|
})
|
|
69
69
|
}
|
|
70
70
|
</View>
|
|
71
71
|
</View>
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
|
|
74
74
|
</View>
|
|
75
75
|
);
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
}
|
|
@@ -1,95 +1,145 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Text, TouchableOpacity, View, StyleSheet, SafeAreaView, Dimensions } from "react-native";
|
|
3
|
-
import { getGlobalState } from '../../globals/useAppState_APP';
|
|
2
|
+
import { Text, TouchableOpacity, View, StyleSheet, SafeAreaView, Dimensions, ScrollView, FlatList, Animated, Image } from "react-native";
|
|
4
3
|
import Video from 'react-native-video';
|
|
5
|
-
import { useState,
|
|
6
|
-
import
|
|
7
|
-
|
|
4
|
+
import { useState, useRef } from 'react';
|
|
5
|
+
import ChevronRightIcon from '../../icons/icon-components/ChevronRight';
|
|
6
|
+
import ChevronLeftIcon from '../../icons/icon-components/ChevronLeft';
|
|
8
7
|
|
|
9
8
|
export default function EventTileWithProduct(props) {
|
|
9
|
+
const [activeIndex, setActiveIndex] = useState(1);
|
|
10
|
+
const [renderedEvents, setRenderedEvents] = useState(5)
|
|
11
|
+
const { width } = Dimensions.get('window');
|
|
12
|
+
const ITEM_WIDTH = width * 0.33;
|
|
13
|
+
const CARD_HEIGHT = 200;
|
|
10
14
|
|
|
11
|
-
const events = props.events;
|
|
12
|
-
const [renderedEvents, setRenderedEvents] = useState(6);
|
|
13
|
-
const isCarousel = React.useRef(null)
|
|
14
|
-
const videoRef = React.useRef(null);
|
|
15
|
-
|
|
16
|
-
const { width, height } = Dimensions.get('window');
|
|
17
|
-
const SLIDER_WIDTH = width + 75;
|
|
18
|
-
const ITEM_WIDTH = Math.round(SLIDER_WIDTH * 0.3)
|
|
19
|
-
const CARD_HEIGHT = height * 0.2;
|
|
20
15
|
const styles = StyleSheet.create({
|
|
16
|
+
container: {
|
|
17
|
+
position: 'relative',
|
|
18
|
+
width: '100%',
|
|
19
|
+
height: 250,
|
|
20
|
+
},
|
|
21
21
|
cardContainer: {
|
|
22
|
-
|
|
23
|
-
width: ITEM_WIDTH*0.7,
|
|
22
|
+
width: ITEM_WIDTH,
|
|
24
23
|
height: CARD_HEIGHT,
|
|
24
|
+
marginHorizontal: 8,
|
|
25
|
+
top: 20,
|
|
26
|
+
},
|
|
27
|
+
arrowContainerRight: {
|
|
25
28
|
position: 'absolute',
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
top: 90,
|
|
30
|
+
right: 0,
|
|
31
|
+
width: 28,
|
|
32
|
+
height: 28,
|
|
33
|
+
marginHorizontal: 5,
|
|
32
34
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
arrowContainerLeft: {
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
top: 90,
|
|
38
|
+
width: 28,
|
|
39
|
+
height: 28,
|
|
40
|
+
marginHorizontal: 5,
|
|
38
41
|
}
|
|
39
42
|
});
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
const handleClick = (index) => {
|
|
45
|
+
setInitialEventIndex(index);
|
|
46
|
+
setIsModalOpen(true);
|
|
47
|
+
};
|
|
42
48
|
|
|
49
|
+
const { events, isModalOpen, setInitialEventIndex, setIsModalOpen } = props;
|
|
50
|
+
// const [pausedVideos, setPausedVideos] = useState({});
|
|
43
51
|
// const handleVideoLoad = (index) => {
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
// }
|
|
52
|
+
// setPausedVideos((prevState) => ({
|
|
53
|
+
// ...prevState,
|
|
54
|
+
// [index]: true
|
|
55
|
+
// }));
|
|
48
56
|
// };
|
|
49
|
-
const
|
|
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
|
+
};
|
|
50
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
|
+
}
|
|
74
|
+
};
|
|
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
|
+
// },[])
|
|
85
|
+
const renderItem = ({ item, index }) => {
|
|
51
86
|
return (
|
|
52
|
-
<TouchableOpacity onPress={()=>handleClick(
|
|
53
|
-
<View style={styles.cardContainer}>
|
|
87
|
+
<TouchableOpacity onPress={() => handleClick(index)} key={index}>
|
|
88
|
+
<Animated.View style={[styles.cardContainer]}>
|
|
54
89
|
<Video
|
|
55
90
|
ref={videoRef}
|
|
56
|
-
|
|
57
|
-
source={{ uri: item?.thumbnail_image }}
|
|
91
|
+
source={{ uri: item?.thumbnail_image }}
|
|
58
92
|
controls={false}
|
|
59
93
|
repeat
|
|
60
94
|
muted
|
|
61
|
-
|
|
62
|
-
paused={
|
|
95
|
+
resizeMode={"cover"}
|
|
96
|
+
// paused={index !== activeIndex}
|
|
63
97
|
// onLoad={() => handleVideoLoad(index)}
|
|
98
|
+
|
|
99
|
+
style={{
|
|
100
|
+
aspectRatio: 0.5625,
|
|
101
|
+
width: "100%",
|
|
102
|
+
height: '100%',
|
|
103
|
+
borderRadius: 10,
|
|
104
|
+
transform: [{ scale: 1.1 }],
|
|
105
|
+
// elevation: 1
|
|
106
|
+
|
|
107
|
+
}}
|
|
64
108
|
/>
|
|
65
|
-
</View>
|
|
109
|
+
</Animated.View>
|
|
66
110
|
</TouchableOpacity>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function handleClick(props, index) {
|
|
71
|
-
console.log('hello', index)
|
|
72
|
-
props.setInitialEventIndex(index);
|
|
73
|
-
props.setIsModalOpen(true);
|
|
74
|
-
}
|
|
75
|
-
function handleSnapToItem(index) {
|
|
76
|
-
setRenderedEvents(prev => prev+1);
|
|
77
|
-
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
const flatListRef = useRef(null);
|
|
78
114
|
|
|
79
115
|
return (
|
|
80
|
-
<SafeAreaView style={
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
116
|
+
<SafeAreaView style={styles.container}>
|
|
117
|
+
<Animated.FlatList
|
|
118
|
+
horizontal
|
|
119
|
+
style={{paddingLeft: 10}}
|
|
84
120
|
data={events.slice(0,renderedEvents)}
|
|
85
|
-
renderItem={
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
121
|
+
renderItem={renderItem}
|
|
122
|
+
contentInsetAdjustmentBehavior="never"
|
|
123
|
+
decelerationRate="fast"
|
|
124
|
+
scrollEnabled={false}
|
|
125
|
+
automaticallyAdjustContentInsets={false}
|
|
126
|
+
showsHorizontalScrollIndicator={false}
|
|
127
|
+
scrollEventThrottle={16}
|
|
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
|
-
)
|
|
95
|
-
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
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
|
+
// };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Svg, Circle, Path } from 'react-native-svg';
|
|
3
|
+
|
|
4
|
+
const ChevronLeftIcon = ({ width, height, color }) => (
|
|
5
|
+
<Svg width={width} height={height} viewBox="0 0 24 24" fill="none">
|
|
6
|
+
<Circle cx="12" cy="12" r="12" fill="white" />
|
|
7
|
+
<Path d="M15.7071 7.70711C16.0976 7.31658 16.0976 6.68342 15.7071 6.29289C15.3166 5.90237 14.6834 5.90237 14.2929 6.29289L9.29289 11.2929C8.90237 11.6834 8.90237 12.3166 9.29289 12.7071L14.2929 17.7071C14.6834 18.0976 15.3166 18.0976 15.7071 17.7071C16.0976 17.3166 16.0976 16.6834 15.7071 16.2929L11.4142 12L15.7071 7.70711Z" fill={'black'} />
|
|
8
|
+
</Svg>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export default ChevronLeftIcon;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Svg, Circle, Path } from 'react-native-svg'; // Assuming you're using react-native-svg
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const ChevronRightIcon = ({ width, height, color }) => (
|
|
5
|
+
<Svg width={width} height={height} viewBox="0 0 24 24" fill="none">
|
|
6
|
+
<Circle cx="12" cy="12" r="12" fill="white" />
|
|
7
|
+
<Path d="M8.29289 16.2929C7.90237 16.6834 7.90237 17.3166 8.29289 17.7071C8.68342 18.0976 9.31658 18.0976 9.70711 17.7071L14.7071 12.7071C15.0976 12.3166 15.0976 11.6834 14.7071 11.2929L9.70711 6.29289C9.31658 5.90237 8.68342 5.90237 8.29289 6.29289C7.90237 6.68342 7.90237 7.31658 8.29289 7.70711L12.5858 12L8.29289 16.2929Z" fill={'black'} />
|
|
8
|
+
</Svg>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export default ChevronRightIcon;
|