@whatmore-repo/whatmore-reactnative-sdk 1.0.16 → 1.0.18

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/index.js CHANGED
@@ -24,7 +24,7 @@ export function WhatmoreBase(props){
24
24
  // );
25
25
 
26
26
  return (
27
- <WhatmoreRootComponent shopId={props.shopId} />
27
+ <WhatmoreRootComponent shopId={props.shopId} onAction={props.onAction} />
28
28
  );
29
29
  }
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatmore-repo/whatmore-reactnative-sdk",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "main": "index.js",
@@ -22,7 +22,7 @@ export default function EventClickComponent(props) {
22
22
  {
23
23
  modalUsed
24
24
  ?
25
- <EventsVerticalSwipeView events={props.events} initialEventIndex={props.initialEventIndex} />
25
+ <EventsVerticalSwipeView events={props.events} onAction={props.onAction} initialEventIndex={props.initialEventIndex} />
26
26
  :
27
27
  <EventsVerticalSwipeViewNoModal events={props.events} initialEventIndex={props.initialEventIndex} />
28
28
  }
@@ -60,7 +60,7 @@ export default function EventShoppingOverlay(props) {
60
60
  {
61
61
  event.products.map((product, index) => {
62
62
  return (
63
- index == 0 && <ProductTileV1 key={index} event={event} product={product} />
63
+ index == 0 && <ProductTileV1 key={index} setModalVisible={props.setModalVisible} onAction={props.onAction} event={event} product={product} />
64
64
  );
65
65
  })
66
66
  }
@@ -3,20 +3,25 @@ import { View } from "react-native";
3
3
  import AppVideoPlayer from './video-player/AppVideoPlayer.js'
4
4
  import { useGlobalState } from '../globals/useAppState_APP.js';
5
5
  import EventShoppingOverlay from './EventShoppingOverlay.js';
6
+ import { useState, useEffect } from 'react';
6
7
 
7
8
  export default function EventShoppingView(props) {
8
9
  const [activeSwiperIndex, setActiveSwiperIndex] = useGlobalState('verticalSwiperViewActiveIndex');
9
-
10
+ const [isLoading, setIsLoading] = useState(true);
10
11
  var event = props.event;
11
12
  var eventIndex = props.eventIndex;
12
-
13
+ useEffect(()=>{
14
+ setIsLoading(true);
15
+ }, [activeSwiperIndex])
13
16
  return (
14
17
  <View
15
18
  style={{
16
- width: '100%', height: '100%'
19
+ width: '100%', height: '100%', backgroundColor: 'gray'
17
20
  }}
18
21
  >
19
- <AppVideoPlayer videoUrl={event.event_hls_url} isMuted={activeSwiperIndex != eventIndex} />
22
+ <AppVideoPlayer videoUrl={event.event_hls_url} isMuted={activeSwiperIndex != eventIndex}
23
+ isLoading={isLoading} setIsLoading={setIsLoading}
24
+ />
20
25
  <View
21
26
  style={{
22
27
  width: '100%', height: '100%',
@@ -24,7 +29,7 @@ export default function EventShoppingView(props) {
24
29
  backgroundColor: 'transparent',
25
30
  }}
26
31
  >
27
- <EventShoppingOverlay event={event} />
32
+ <EventShoppingOverlay setModalVisible={props.setModalVisible} event={event} onAction={props.onAction} />
28
33
  </View>
29
34
  </View>
30
35
  );
@@ -5,16 +5,10 @@ import Swiper from 'react-native-swiper'
5
5
  import { InView } from 'react-native-intersection-observer'
6
6
  import EventShoppingView from './EventShoppingView.js';
7
7
  import { setGlobalState } from '../globals/useAppState_APP.js';
8
- import {handleAction} from '@appmaker-xyz/react-native';
9
8
 
10
9
  export default function EventsVerticalSwipeView(props) {
11
10
  const [modalVisible, setModalVisible] = React.useState(true);
12
11
  var events = props.events;
13
- function customAction(){
14
- handleAction({
15
- action: "OPEN_WHATMORE_SHOPPABLE"
16
- })
17
- }
18
12
  return (
19
13
  <Modal
20
14
  style={{
@@ -23,7 +17,7 @@ export default function EventsVerticalSwipeView(props) {
23
17
  width: '100%'
24
18
  }}
25
19
  animationType="slide"
26
- transparent={true}
20
+ transparent={false}
27
21
  visible={modalVisible}
28
22
  onRequestClose={() => {
29
23
  setModalVisible(!modalVisible);
@@ -38,7 +32,6 @@ export default function EventsVerticalSwipeView(props) {
38
32
  loadMinimalSize={1}
39
33
  index={props.initialEventIndex}
40
34
  onIndexChanged={(index) => {
41
- customAction()
42
35
  setGlobalState('verticalSwiperViewActiveIndex', index);
43
36
  }}
44
37
 
@@ -55,7 +48,7 @@ export default function EventsVerticalSwipeView(props) {
55
48
  backgroundColor: 'transparent'
56
49
  }}
57
50
  >
58
- <EventShoppingView event={event} eventIndex={eventIndex} />
51
+ <EventShoppingView setModalVisible={setModalVisible} onAction={props.onAction} event={event} eventIndex={eventIndex} />
59
52
  </View>
60
53
  )
61
54
  })
@@ -84,6 +84,6 @@ export default function WhatmoreRootComponent(props) {
84
84
  logEventData && console.log("valid events size : " + data.length);
85
85
 
86
86
  return (
87
- <EventClickComponent events={data} initialEventIndex={0} />
87
+ <EventClickComponent events={data} initialEventIndex={0} onAction={props.onAction} />
88
88
  );
89
89
  }
@@ -0,0 +1,50 @@
1
+ import { getGlobalState } from "../../globals/useAppState_APP";
2
+ import { Text, TouchableOpacity, View } from "react-native";
3
+
4
+ function ShopNow(props){
5
+ const whatmorePrimaryColor = getGlobalState('whatmorePrimaryColor');
6
+ const whatmorePrimaryFont = getGlobalState('whatmorePrimaryFont');
7
+
8
+ const onClick = props.onClick;
9
+ const height = props.height;
10
+
11
+ const BOX_PADDING = 2;
12
+
13
+ return (
14
+ <TouchableOpacity
15
+ style={{
16
+ width: '100%',
17
+ height: height,
18
+ padding: BOX_PADDING,
19
+ backgroundColor: whatmorePrimaryColor
20
+ }}
21
+ onPress={(e) => {
22
+ e.stopPropagation();
23
+ onClick();
24
+ }}
25
+ >
26
+ <View
27
+ style={{
28
+ width: '100%',
29
+ height: '100%',
30
+ alignItems: 'center',
31
+ justifyContent: 'center',
32
+ // paddingVertical: 5
33
+ }}
34
+ >
35
+ <Text
36
+ style={{
37
+ fontSize: props.fontSize,
38
+ fontWeight: 'bold',
39
+ fontFamily: whatmorePrimaryFont,
40
+ color: 'white'
41
+ }}
42
+ >
43
+ &nbsp;{"SHOP NOW"}&nbsp;
44
+ </Text>
45
+ </View>
46
+ </TouchableOpacity>
47
+ );
48
+ }
49
+
50
+ export default ShopNow
@@ -1,35 +1,19 @@
1
- import { getGlobalState, setGlobalState, useGlobalState } from '../../globals/useAppState_APP.js';
1
+ import { getGlobalState } from '../../globals/useAppState_APP.js';
2
2
  import { Image, Text} from 'react-native';
3
3
  import ProductPriceBadge from './ProductPriceBadge.js';
4
4
 
5
- import React, { useEffect, useRef, useState } from 'react';
6
- import { View, TouchableOpacity, ScrollView, Dimensions, TouchableWithoutFeedback } from 'react-native';
7
- import SelectVariantComponent from './SelectVariantComponent';
5
+ import React, { useEffect, useState } from 'react';
6
+ import { View, Dimensions, TouchableWithoutFeedback } from 'react-native';
8
7
  import useAddToCartStates from '../../hooks/useAddToCartStates.js';
9
- import AddToCartButton from '../cta-buttons/AddToCartButton.jsx';
10
8
  import * as Animatable from 'react-native-animatable';
11
- import { navigateToProductPage } from '../../api/navigation-commands/NavigationCommands.js';
12
- import {handleAction} from '@appmaker-xyz/react-native';
9
+ import ShopNow from '../cta-buttons/ShopNowButton.jsx';
13
10
 
14
11
  export default function ProductTileV1(props) {
15
12
  const event = props.event;
16
13
  const product = props.product;
17
-
18
- const [cartState, productVariantOptions, initiateVariantSelection, initiateAtcApiCall, getPriceDetailsFromSelectedOption, initiateAtcCartIconClickAction] = useAddToCartStates(0, product, props.event);
19
- const [selectedOptions, setSelectedOptions] = useState(null);
20
14
  const [tileTapAnimate, setTileTapAnimate] = useState(false);
21
-
22
- const [productVariantPrice, setProductVariantPrice] = useState(parseFloat(product.price));
23
- const [productVariantComparePrice, setProductVariantComparePrice] = useState(parseFloat(product.compare_price));
24
-
25
- const whatmorePrimaryColor = getGlobalState('whatmorePrimaryColor');
26
15
  const whatmorePrimaryFont = getGlobalState('whatmorePrimaryFont');
27
-
28
- const brandDomainContext = getGlobalState('brandDomainContext');
29
- const whatmoreShopId = getGlobalState('whatmoreShopId');
30
-
31
16
  const PRODUCT_TILE_TOTAL_HEIGHT = Dimensions.get('window').height * 0.2;
32
- const SELECT_VARIANT_TILE_HEIGHT_FACTOR = 3.0;
33
17
  const BASE_FONT_SIZE = 20;
34
18
 
35
19
  useEffect(() => {
@@ -40,22 +24,14 @@ export default function ProductTileV1(props) {
40
24
  }
41
25
  }, [tileTapAnimate]);
42
26
 
43
- function _updateSelectedOptions(_selectedOptions){
44
- setSelectedOptions(_selectedOptions);
45
-
46
- // set price to selected option
47
- const optionPriceDetails = getPriceDetailsFromSelectedOption(_selectedOptions);
48
27
 
49
- if(optionPriceDetails){
50
- setProductVariantPrice(optionPriceDetails['price']);
51
- setProductVariantComparePrice(optionPriceDetails['compare_price']);
52
- }
53
- }
54
28
  function handleClick(){
55
- handleAction({
29
+ console.log('click')
30
+ props.setModalVisible(false);
31
+ props.onAction({
56
32
  action: "OPEN_PRODUCT",
57
33
  params:{
58
- productId: 'gid://shopify/Product/' + product.client_product_id
34
+ productId: 'gid://shopify/Product/7600010723466'
59
35
  }
60
36
  })
61
37
  }
@@ -63,7 +39,7 @@ export default function ProductTileV1(props) {
63
39
  <TouchableWithoutFeedback
64
40
  onPress={() => {
65
41
  setTileTapAnimate(true);
66
- navigateToProductPage(product, brandDomainContext, whatmoreShopId);
42
+ // navigateToProductPage(product, brandDomainContext, whatmoreShopId);
67
43
  handleClick();
68
44
  }}
69
45
  >
@@ -88,7 +64,9 @@ export default function ProductTileV1(props) {
88
64
  duration={100} iterationCount={1}
89
65
  easing="ease-out"
90
66
  style={{
91
- width: '100%', height: 'auto',
67
+ width: '90%', // Adjust width as needed, e.g., '80%'
68
+ alignSelf: 'center',
69
+ height: 'auto',
92
70
  flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'center',
93
71
  borderRadius: 5, overflow: 'hidden',
94
72
  shadowColor: 'black', shadowOpacity: 1, shadowOffset: {width: 0, height: 0},
@@ -128,7 +106,7 @@ export default function ProductTileV1(props) {
128
106
 
129
107
  fontWeight: 'normal',
130
108
  fontFamily: whatmorePrimaryFont,
131
- fontSize: BASE_FONT_SIZE * 1,
109
+ fontSize: BASE_FONT_SIZE * 0.9,
132
110
  color: 'black',
133
111
  overflow: 'hidden',
134
112
 
@@ -143,10 +121,7 @@ export default function ProductTileV1(props) {
143
121
  }}
144
122
  ></View>
145
123
 
146
- <ProductPriceBadge product={product} event={event} fontSize={BASE_FONT_SIZE * 1} color={'black'} />
147
- {/* <Text>
148
- {product.price.toString()}
149
- </Text> */}
124
+ <ProductPriceBadge product={product} event={event} fontSize={BASE_FONT_SIZE * 0.9} color={'black'} />
150
125
  </View>
151
126
 
152
127
 
@@ -155,59 +130,18 @@ export default function ProductTileV1(props) {
155
130
  <View
156
131
  style={{
157
132
  width: '100%', height: 'auto',
158
- backgroundColor: '#ffffffdd',
133
+ backgroundColor: '#fff',
159
134
  overflow: 'hidden'
160
135
  }}
161
136
 
162
137
  >
163
- {cartState['state'] === "awaitingVariantSelection" && productVariantOptions &&
164
- <ScrollView
165
- style={{
166
- width: '100%',
167
- height: 'auto',
168
- marginTop: 5,
169
- marginBottom: 10,
170
- maxHeight: PRODUCT_TILE_TOTAL_HEIGHT * SELECT_VARIANT_TILE_HEIGHT_FACTOR
171
- }}
172
- >
173
- <Animatable.View
174
- animation="fadeIn"
175
- duration={500} iterationCount={1}
176
- easing="ease-in-out"
177
- style={{
178
- height: 'auto', width: '100%'
179
- }}
180
- >
181
- <SelectVariantComponent
182
- width='100%'
183
- height='auto'
184
- event={event}
185
- product={product}
186
- productVariantOptions={productVariantOptions}
187
- baseFontSize={BASE_FONT_SIZE * 0.9}
188
- onOptionSelected={_updateSelectedOptions}
189
- />
190
- </Animatable.View>
191
- </ScrollView>
192
- }
193
138
 
194
- <View style={{ flexDirection: 'row', width: '100%', justifyContent: 'center', alignItems: 'center' }}>
195
- <AddToCartButton
196
- baseFontSize={BASE_FONT_SIZE * 0.3}
197
- event={event}
198
- product={product}
199
- cartState={cartState['state']}
200
- cartCount={cartState['cart_count']}
201
- onClickAtc={(e) => {
202
- if(cartState['state'] == "init"){
203
- initiateVariantSelection();
204
- } else if(cartState['state'] == "awaitingVariantSelection"){
205
- initiateAtcApiCall(selectedOptions);
206
- }
207
- }}
208
- onCartIconClick={initiateAtcCartIconClickAction}
139
+ <View style={{ flexDirection: 'row', width: '100%', justifyContent: 'center', alignItems: 'center'}}>
140
+ <ShopNow
209
141
  height={PRODUCT_TILE_TOTAL_HEIGHT * 0.3}
210
- />
142
+ onClick={handleClick}
143
+ fontSize={BASE_FONT_SIZE*1.1}
144
+ />
211
145
  </View>
212
146
  </View>
213
147
  </Animatable.View>
@@ -1,26 +1,42 @@
1
1
  import * as React from 'react';
2
+ import {View} from 'react-native';
3
+ import { ActivityIndicator } from 'react-native';
2
4
  import { useGlobalState } from '../../globals/useAppState_APP';
3
5
  import Video from 'react-native-video';
4
6
 
5
7
  export default function AppVideoPlayer(props) {
6
8
  const video = React.useRef(null);
7
9
  const [isAppMuted] = useGlobalState("isAppMuted");
8
-
10
+
11
+ const handleLoad = () => {
12
+ props.setIsLoading(false);
13
+ }
9
14
  return (
10
- <Video
11
- source={{uri: props.videoUrl}}
12
- ref={video}
13
- muted={isAppMuted ? true : props.isMuted}
14
- controls={false}
15
- resizeMode='cover'
16
- style={{
17
- position: 'absolute',
18
- top: 0,
19
- left: 0,
20
- bottom: 0,
21
- right: 0,
22
- width: '100%', height: '100%'
23
- }}
24
- />
15
+ <>
16
+ {props.isLoading && (
17
+ <View style={{ position: 'absolute',
18
+ top: '42%',
19
+ width: '100%', height: '100%'}}>
20
+ <ActivityIndicator size="large" color="#fff" />
21
+ </View>
22
+ )}
23
+ <Video
24
+ source={{uri: props.videoUrl}}
25
+ ref={video}
26
+ repeat
27
+ muted={isAppMuted ? true : props.isMuted}
28
+ controls={false}
29
+ resizeMode='cover'
30
+ style={{
31
+ position: 'absolute',
32
+ top: 0,
33
+ left: 0,
34
+ bottom: 0,
35
+ right: 0,
36
+ width: '100%', height: '100%'
37
+ }}
38
+ onLoad={handleLoad}
39
+ />
40
+ </>
25
41
  )
26
42
  }