@whatmore-repo/whatmore-reactnative-sdk 1.0.11 → 1.0.12

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.
Files changed (36) hide show
  1. package/commands.txt +45 -38
  2. package/index.js +31 -31
  3. package/package.json +29 -29
  4. package/pre-integration-steps.txt +2 -2
  5. package/src/api/cart-commands/CartCommands.js +26 -26
  6. package/src/api/navigation-commands/NavigationCommands.js +16 -16
  7. package/src/api/partners/PartnerUtils.js +10 -10
  8. package/src/api/partners/appbrew/AppbrewCommands.js +26 -26
  9. package/src/api/product-details-commands/ProductDetailsCommands.js +389 -389
  10. package/src/api/shopify-commands/ShopifyCommands.js +28 -28
  11. package/src/api/whatmore-backend/WhatmoreMetricCommands.js +159 -159
  12. package/src/components/EventClickComponent.js +30 -30
  13. package/src/components/EventShoppingOverlay.js +74 -74
  14. package/src/components/EventShoppingView.js +31 -31
  15. package/src/components/EventsVerticalSwipeView.js +59 -59
  16. package/src/components/EventsVerticalSwipeViewNoModal.js +51 -51
  17. package/src/components/WhatmoreRootComponent.js +88 -88
  18. package/src/components/commons/AppMuteUnmuteIcon.js +35 -35
  19. package/src/components/cta-buttons/AddToCartButton.jsx +345 -345
  20. package/src/components/product-tiles/ProductPriceBadge.js +51 -51
  21. package/src/components/product-tiles/ProductTileV1.js +204 -204
  22. package/src/components/product-tiles/SelectVariantComponent.js +116 -116
  23. package/src/components/video-player/AppVideoPlayer.js +25 -25
  24. package/src/constants/AppGlobalVars.js +12 -12
  25. package/src/globals/useAppState_APP.js +17 -17
  26. package/src/hooks/useAddToCartStates.js +194 -194
  27. package/src/{components/icons → icons}/icon-components/CartIcon.jsx +26 -26
  28. package/src/{components/icons → icons}/icon-components/LoadingIcon.jsx +17 -17
  29. package/src/{components/icons → icons}/icon-components/MuteIcon.jsx +22 -22
  30. package/src/{components/icons → icons}/icon-components/PlusIcon.jsx +26 -26
  31. package/src/{components/icons → icons}/icon-components/UnmuteIcon.jsx +22 -22
  32. package/src/{components/icons → icons}/svg-utils.txt +6 -6
  33. package/src/utils/ColorUtils.js +39 -39
  34. package/src/utils/EventSanityUtils.js +21 -21
  35. package/src/utils/PriceUtils.js +27 -27
  36. package/src/utils/ProductUtils.js +5 -5
@@ -1,52 +1,52 @@
1
- import * as React from 'react';
2
- import { useGlobalState } from '../../globals/useAppState_APP.js';
3
- import { Text, View } from 'react-native';
4
- import { getPriceStringWithCurrency } from '../../utils/PriceUtils.js';
5
-
6
- export default function ProductPriceBadge(props) {
7
- const event = props.event;
8
- const product = props.product;
9
- const fontSize = props.fontSize;
10
- const color = props.color;
11
-
12
- return (
13
- <View
14
- style={{
15
- width: 'auto', height: 'auto',
16
- backgroundColor: '#00000022',
17
- flexDirection: 'row',
18
- justifyContent: 'space-between', alignItems: 'center',
19
- borderRadius: 20, overflow: 'hidden',
20
- paddingLeft: 10, paddingRight: 10, paddingTop: 5, paddingBottom: 5
21
- }}
22
- >
23
- <Text
24
- numberOfLines={1}
25
- style={{
26
- fontWeight: 'bold',
27
- fontSize: fontSize,
28
- color: color
29
- }}
30
- >
31
- {getPriceStringWithCurrency(product.price)}
32
- </Text>
33
- <Text
34
- numberOfLines={1}
35
- >
36
- {' '}
37
- </Text>
38
- <Text
39
- numberOfLines={1}
40
- style={{
41
- fontWeight: 'normal',
42
- textDecorationLine: 'line-through',
43
- fontSize: fontSize
44
- }}
45
- >
46
- {getPriceStringWithCurrency(product.compare_price)}
47
- </Text>
48
-
49
- </View>
50
- );
51
-
1
+ import * as React from 'react';
2
+ import { useGlobalState } from '../../globals/useAppState_APP.js';
3
+ import { Text, View } from 'react-native';
4
+ import { getPriceStringWithCurrency } from '../../utils/PriceUtils.js';
5
+
6
+ export default function ProductPriceBadge(props) {
7
+ const event = props.event;
8
+ const product = props.product;
9
+ const fontSize = props.fontSize;
10
+ const color = props.color;
11
+
12
+ return (
13
+ <View
14
+ style={{
15
+ width: 'auto', height: 'auto',
16
+ backgroundColor: '#00000022',
17
+ flexDirection: 'row',
18
+ justifyContent: 'space-between', alignItems: 'center',
19
+ borderRadius: 20, overflow: 'hidden',
20
+ paddingLeft: 10, paddingRight: 10, paddingTop: 5, paddingBottom: 5
21
+ }}
22
+ >
23
+ <Text
24
+ numberOfLines={1}
25
+ style={{
26
+ fontWeight: 'bold',
27
+ fontSize: fontSize,
28
+ color: color
29
+ }}
30
+ >
31
+ {getPriceStringWithCurrency(product.price)}
32
+ </Text>
33
+ <Text
34
+ numberOfLines={1}
35
+ >
36
+ {' '}
37
+ </Text>
38
+ <Text
39
+ numberOfLines={1}
40
+ style={{
41
+ fontWeight: 'normal',
42
+ textDecorationLine: 'line-through',
43
+ fontSize: fontSize
44
+ }}
45
+ >
46
+ {getPriceStringWithCurrency(product.compare_price)}
47
+ </Text>
48
+
49
+ </View>
50
+ );
51
+
52
52
  }
@@ -1,205 +1,205 @@
1
- import { getGlobalState, setGlobalState, useGlobalState } from '../../globals/useAppState_APP.js';
2
- import { Image, Text} from 'react-native';
3
- import ProductPriceBadge from './ProductPriceBadge.js';
4
-
5
- import React, { useEffect, useRef, useState } from 'react';
6
- import { View, TouchableOpacity, ScrollView, Dimensions, TouchableWithoutFeedback } from 'react-native';
7
- import SelectVariantComponent from './SelectVariantComponent';
8
- import useAddToCartStates from '../../hooks/useAddToCartStates.js';
9
- import AddToCartButton from '../cta-buttons/AddToCartButton.jsx';
10
- import * as Animatable from 'react-native-animatable';
11
- import { navigateToProductPage } from '../../api/navigation-commands/NavigationCommands.js';
12
-
13
- export default function ProductTileV1(props) {
14
- const event = props.event;
15
- const product = props.product;
16
-
17
- const [cartState, productVariantOptions, initiateVariantSelection, initiateAtcApiCall, getPriceDetailsFromSelectedOption, initiateAtcCartIconClickAction] = useAddToCartStates(0, product, props.event);
18
- const [selectedOptions, setSelectedOptions] = useState(null);
19
- const [tileTapAnimate, setTileTapAnimate] = useState(false);
20
-
21
- const [productVariantPrice, setProductVariantPrice] = useState(parseFloat(product.price));
22
- const [productVariantComparePrice, setProductVariantComparePrice] = useState(parseFloat(product.compare_price));
23
-
24
- const whatmorePrimaryColor = getGlobalState('whatmorePrimaryColor');
25
- const whatmorePrimaryFont = getGlobalState('whatmorePrimaryFont');
26
-
27
- const brandDomainContext = getGlobalState('brandDomainContext');
28
- const whatmoreShopId = getGlobalState('whatmoreShopId');
29
-
30
- const PRODUCT_TILE_TOTAL_HEIGHT = Dimensions.get('window').height * 0.2;
31
- const SELECT_VARIANT_TILE_HEIGHT_FACTOR = 3.0;
32
- const BASE_FONT_SIZE = 20;
33
-
34
- useEffect(() => {
35
- if(tileTapAnimate){
36
- setTimeout(() => {
37
- setTileTapAnimate(false);
38
- }, 1000);
39
- }
40
- }, [tileTapAnimate]);
41
-
42
- function _updateSelectedOptions(_selectedOptions){
43
- setSelectedOptions(_selectedOptions);
44
-
45
- // set price to selected option
46
- const optionPriceDetails = getPriceDetailsFromSelectedOption(_selectedOptions);
47
-
48
- if(optionPriceDetails){
49
- setProductVariantPrice(optionPriceDetails['price']);
50
- setProductVariantComparePrice(optionPriceDetails['compare_price']);
51
- }
52
- }
53
-
54
-
55
- return (
56
- <TouchableWithoutFeedback
57
- onPress={() => {
58
- setTileTapAnimate(true);
59
- navigateToProductPage(product, brandDomainContext, whatmoreShopId);
60
- }}
61
- >
62
- <Animatable.View
63
- animation={
64
- tileTapAnimate
65
- ?
66
- {
67
- 0: {
68
- scale: 1
69
- },
70
- 0.5: {
71
- scale: 0.9
72
- },
73
- 1: {
74
- scale: 1
75
- }
76
- }
77
- :
78
- null
79
- }
80
- duration={100} iterationCount={1}
81
- easing="ease-out"
82
- style={{
83
- width: '100%', height: 'auto',
84
- flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'center',
85
- overflow: 'hidden',
86
- borderRadius: 5, overflow: 'hidden',
87
- shadowColor: 'black', shadowOpacity: 1, shadowOffset: {width: 0, height: 0},
88
- shadowRadius: 20, elevation: 10
89
- }}
90
- >
91
- <View
92
- style={{
93
- width: '100%', height: 'auto',
94
- backgroundColor: '#ffffffdd',
95
- flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center'
96
- }}
97
- >
98
- <Image
99
- style={{
100
- width: 120, height: 120
101
- }}
102
- source={{
103
- uri: product.thumbnail_image,
104
- }}
105
- >
106
-
107
- </Image>
108
- <View
109
- style={{
110
- width: 'auto', height: 'auto',
111
- flexDirection: 'column', justifyContent: 'space-between', alignItems: 'flex-start',
112
- paddingLeft: 10, paddingRight: 10
113
- }}
114
- >
115
- <Text
116
- numberOfLines={2}
117
- ellipsizeMode='tail'
118
- style={{
119
- fontWeight: 'normal',
120
- fontFamily: whatmorePrimaryFont,
121
- fontSize: BASE_FONT_SIZE * 1,
122
- color: 'black'
123
- }}
124
- >
125
- {product.title.toString()}
126
- </Text>
127
-
128
- <View
129
- style={{
130
- height: 10, width: 'auto'
131
- }}
132
- ></View>
133
-
134
- <ProductPriceBadge product={product} event={event} fontSize={BASE_FONT_SIZE * 1} color={'black'} />
135
- {/* <Text>
136
- {product.price.toString()}
137
- </Text> */}
138
- </View>
139
-
140
-
141
- </View>
142
-
143
- <View
144
- style={{
145
- width: '100%', height: 'auto',
146
- backgroundColor: '#ffffffdd',
147
- overflow: 'hidden'
148
- }}
149
-
150
- >
151
- {cartState['state'] === "awaitingVariantSelection" && productVariantOptions &&
152
- <ScrollView
153
- style={{
154
- width: '100%',
155
- height: 'auto',
156
- marginTop: 5,
157
- marginBottom: 10,
158
- maxHeight: PRODUCT_TILE_TOTAL_HEIGHT * SELECT_VARIANT_TILE_HEIGHT_FACTOR
159
- }}
160
- >
161
- <Animatable.View
162
- animation="fadeIn"
163
- duration={500} iterationCount={1}
164
- easing="ease-in-out"
165
- style={{
166
- height: 'auto', width: '100%'
167
- }}
168
- >
169
- <SelectVariantComponent
170
- width='100%'
171
- height='auto'
172
- event={event}
173
- product={product}
174
- productVariantOptions={productVariantOptions}
175
- baseFontSize={BASE_FONT_SIZE * 0.9}
176
- onOptionSelected={_updateSelectedOptions}
177
- />
178
- </Animatable.View>
179
- </ScrollView>
180
- }
181
-
182
- <View style={{ flexDirection: 'row', width: '100%', justifyContent: 'center', alignItems: 'center' }}>
183
- <AddToCartButton
184
- baseFontSize={BASE_FONT_SIZE * 0.3}
185
- event={event}
186
- product={product}
187
- cartState={cartState['state']}
188
- cartCount={cartState['cart_count']}
189
- onClickAtc={(e) => {
190
- if(cartState['state'] == "init"){
191
- initiateVariantSelection();
192
- } else if(cartState['state'] == "awaitingVariantSelection"){
193
- initiateAtcApiCall(selectedOptions);
194
- }
195
- }}
196
- onCartIconClick={initiateAtcCartIconClickAction}
197
- height={PRODUCT_TILE_TOTAL_HEIGHT * 0.3}
198
- />
199
- </View>
200
- </View>
201
- </Animatable.View>
202
- </TouchableWithoutFeedback>
203
- );
204
-
1
+ import { getGlobalState, setGlobalState, useGlobalState } from '../../globals/useAppState_APP.js';
2
+ import { Image, Text} from 'react-native';
3
+ import ProductPriceBadge from './ProductPriceBadge.js';
4
+
5
+ import React, { useEffect, useRef, useState } from 'react';
6
+ import { View, TouchableOpacity, ScrollView, Dimensions, TouchableWithoutFeedback } from 'react-native';
7
+ import SelectVariantComponent from './SelectVariantComponent';
8
+ import useAddToCartStates from '../../hooks/useAddToCartStates.js';
9
+ import AddToCartButton from '../cta-buttons/AddToCartButton.jsx';
10
+ import * as Animatable from 'react-native-animatable';
11
+ import { navigateToProductPage } from '../../api/navigation-commands/NavigationCommands.js';
12
+
13
+ export default function ProductTileV1(props) {
14
+ const event = props.event;
15
+ const product = props.product;
16
+
17
+ const [cartState, productVariantOptions, initiateVariantSelection, initiateAtcApiCall, getPriceDetailsFromSelectedOption, initiateAtcCartIconClickAction] = useAddToCartStates(0, product, props.event);
18
+ const [selectedOptions, setSelectedOptions] = useState(null);
19
+ const [tileTapAnimate, setTileTapAnimate] = useState(false);
20
+
21
+ const [productVariantPrice, setProductVariantPrice] = useState(parseFloat(product.price));
22
+ const [productVariantComparePrice, setProductVariantComparePrice] = useState(parseFloat(product.compare_price));
23
+
24
+ const whatmorePrimaryColor = getGlobalState('whatmorePrimaryColor');
25
+ const whatmorePrimaryFont = getGlobalState('whatmorePrimaryFont');
26
+
27
+ const brandDomainContext = getGlobalState('brandDomainContext');
28
+ const whatmoreShopId = getGlobalState('whatmoreShopId');
29
+
30
+ const PRODUCT_TILE_TOTAL_HEIGHT = Dimensions.get('window').height * 0.2;
31
+ const SELECT_VARIANT_TILE_HEIGHT_FACTOR = 3.0;
32
+ const BASE_FONT_SIZE = 20;
33
+
34
+ useEffect(() => {
35
+ if(tileTapAnimate){
36
+ setTimeout(() => {
37
+ setTileTapAnimate(false);
38
+ }, 1000);
39
+ }
40
+ }, [tileTapAnimate]);
41
+
42
+ function _updateSelectedOptions(_selectedOptions){
43
+ setSelectedOptions(_selectedOptions);
44
+
45
+ // set price to selected option
46
+ const optionPriceDetails = getPriceDetailsFromSelectedOption(_selectedOptions);
47
+
48
+ if(optionPriceDetails){
49
+ setProductVariantPrice(optionPriceDetails['price']);
50
+ setProductVariantComparePrice(optionPriceDetails['compare_price']);
51
+ }
52
+ }
53
+
54
+
55
+ return (
56
+ <TouchableWithoutFeedback
57
+ onPress={() => {
58
+ setTileTapAnimate(true);
59
+ navigateToProductPage(product, brandDomainContext, whatmoreShopId);
60
+ }}
61
+ >
62
+ <Animatable.View
63
+ animation={
64
+ tileTapAnimate
65
+ ?
66
+ {
67
+ 0: {
68
+ scale: 1
69
+ },
70
+ 0.5: {
71
+ scale: 0.9
72
+ },
73
+ 1: {
74
+ scale: 1
75
+ }
76
+ }
77
+ :
78
+ null
79
+ }
80
+ duration={100} iterationCount={1}
81
+ easing="ease-out"
82
+ style={{
83
+ width: '100%', height: 'auto',
84
+ flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'center',
85
+ overflow: 'hidden',
86
+ borderRadius: 5, overflow: 'hidden',
87
+ shadowColor: 'black', shadowOpacity: 1, shadowOffset: {width: 0, height: 0},
88
+ shadowRadius: 20, elevation: 10
89
+ }}
90
+ >
91
+ <View
92
+ style={{
93
+ width: '100%', height: 'auto',
94
+ backgroundColor: '#ffffffdd',
95
+ flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center'
96
+ }}
97
+ >
98
+ <Image
99
+ style={{
100
+ width: 120, height: 120
101
+ }}
102
+ source={{
103
+ uri: product.thumbnail_image,
104
+ }}
105
+ >
106
+
107
+ </Image>
108
+ <View
109
+ style={{
110
+ width: 'auto', height: 'auto',
111
+ flexDirection: 'column', justifyContent: 'space-between', alignItems: 'flex-start',
112
+ paddingLeft: 10, paddingRight: 10
113
+ }}
114
+ >
115
+ <Text
116
+ numberOfLines={2}
117
+ ellipsizeMode='tail'
118
+ style={{
119
+ fontWeight: 'normal',
120
+ fontFamily: whatmorePrimaryFont,
121
+ fontSize: BASE_FONT_SIZE * 1,
122
+ color: 'black'
123
+ }}
124
+ >
125
+ {product.title.toString()}
126
+ </Text>
127
+
128
+ <View
129
+ style={{
130
+ height: 10, width: 'auto'
131
+ }}
132
+ ></View>
133
+
134
+ <ProductPriceBadge product={product} event={event} fontSize={BASE_FONT_SIZE * 1} color={'black'} />
135
+ {/* <Text>
136
+ {product.price.toString()}
137
+ </Text> */}
138
+ </View>
139
+
140
+
141
+ </View>
142
+
143
+ <View
144
+ style={{
145
+ width: '100%', height: 'auto',
146
+ backgroundColor: '#ffffffdd',
147
+ overflow: 'hidden'
148
+ }}
149
+
150
+ >
151
+ {cartState['state'] === "awaitingVariantSelection" && productVariantOptions &&
152
+ <ScrollView
153
+ style={{
154
+ width: '100%',
155
+ height: 'auto',
156
+ marginTop: 5,
157
+ marginBottom: 10,
158
+ maxHeight: PRODUCT_TILE_TOTAL_HEIGHT * SELECT_VARIANT_TILE_HEIGHT_FACTOR
159
+ }}
160
+ >
161
+ <Animatable.View
162
+ animation="fadeIn"
163
+ duration={500} iterationCount={1}
164
+ easing="ease-in-out"
165
+ style={{
166
+ height: 'auto', width: '100%'
167
+ }}
168
+ >
169
+ <SelectVariantComponent
170
+ width='100%'
171
+ height='auto'
172
+ event={event}
173
+ product={product}
174
+ productVariantOptions={productVariantOptions}
175
+ baseFontSize={BASE_FONT_SIZE * 0.9}
176
+ onOptionSelected={_updateSelectedOptions}
177
+ />
178
+ </Animatable.View>
179
+ </ScrollView>
180
+ }
181
+
182
+ <View style={{ flexDirection: 'row', width: '100%', justifyContent: 'center', alignItems: 'center' }}>
183
+ <AddToCartButton
184
+ baseFontSize={BASE_FONT_SIZE * 0.3}
185
+ event={event}
186
+ product={product}
187
+ cartState={cartState['state']}
188
+ cartCount={cartState['cart_count']}
189
+ onClickAtc={(e) => {
190
+ if(cartState['state'] == "init"){
191
+ initiateVariantSelection();
192
+ } else if(cartState['state'] == "awaitingVariantSelection"){
193
+ initiateAtcApiCall(selectedOptions);
194
+ }
195
+ }}
196
+ onCartIconClick={initiateAtcCartIconClickAction}
197
+ height={PRODUCT_TILE_TOTAL_HEIGHT * 0.3}
198
+ />
199
+ </View>
200
+ </View>
201
+ </Animatable.View>
202
+ </TouchableWithoutFeedback>
203
+ );
204
+
205
205
  }