ordering-ui-react-native 0.15.74-release → 0.15.75-release

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.15.74-release",
3
+ "version": "0.15.75-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -367,6 +367,7 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
367
367
  key={business.id}
368
368
  business={business}
369
369
  isBusinessOpen={business.open}
370
+ enableIntersection={false}
370
371
  handleCustomClick={() => onBusinessClick(business)}
371
372
  handleUpdateBusinessList={handleUpdateBusinessList}
372
373
  orderType={orderState?.options?.type}
@@ -438,11 +439,12 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
438
439
  key={product?.id}
439
440
  isSoldOut={(product.inventoried && !product.quantity)}
440
441
  product={product}
442
+ enableIntersection={false}
441
443
  businessId={business?.id}
442
444
  onProductClick={(product: any) => onProductClick(business, category?.id, product?.id)}
443
445
  productAddedToCartLength={0}
444
446
  handleUpdateProducts={(productId: number, changes: any) => handleUpdateProducts(productId, category?.id, business?.id, changes)}
445
- style={{ width: screenWidth - 120, marginRight: i === category?.products?.length - 1 ? 0 : 20 }}
447
+ style={{ width: screenWidth - 80, maxWidth: screenWidth - 80, marginRight: 20 }}
446
448
  />
447
449
  )))}
448
450
 
@@ -0,0 +1,87 @@
1
+ import React from 'react'
2
+ import { useTheme } from 'styled-components/native'
3
+ import { StyleSheet } from 'react-native'
4
+ import { SubCategoriesContainer, ContainerButton } from './styles'
5
+ import { OButton } from '../../shared'
6
+ import { useLanguage } from 'ordering-components/native'
7
+
8
+ function SubcategoriesComponentPropsAreEqual(prev: any, next: any) {
9
+ return prev.subcategoriesSelected === next.subcategoriesSelected &&
10
+ prev.category === next.category
11
+ }
12
+
13
+ interface SubcategoriesComponentParams {
14
+ subcategoriesSelected?: any,
15
+ category?: any,
16
+ onClickSubcategory: any
17
+ }
18
+
19
+ const SubcategoriesComponent = (props : SubcategoriesComponentParams) => {
20
+ const {
21
+ subcategoriesSelected,
22
+ category,
23
+ onClickSubcategory
24
+ } = props
25
+
26
+ const theme = useTheme()
27
+ const [, t] = useLanguage()
28
+ const allsubcategorySelected = !subcategoriesSelected?.some((subcategory: any) => category?.id === subcategory?.parent_category_id)
29
+
30
+ const bpStyles = StyleSheet.create({
31
+ catWrap: { flexDirection: 'row', alignItems: 'center', marginBottom: 19 },
32
+ catIcon: {
33
+ borderRadius: 7.6,
34
+ shadowColor: '#000000',
35
+ shadowOpacity: 0.1,
36
+ shadowOffset: { width: 0, height: 0 },
37
+ shadowRadius: 1,
38
+ marginEnd: 13,
39
+ },
40
+ categoryButtonStyle: {
41
+ borderWidth: 0,
42
+ marginLeft: 5,
43
+ marginRight: 5,
44
+ marginBottom: 10,
45
+ height: 35,
46
+ paddingLeft: 3,
47
+ paddingRight: 3,
48
+ }
49
+ });
50
+
51
+
52
+ return (
53
+ <SubCategoriesContainer>
54
+ <ContainerButton
55
+ isSelected={allsubcategorySelected}
56
+ >
57
+ <OButton
58
+ onClick={() => onClickSubcategory(null, category)}
59
+ bgColor={allsubcategorySelected ? theme.colors.primary : theme.colors.backgroundGray}
60
+ text={`${t('ALL', 'All')} ${allsubcategorySelected ? 'X' : ''}`}
61
+ style={bpStyles.categoryButtonStyle}
62
+ textStyle={{ color: allsubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
63
+ />
64
+ </ContainerButton>
65
+ {category?.subcategories?.map((subcategory: any) => {
66
+ const isSubcategorySelected = subcategoriesSelected?.find((_subcategory: any) => _subcategory?.id === subcategory?.id)
67
+ return (
68
+ <ContainerButton
69
+ key={subcategory?.id}
70
+ isSelected={isSubcategorySelected}
71
+ >
72
+ <OButton
73
+ onClick={() => onClickSubcategory(subcategory, category)}
74
+ bgColor={isSubcategorySelected ? theme.colors.primary : theme.colors.backgroundGray}
75
+ text={`${subcategory?.name} ${isSubcategorySelected ? 'X' : ''}`}
76
+ style={bpStyles.categoryButtonStyle}
77
+ textStyle={{ color: isSubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
78
+ />
79
+ </ContainerButton>
80
+ )
81
+ }
82
+ )}
83
+ </SubCategoriesContainer>
84
+ )
85
+ }
86
+
87
+ export const SubcategoriesComponentMemoized = React.memo(SubcategoriesComponent, SubcategoriesComponentPropsAreEqual)
@@ -0,0 +1,12 @@
1
+ import styled from "styled-components/native";
2
+
3
+ export const SubCategoriesContainer = styled.View`
4
+ flex-direction: row;
5
+ flex-wrap: wrap;
6
+ margin-bottom: 10px;
7
+ `
8
+
9
+ export const ContainerButton = styled.View`
10
+ `
11
+
12
+ export const HeaderWrapper = styled.View``
@@ -12,6 +12,7 @@ import { useTheme } from 'styled-components/native';
12
12
  import { shape } from '../../utils'
13
13
  import { CategoryDescriptionMemoized } from './CategoryDescription';
14
14
  import { OrderItAgain } from '../OrderItAgain'
15
+ import { SubcategoriesComponentMemoized } from './SubcategoriesComponent';
15
16
 
16
17
  const BusinessProductsListUI = (props: BusinessProductsListParams) => {
17
18
  const {
@@ -70,49 +71,15 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
70
71
  }
71
72
  }
72
73
 
73
- const SubcategoriesComponent = ({ category }: any) => {
74
- const allsubcategorySelected = !subcategoriesSelected?.some((subcategory: any) => category?.id === subcategory?.parent_category_id)
75
-
76
- return (
77
- <SubCategoriesContainer>
78
- <ContainerButton
79
- isSelected={allsubcategorySelected}
80
- >
81
- <OButton
82
- onClick={() => onClickSubcategory(null, category)}
83
- bgColor={allsubcategorySelected ? theme.colors.primary : theme.colors.backgroundGray}
84
- text={`${t('ALL', 'All')} ${allsubcategorySelected ? 'X' : ''}`}
85
- style={bpStyles.categoryButtonStyle}
86
- textStyle={{ color: allsubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
87
- />
88
- </ContainerButton>
89
- {category?.subcategories?.map((subcategory: any) => {
90
- const isSubcategorySelected = subcategoriesSelected?.find((_subcategory: any) => _subcategory?.id === subcategory?.id)
91
- return (
92
- <ContainerButton
93
- key={subcategory?.id}
94
- isSelected={isSubcategorySelected}
95
- >
96
- <OButton
97
- onClick={() => onClickSubcategory(subcategory, category)}
98
- bgColor={isSubcategorySelected ? theme.colors.primary : theme.colors.backgroundGray}
99
- text={`${subcategory?.name} ${isSubcategorySelected ? 'X' : ''}`}
100
- style={bpStyles.categoryButtonStyle}
101
- textStyle={{ color: isSubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
102
- />
103
- </ContainerButton>
104
- )
105
- }
106
- )}
107
- </SubCategoriesContainer>
108
- )
109
- }
110
-
111
74
  return (
112
75
  <ProductsContainer renderToHardwareTextureAndroid={categoryState.loading || isBusinessLoading}>
113
76
  <HeaderWrapper>
114
77
  {category?.subcategories?.length > 0 && (
115
- <SubcategoriesComponent category={category} />
78
+ <SubcategoriesComponentMemoized
79
+ category={category}
80
+ subcategoriesSelected={subcategoriesSelected}
81
+ onClickSubcategory={onClickSubcategory}
82
+ />
116
83
  )}
117
84
  </HeaderWrapper>
118
85
  {previouslyProducts?.length > 0 && (
@@ -136,7 +103,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
136
103
  <SingleProductCard
137
104
  key={'prod_' + product.id + `_${i}`}
138
105
  isSoldOut={product.inventoried && !product.quantity}
139
- enableIntersection={!isFiltMode}
106
+ enableIntersection={!isFiltMode && categoryState.products?.length < 80}
140
107
  product={product}
141
108
  businessId={businessId}
142
109
  categoryState={categoryState}
@@ -164,7 +131,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
164
131
  key={'feat_' + product.id + `_${i}`}
165
132
  isSoldOut={product.inventoried && !product.quantity}
166
133
  product={product}
167
- enableIntersection={!isFiltMode}
134
+ enableIntersection={!isFiltMode && categoryState.products?.length < 80}
168
135
  businessId={businessId}
169
136
  categoryState={categoryState}
170
137
  onProductClick={onProductClick}
@@ -251,13 +218,17 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
251
218
  </View>
252
219
  )}
253
220
  {category?.subcategories?.length > 0 && !isFiltMode && (
254
- <SubcategoriesComponent category={category} />
221
+ <SubcategoriesComponentMemoized
222
+ category={category}
223
+ subcategoriesSelected={subcategoriesSelected}
224
+ onClickSubcategory={onClickSubcategory}
225
+ />
255
226
  )}
256
227
  <>
257
228
  {products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
258
229
  <SingleProductCard
259
230
  key={`${product?.id}_${i}`}
260
- enableIntersection={!isFiltMode}
231
+ enableIntersection={!isFiltMode && categoryState.products?.length < 80}
261
232
  isSoldOut={product.inventoried && !product.quantity}
262
233
  businessId={businessId}
263
234
  product={product}
@@ -279,7 +250,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
279
250
  <>
280
251
  {[...Array(categoryState?.pagination?.nextPageItems).keys()].map(
281
252
  (item, i) => (
282
- <View style={{ minHeight: 165, marginBottom: 28, padding: 12 }}>
253
+ <View style={{ minHeight: 165, marginBottom: 28, padding: 12 }} key={i}>
283
254
  <Placeholder style={{ padding: 5 }} Animation={Fade}>
284
255
  <View style={{ flexDirection: 'row' }}>
285
256
  <Placeholder style={{ paddingVertical: 10, flex: 1 }}>
@@ -363,6 +363,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
363
363
  onScroll={handlePageScroll}
364
364
  onScrollBeginDrag={handleTouchDrag}
365
365
  scrollEventThrottle={16}
366
+ bounces={false}
366
367
  >
367
368
  <BusinessBasicInformation
368
369
  navigation={navigation}
@@ -92,6 +92,7 @@ export const BusinessesListing = (props: any) => {
92
92
  bottomContainerStyle={{ height: 'auto', borderRadius: 10 }}
93
93
  titleStyle={{ textAlign: 'center' }}
94
94
  closeIcon={theme.images.general.close}
95
+ presentationStyle='overFullScreen'
95
96
  >
96
97
  {lastOrderReview?.order && <ReviewTrigger order={lastOrderReview?.order} handleOpenOrderReview={handleOpenOrderReview} />}
97
98
  </OBottomPopup>
@@ -105,8 +105,7 @@ const CheckoutUI = (props: any) => {
105
105
  padding: 20
106
106
  },
107
107
  pagePadding: {
108
- paddingLeft: 40,
109
- paddingRight: 40
108
+ paddingHorizontal: 40
110
109
  },
111
110
  icon: {
112
111
  top: 15,
@@ -76,7 +76,6 @@ export const ChCart = styled(ChPaymethods)``
76
76
 
77
77
  export const WalletPaymentOptionContainer = styled(ChPaymethods)`
78
78
  padding-bottom: 0;
79
- margin-left: -20px;
80
79
  `
81
80
 
82
81
  export const ChPlaceOrderBtn = styled.View`
@@ -42,7 +42,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
42
42
  const theme = useTheme();
43
43
  const hideAddButton = theme?.business_view?.components?.products?.components?.add_to_cart_button?.hidden ?? true
44
44
 
45
- const fadeAnim = useRef(new Animated.Value(0)).current;
45
+ const fadeAnim = useRef(new Animated.Value(enableIntersection ? 0 : 1)).current;
46
46
 
47
47
  const styles = StyleSheet.create({
48
48
  container: {
@@ -50,7 +50,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
50
50
  borderRadius: 7.6,
51
51
  borderColor: theme.colors.border,
52
52
  marginBottom: 28,
53
- minHeight: 165
53
+ minHeight: hideAddButton ? 100 : 165
54
54
  },
55
55
  titleWrapper: {
56
56
  flexDirection: 'row',
@@ -123,7 +123,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
123
123
  maxCartProductConfig,
124
124
  maxCartProductInventory,
125
125
  );
126
-
126
+
127
127
  const fadeIn = () => {
128
128
  Animated.timing(fadeAnim, {
129
129
  toValue: 1,
@@ -141,16 +141,18 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
141
141
  }
142
142
 
143
143
  const handleChangeIntersection = () => {
144
- setIsIntersectionObserver(true);
145
- fadeIn();
144
+ if (enableIntersection) {
145
+ setIsIntersectionObserver(true);
146
+ fadeIn();
147
+ }
146
148
  }
147
149
 
148
150
  useEffect(() => {
149
- if (!enableIntersection) fadeIn()
151
+ if (enableIntersection) fadeIn()
150
152
  }, [enableIntersection])
151
153
 
152
154
  return (
153
- <InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
155
+ <InView style={{ minHeight: hideAddButton ? 125 : 165 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
154
156
  {isIntersectionObserver ? (
155
157
  <CardContainer
156
158
  showAddButton={!hideAddButton}
@@ -164,7 +166,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
164
166
  <View style={{ flexDirection: 'row' }}>
165
167
  {productAddedToCartLength > 0 && (
166
168
  <QuantityContainer style={[styles.quantityContainer, {
167
- transform: [{ translateX: 25 }, { translateY: -55 }],
169
+ transform: [{ translateX: 25 }, { translateY: hideAddButton ? -25 : -55 }],
168
170
  }]}>
169
171
  <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
170
172
  </QuantityContainer>
@@ -281,7 +283,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
281
283
  )}
282
284
  </CardContainer>
283
285
  ) : (
284
- <View style={{ minHeight: 165, marginBottom: 28, padding: 12 }}>
286
+ <View style={{ marginBottom: 28, padding: 12, height: hideAddButton ? 125 : 165 }}>
285
287
  <Placeholder style={{ padding: 5 }} Animation={Fade}>
286
288
  <View style={{ flexDirection: 'row' }}>
287
289
  <Placeholder style={{ paddingVertical: 10, flex: 1 }}>
@@ -14,6 +14,7 @@ interface Props {
14
14
  bottomContainerStyle?: any;
15
15
  titleStyle?: any;
16
16
  closeIcon?: any;
17
+ presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen" | undefined
17
18
  }
18
19
  const OBottomPopup = (props: Props) => {
19
20
  const {
@@ -25,17 +26,18 @@ const OBottomPopup = (props: Props) => {
25
26
  isStatusBar,
26
27
  titleStyle,
27
28
  bottomContainerStyle,
28
- closeIcon
29
+ closeIcon,
30
+ presentationStyle
29
31
  } = props
30
32
  const { top, bottom } = useSafeAreaInsets();
31
-
33
+
32
34
  return (
33
35
  <Modal
34
36
  animationType='slide'
35
37
  transparent={transparent}
36
38
  visible={open}
37
39
  onRequestClose={() => onClose()}
38
- presentationStyle={'fullScreen'}
40
+ presentationStyle={presentationStyle || 'fullScreen'}
39
41
  >
40
42
  {isStatusBar && <StatusBar translucent={false} />}
41
43
  <View style={styles.container}>