ordering-ui-react-native 0.16.26 → 0.16.29

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": "ordering-ui-react-native",
3
- "version": "0.16.26",
3
+ "version": "0.16.29",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -153,7 +153,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
153
153
  {(
154
154
  productInfo?.()?.ingredients?.length > 0 ||
155
155
  productInfo?.()?.options?.length > 0 ||
156
- product.comment
156
+ !!product.comment
157
157
  ) && !isClickableEvent && (
158
158
  <MaterialCommunityIcon name="chevron-down" size={12} />
159
159
  )}
@@ -278,7 +278,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
278
278
  </ProductOptionsList>
279
279
  )}
280
280
 
281
- {product.comment && (
281
+ {!!product.comment && (
282
282
  <ProductComment>
283
283
  <OText
284
284
  size={12}
@@ -55,6 +55,7 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
55
55
  } = props
56
56
 
57
57
  const screenHeight = Dimensions.get('window').height;
58
+ const screenWidth = Dimensions.get('window').width;
58
59
  const theme = useTheme()
59
60
  const [orderState] = useOrder()
60
61
  const { top } = useSafeAreaInsets();
@@ -339,7 +340,7 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
339
340
  handleCustomClick={() => onBusinessClick(business)}
340
341
  handleUpdateBusinessList={handleUpdateBusinessList}
341
342
  orderType={orderState?.options?.type}
342
- style={{ width: 320, marginRight: (businessesSearchList.loading || i !== businessesSearchList.businesses?.length - 1) ? 20 : 0 }}
343
+ style={{ width: screenWidth - 80, marginRight: (businessesSearchList.loading || i !== businessesSearchList.businesses?.length - 1) ? 20 : 0 }}
343
344
  />
344
345
  ))}
345
346
  {!businessesSearchList.loading && paginationProps?.totalPages && paginationProps?.currentPage < paginationProps?.totalPages && (
@@ -411,7 +412,7 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
411
412
  onProductClick={() => { }}
412
413
  productAddedToCartLength={0}
413
414
  handleUpdateProducts={(productId: number, changes: any) => handleUpdateProducts(productId, category?.id, business?.id, changes)}
414
- style={{ width: 320, marginRight: i === category?.products?.length - 1 ? 0 : 20 }}
415
+ style={{ width: screenWidth - 80, marginRight: i === category?.products?.length - 1 ? 0 : 20 }}
415
416
  />
416
417
  )))}
417
418
 
@@ -7,11 +7,12 @@ import { ListWrapper } from './styles'
7
7
  import {
8
8
  View,
9
9
  StyleSheet,
10
- ScrollView
10
+ ScrollView,
11
+ Dimensions
11
12
  } from 'react-native';
12
13
  import { PreviousBusinessOrderedParams } from '../../../types';
13
14
 
14
- export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams) => {
15
+ export const PreviousBusinessOrderedUI = (props: PreviousBusinessOrderedParams) => {
15
16
  const {
16
17
  navigation,
17
18
  businessesList,
@@ -23,6 +24,8 @@ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams)
23
24
  } = props
24
25
 
25
26
  const [orderState] = useOrder()
27
+ const windowWidth = Dimensions.get('window').width;
28
+
26
29
  const onBusinessClick = (business: any) => {
27
30
  onNavigationRedirect('Business', { store: business.slug })
28
31
  }
@@ -120,7 +123,7 @@ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams)
120
123
  <>
121
124
  {!businessLoading && (
122
125
  <BusinessControllerList
123
- style={{ width: 320, marginRight: 20 }}
126
+ style={{ width: windowWidth - 80, marginRight: 20 }}
124
127
  />
125
128
  )}
126
129
  </>
@@ -137,7 +140,7 @@ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams)
137
140
  )
138
141
  }
139
142
 
140
- export const PreviousBusinessOrdered = (props) => {
143
+ export const PreviousBusinessOrdered = (props: PreviousBusinessOrderedParams) => {
141
144
  const previousBusinessOrderedController = {
142
145
  ...props,
143
146
  UIComponent: PreviousBusinessOrderedUI,
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { ScrollView, StyleSheet } from 'react-native'
2
+ import { ScrollView, StyleSheet, Dimensions } from 'react-native'
3
3
  import {
4
4
  ListWrapper
5
5
  } from './styles'
@@ -7,13 +7,15 @@ import {
7
7
  import { SingleProductCard } from '../../SingleProductCard'
8
8
  import { PreviousProductsOrderedParams } from '../../../types'
9
9
 
10
- export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) => {
10
+ export const PreviousProductsOrdered = (props: PreviousProductsOrderedParams) => {
11
11
  const {
12
12
  products,
13
13
  onProductClick,
14
14
  isBusinessesSearchList
15
15
  } = props
16
16
 
17
+ const windowWidth = Dimensions.get('window').width;
18
+
17
19
  const styles = StyleSheet.create({
18
20
  container: {
19
21
  marginBottom: 0,
@@ -24,15 +26,15 @@ export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) =
24
26
  return (
25
27
  <>
26
28
  {products?.map((product: any) => (
27
- <SingleProductCard
28
- key={product?.id}
29
- isSoldOut={(product.inventoried && !product.quantity)}
30
- product={product}
31
- businessId={product?.business?.id}
32
- onProductClick={onProductClick}
33
- style={style}
34
- productAddedToCartLength={0}
35
- />
29
+ <SingleProductCard
30
+ key={product?.id}
31
+ isSoldOut={(product.inventoried && !product.quantity)}
32
+ product={product}
33
+ businessId={product?.business?.id}
34
+ onProductClick={onProductClick}
35
+ style={style}
36
+ productAddedToCartLength={0}
37
+ />
36
38
  ))}
37
39
  </>
38
40
  )
@@ -40,7 +42,7 @@ export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) =
40
42
  return (
41
43
  <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
42
44
  {isBusinessesSearchList ? (
43
- <ProductList style={{ width: 320, marginRight: 20 }} />
45
+ <ProductList style={{ width: windowWidth - 80, marginRight: 20 }} />
44
46
  ) : (
45
47
  <ListWrapper isBusinessesSearchList={isBusinessesSearchList}>
46
48
  <ProductList />
@@ -9,13 +9,20 @@ import {
9
9
  import { useTheme } from 'styled-components/native';
10
10
  import { SingleProductCardParams } from '../../types';
11
11
  import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper } from './styles';
12
- import { StyleSheet, View, TouchableOpacity } from 'react-native';
13
- import { OText, OIcon } from '../shared';
12
+ import { StyleSheet, View, TouchableOpacity, Image } from 'react-native';
13
+ import { OText } from '../shared';
14
14
  import FastImage from 'react-native-fast-image'
15
15
  import IconAntDesign from 'react-native-vector-icons/AntDesign'
16
16
  import { shape } from '../../utils';
17
17
 
18
- const SinguleProductCardUI = (props: SingleProductCardParams) => {
18
+ function SingleProductCardPropsAreEqual(prevProps: any, nextProps: any) {
19
+ return JSON.stringify(prevProps.product) === JSON.stringify(nextProps.product) &&
20
+ prevProps.isSoldOut === nextProps.isSoldOut &&
21
+ prevProps.productAddedToCartLength === nextProps.productAddedToCartLength &&
22
+ prevProps.categoryState === nextProps.categoryState
23
+ }
24
+
25
+ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
19
26
  const {
20
27
  product,
21
28
  isSoldOut,
@@ -188,9 +195,13 @@ const SinguleProductCardUI = (props: SingleProductCardParams) => {
188
195
  resizeMode={FastImage.resizeMode.cover}
189
196
  />
190
197
  ) : (
191
- <OIcon
192
- src={theme?.images?.dummies?.product}
198
+ <FastImage
193
199
  style={styles.productStyle}
200
+ source={{
201
+ uri: Image.resolveAssetSource(theme.images.dummies.product).uri,
202
+ priority: FastImage.priority.normal,
203
+ }}
204
+ resizeMode={FastImage.resizeMode.cover}
194
205
  />
195
206
  )}
196
207
  </LogoWrapper>
@@ -204,7 +215,7 @@ const SinguleProductCardUI = (props: SingleProductCardParams) => {
204
215
  )}
205
216
  </CardContainer>
206
217
  );
207
- };
218
+ }, SingleProductCardPropsAreEqual);
208
219
 
209
220
  export const SingleProductCard = (props: SingleProductCardParams) => {
210
221
  const singleProductCardProps = {