@whatmore-repo/whatmore-reactnative-sdk 1.0.20 → 1.0.21

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.20",
3
+ "version": "1.0.21",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "main": "index.js",
@@ -4,7 +4,7 @@ import { isAppBrew, isAppMaker, isPlobalApps } from "../partners/PartnerUtils.js
4
4
  import { appbrewNavigateToProductPageCommand } from "../partners/appbrew/AppbrewCommands.js";
5
5
 
6
6
  function handleClick(product, props){
7
- props.setModalVisible(false);
7
+ props.setIsModalOpen(false);
8
8
  props.onAction({
9
9
  action: "OPEN_PRODUCT",
10
10
  params:{
@@ -22,7 +22,7 @@ export default function EventClickComponent(props) {
22
22
  {
23
23
  modalUsed
24
24
  ?
25
- <EventsVerticalSwipeView events={props.events} onAction={props.onAction} initialEventIndex={props.initialEventIndex} />
25
+ <EventsVerticalSwipeView setIsModalOpen={props.setIsModalOpen} isModalOpen={props.isModalOpen} events={props.events} onAction={props.onAction} initialEventIndex={props.initialEventIndex} />
26
26
  :
27
27
  <EventsVerticalSwipeViewNoModal events={props.events} initialEventIndex={props.initialEventIndex} />
28
28
  }
@@ -3,6 +3,7 @@ import { Text, TouchableOpacity, View } from "react-native";
3
3
  import { getGlobalState, setGlobalState, useGlobalState } from '../globals/useAppState_APP.js';
4
4
  import AppMuteUnmuteIcon from './commons/AppMuteUnmuteIcon.js';
5
5
  import ProductTileV1 from './product-tiles/ProductTileV1.js';
6
+ import CrossIcon from '../icons/icon-components/CloseIcon.jsx';
6
7
 
7
8
  export default function EventShoppingOverlay(props) {
8
9
  var event = props.event;
@@ -15,16 +16,18 @@ export default function EventShoppingOverlay(props) {
15
16
  }}
16
17
  >
17
18
  {/* <Text style={{fontSize: 20, fontWeight: 'bold'}}> ABCD </Text> */}
18
-
19
- <View
20
- style={{
21
- width: '100%',
22
- height: 'auto',
23
- flexDirection: 'row',
24
- justifyContent: 'flex-end', alignItems: 'center', backgroundColor: 'transparent',
25
- paddingLeft: 10, paddingRight: 10, paddingTop: 10, paddingBottom: 10
26
- }}
27
- >
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
+ </TouchableOpacity>
30
+
28
31
  <AppMuteUnmuteIcon />
29
32
  </View>
30
33
  <View
@@ -60,7 +63,7 @@ export default function EventShoppingOverlay(props) {
60
63
  {
61
64
  event.products.map((product, index) => {
62
65
  return (
63
- index == 0 && <ProductTileV1 key={index} setModalVisible={props.setModalVisible} onAction={props.onAction} event={event} product={product} />
66
+ index == 0 && <ProductTileV1 setIsModalOpen={props.setIsModalOpen} key={index} onAction={props.onAction} event={event} product={product} />
64
67
  );
65
68
  })
66
69
  }
@@ -29,7 +29,7 @@ export default function EventShoppingView(props) {
29
29
  backgroundColor: 'transparent',
30
30
  }}
31
31
  >
32
- <EventShoppingOverlay setModalVisible={props.setModalVisible} event={event} onAction={props.onAction} />
32
+ <EventShoppingOverlay setIsModalOpen={props.setIsModalOpen} event={event} onAction={props.onAction} />
33
33
  </View>
34
34
  </View>
35
35
  );
@@ -7,7 +7,6 @@ import EventShoppingView from './EventShoppingView.js';
7
7
  import { setGlobalState } from '../globals/useAppState_APP.js';
8
8
 
9
9
  export default function EventsVerticalSwipeView(props) {
10
- const [modalVisible, setModalVisible] = React.useState(true);
11
10
  var events = props.events;
12
11
  return (
13
12
  <Modal
@@ -18,10 +17,7 @@ export default function EventsVerticalSwipeView(props) {
18
17
  }}
19
18
  animationType="slide"
20
19
  transparent={false}
21
- visible={modalVisible}
22
- onRequestClose={() => {
23
- setModalVisible(!modalVisible);
24
- }}
20
+ visible={props.isModalOpen}
25
21
  >
26
22
  <Swiper
27
23
  style={{}}
@@ -48,7 +44,7 @@ export default function EventsVerticalSwipeView(props) {
48
44
  backgroundColor: 'transparent'
49
45
  }}
50
46
  >
51
- <EventShoppingView setModalVisible={setModalVisible} onAction={props.onAction} event={event} eventIndex={eventIndex} />
47
+ <EventShoppingView setIsModalOpen={props.setIsModalOpen} onAction={props.onAction} event={event} eventIndex={eventIndex} />
52
48
  </View>
53
49
  )
54
50
  })
@@ -1,10 +1,12 @@
1
- import * as React from 'react';
2
- import { useState, useEffect } from 'react';
3
- import EventClickComponent from "./EventClickComponent";
1
+ import React, { useState, useEffect, lazy } from 'react';
2
+
4
3
  import { WHATMORE_BACKEND_BASE_URL } from '../constants/AppGlobalVars';
5
4
  import { extractEvents, removeInvalidEvents } from '../utils/EventSanityUtils';
6
5
  import { View } from 'react-native';
7
6
 
7
+ const EventTileWithProduct = lazy(() => import('./carousel-view/EventTileWithProduct.js'));
8
+ const EventClickComponent = lazy(() => import('./EventClickComponent'));
9
+
8
10
  const logEventData = false;
9
11
 
10
12
  function logResponse(data, response = '200'){
@@ -30,10 +32,12 @@ function transformEventData(data, brandId){
30
32
  }
31
33
 
32
34
  export default function WhatmoreRootComponent(props) {
35
+ var brandId = props.shopId;
33
36
  const [data, setData] = useState();
34
37
  const [error, setError] = useState();
38
+ const [isModalOpen, setIsModalOpen] = useState(brandId !== '27358003275');
39
+ const [initialEventIndex, setInitialEventIndex] = useState(0)
35
40
 
36
- var brandId = props.shopId;
37
41
  var eventStatuses = "live,upcoming";
38
42
  var isActive = "true";
39
43
 
@@ -50,9 +54,9 @@ export default function WhatmoreRootComponent(props) {
50
54
  + '&is_active=' + isActive.toString();
51
55
  fetch(url)
52
56
  .then((response) => response.json())
53
- .then((data) => {
54
- return extractEvents(data, false);
55
- })
57
+ // .then((data) => {
58
+ // return extractEvents(data, false);
59
+ // })
56
60
  .then((data) => {
57
61
  logEventData && console.log("initial received events size : " + data.length);
58
62
  return removeInvalidEvents(data, brandId);
@@ -79,11 +83,14 @@ export default function WhatmoreRootComponent(props) {
79
83
  }
80
84
 
81
85
  logEventData && logResponse(data);
82
- transformEventData(data, brandId);
86
+ // transformEventData(data, brandId);
83
87
  logEventData && console.log("final transformed events data : " + JSON.stringify(data));
84
88
  logEventData && console.log("valid events size : " + data.length);
85
89
 
86
90
  return (
87
- <EventClickComponent events={data} initialEventIndex={0} onAction={props.onAction} />
91
+ <>
92
+ {brandId == '27358003275' && <EventTileWithProduct isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen} events={data} setInitialEventIndex={setInitialEventIndex} />}
93
+ {(isModalOpen || brandId !== '27358003275') && <EventClickComponent isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen} events={data} initialEventIndex={initialEventIndex} onAction={props.onAction} /> }
94
+ </>
88
95
  );
89
96
  }
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
- import { Text, TouchableOpacity, View, StyleSheet, Image, SafeAreaView, FlatList, Dimensions } from "react-native";
2
+ import { Text, TouchableOpacity, View, StyleSheet, SafeAreaView, Dimensions } from "react-native";
3
3
  import { getGlobalState } from '../../globals/useAppState_APP';
4
- import Swiper from 'react-native-swiper';
5
4
  import Video from 'react-native-video';
6
5
  import { useState, useEffect } from 'react';
7
6
  import Carousel from 'react-native-snap-carousel'
@@ -10,94 +9,90 @@ import Carousel from 'react-native-snap-carousel'
10
9
  export default function EventTileWithProduct(props) {
11
10
 
12
11
  const events = props.events;
13
- const { width } = Dimensions.get('window');
12
+ const [renderedEvents, setRenderedEvents] = useState(6);
14
13
  const isCarousel = React.useRef(null)
15
- const SLIDER_WIDTH = Dimensions.get('window').width + 80
16
- const ITEM_WIDTH = Math.round(SLIDER_WIDTH * 0.7)
14
+ const videoRef = React.useRef(null);
17
15
 
18
- function handleClick(props, index){
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
+ const styles = StyleSheet.create({
21
+ cardContainer: {
22
+ borderRadius: 30,
23
+ width: ITEM_WIDTH*0.7,
24
+ height: CARD_HEIGHT,
25
+ position: 'absolute',
26
+ borderRadius: 30,
27
+ elevation: 3,
28
+
29
+ top: 40,
30
+ transform: [{ scale: 1.3 }],
31
+
32
+ },
33
+ video: {
34
+ width: '100%',
35
+ height: '100%',
36
+ borderRadius: 10,
37
+ elevation: 8
38
+ }
39
+ });
40
+
41
+ // const [currentIndex, setCurrentIndex] = useState(1);
42
+
43
+ // const handleVideoLoad = (index) => {
44
+ // if (index !== currentIndex && videoRef.current) {
45
+ // videoRef.current.setNativeProps({ paused: false });
46
+
47
+ // }
48
+ // };
49
+ const CarouselCardItem = ({ item, index }) => {
50
+
51
+ return (
52
+ <TouchableOpacity onPress={()=>handleClick(props, index)} key={index}>
53
+ <View style={styles.cardContainer}>
54
+ <Video
55
+ ref={videoRef}
56
+
57
+ source={{ uri: item?.thumbnail_image }}
58
+ controls={false}
59
+ repeat
60
+ muted
61
+ style={styles.video}
62
+ // paused={!isFocused}
63
+ // onLoad={() => handleVideoLoad(index)}
64
+ />
65
+ </View>
66
+ </TouchableOpacity>
67
+ )
68
+ }
69
+
70
+ function handleClick(props, index) {
19
71
  console.log('hello', index)
20
72
  props.setInitialEventIndex(index);
21
73
  props.setIsModalOpen(true);
22
74
  }
75
+ function handleSnapToItem(index) {
76
+ setRenderedEvents(prev => prev+1);
77
+ }
78
+
23
79
  return (
24
80
  <SafeAreaView style={{
25
81
  width: '100%',
26
- height: '100%'
82
+ height: '100%',
27
83
  }}>
28
- <View>
29
- <Carousel
30
- layout="tinder"
31
- layoutCardOffset={9}
32
- ref={isCarousel}
33
- // data={data}
34
- // renderItem={CarouselCardItem}
35
- sliderWidth={SLIDER_WIDTH}
36
- itemWidth={ITEM_WIDTH}
37
- inactiveSlideShift={0}
38
- useScrollView={true}
39
- />
40
- </View>
41
- {/* <View
42
- style={{
43
- flex: 1,
44
- height: '100%',
45
- width: '100%'
46
- }}
47
- >
48
- <FlatList
49
- data={events}
50
- horizontal
51
- keyExtractor={(item, index) => index.toString()}
52
- renderItem={({ item, index }) => (
53
- <TouchableOpacity onPress={()=>handleClick(props, index)} style={{ width: width / 2.5, height: width / 2 }}>
54
- <Video
55
- source={{ uri: item.thumbnail_image }}
56
- style={{ width: '100%', height: '100%' }}
57
- controls={false}
58
- muted
59
- repeat
60
- />
61
- </TouchableOpacity>
62
- )}
63
- /> */}
64
- {/* <Swiper horizontal={true}
65
- style={{}}
66
-
67
- loop={true}
68
- showsPagination={false}
69
- loadMinimal={true}
70
- loadMinimalSize={1}
71
- >
72
- {
73
- events.map((event, index) => {
74
- // console.log(event.thumbnail_image,'p')
75
- return (
76
- <View
77
- key={index}
78
- style={{
79
- width: '100%', height: '100%', backgroundColor: 'gray'
80
- }}
81
- >
82
- <Video source = {{uri: event.thumbnail_image}}
83
- style={{
84
- position: 'absolute',
85
- top: 0,
86
- left: 0,
87
- bottom: 0,
88
- right: 0,
89
- width: '100%', height: '100%'
90
- }}
91
- />
92
-
93
- </View>
94
- )
95
- })
96
- }
97
- </Swiper> */}
98
- {/* </View> */}
84
+ <Carousel
85
+ layout="default"
86
+ ref={isCarousel}
87
+ data={events.slice(0,renderedEvents)}
88
+ renderItem={CarouselCardItem}
89
+ sliderWidth={SLIDER_WIDTH}
90
+ itemWidth={ITEM_WIDTH}
91
+ inactiveSlideShift={-15}
92
+ firstItem={1}
93
+ useScrollView={true}
94
+ onSnapToItem={handleSnapToItem}
95
+ />
99
96
  </SafeAreaView>
100
97
  )
101
-
102
- }
103
-
98
+ }
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import Svg, {Line} from 'react-native-svg';
3
+
4
+ function CrossIcon({size = 24, color = 'white' }) {
5
+ return (
6
+ <Svg height={size} width={size} viewBox="0 0 24 24">
7
+ <Line x1="1" y1="1" x2="23" y2="23" stroke={color} strokeWidth="2" />
8
+ <Line x1="23" y1="1" x2="1" y2="23" stroke={color} strokeWidth="2" />
9
+ </Svg>
10
+ );
11
+ }
12
+
13
+ export default CrossIcon;