ordering-ui-react-native 0.13.7 → 0.13.8

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.13.7",
3
+ "version": "0.13.8",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -71,7 +71,7 @@ export const BusinessBasicInformation = (props: BusinessBasicInformationParams)
71
71
  <BusinessContainer>
72
72
  <BusinessHeader
73
73
  style={{...styles.businesInfoheaderStyle}}
74
- source={{ uri: header || optimizeImage(businessState?.business?.header, 'h_400,c_limit') }}
74
+ source={{ uri: header || optimizeImage(businessState?.business?.header, 'h_300,c_limit') }}
75
75
  >
76
76
  <BusinessLogo>
77
77
  {loading ? (
@@ -83,7 +83,7 @@ export const BusinessBasicInformation = (props: BusinessBasicInformationParams)
83
83
  ) : (
84
84
  !isBusinessInfoShow && (
85
85
  <OIcon
86
- url={logo || optimizeImage(businessState?.business?.logo, 'h_300,c_limit')}
86
+ url={logo || optimizeImage(businessState?.business?.logo, 'h_100,c_limit')}
87
87
  style={styles.businessLogo}
88
88
  cover
89
89
  />
@@ -140,13 +140,15 @@ export const BusinessBasicInformation = (props: BusinessBasicInformationParams)
140
140
  <OText color={theme.colors.textSecondary} numberOfLines={1} style={{ flexBasis: '85%', marginEnd: 6 }}>
141
141
  {orderState?.options?.address?.address}
142
142
  </OText>
143
- <TouchableOpacity
144
- onPress={() => auth
145
- ? onRedirect('AddressList', { isGoBack: true, isFromProductsList: true })
146
- : onRedirect('AddressForm', { address: orderState.options?.address })}
147
- >
148
- <OIcon width={16} src={theme.images.general.pencil} />
149
- </TouchableOpacity>
143
+ {!isBusinessInfoShow && (
144
+ <TouchableOpacity
145
+ onPress={() => auth
146
+ ? onRedirect('AddressList', { isGoBack: true, isFromProductsList: true })
147
+ : onRedirect('AddressForm', { address: orderState.options?.address })}
148
+ >
149
+ <OIcon width={16} src={theme.images.general.pencil} />
150
+ </TouchableOpacity>
151
+ )}
150
152
  </View>
151
153
  <View style={{ ...styles.infoItem, paddingStart: 12 }}>
152
154
  <OText color={theme.colors.textSecondary} numberOfLines={1} style={{ flexBasis: '85%', paddingEnd: 6 }}>
@@ -154,46 +156,16 @@ export const BusinessBasicInformation = (props: BusinessBasicInformationParams)
154
156
  ? moment(orderState.options?.moment).format('dddd, MMM.DD.yyyy hh:mm A')
155
157
  : t('ASAP_ABBREVIATION', 'ASAP')}
156
158
  </OText>
157
- <TouchableOpacity
158
- onPress={() => navigation.navigate('MomentOption')}
159
- >
160
- <OIcon src={theme.images.general.info} width={16} />
161
- </TouchableOpacity>
159
+ {!isBusinessInfoShow && (
160
+ <TouchableOpacity
161
+ onPress={() => navigation.navigate('MomentOption')}
162
+ >
163
+ <OIcon src={theme.images.general.info} width={16} />
164
+ </TouchableOpacity>
165
+ )}
162
166
  </View>
163
167
  </>
164
- }
165
- {/* <View style={styles.bullet}>
166
- <IconEvilIcons
167
- name='clock'
168
- color={theme.colors.textSecondary}
169
- size={16}
170
- />
171
- {orderState?.options?.type === 1 ? (
172
- <OText color={theme.colors.textSecondary} style={styles.metadata}>
173
- {convertHoursToMinutes(business?.delivery_time)}
174
- </OText>
175
- ) : (
176
- <OText color={theme.colors.textSecondary} style={styles.metadata}>
177
- {convertHoursToMinutes(business?.pickup_time)}
178
- </OText>
179
- )}
180
- </View>
181
- <View style={styles.bullet}>
182
- <IconEvilIcons
183
- name='location'
184
- color={theme.colors.textSecondary}
185
- size={16}
186
- />
187
- <OText color={theme.colors.textSecondary} style={styles.metadata}>{parseDistance(business?.distance || 0)}</OText>
188
- </View>
189
- <View style={styles.bullet}>
190
- <MaterialComIcon
191
- name='truck-delivery'
192
- color={theme.colors.textSecondary}
193
- size={16}
194
- />
195
- </View>
196
- <OText color={theme.colors.textSecondary} style={styles.metadata}>{business && parsePrice(business?.delivery_price || 0)}</OText> */}
168
+ }
197
169
  </BusinessInfoItem>
198
170
  </View>
199
171
  {showReview && (
@@ -144,7 +144,7 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
144
144
 
145
145
  <BusinessLogo>
146
146
  <OIcon
147
- url={optimizeImage(business?.logo, 'h_300,c_limit')}
147
+ url={optimizeImage(business?.logo, 'h_50,c_limit')}
148
148
  style={styles.businessLogo}
149
149
  />
150
150
  </BusinessLogo>
@@ -11,7 +11,6 @@ export const GrayBackground = styled.View`
11
11
  `
12
12
  export const WrapMainContent = styled.ScrollView`
13
13
  flex: 1;
14
- margin-top: 40px;
15
14
  `
16
15
  export const InnerContent = styled.View`
17
16
  padding: 30px 20px;
@@ -4,14 +4,15 @@ import { SingleProductCard } from '../SingleProductCard'
4
4
  import { NotFoundSource } from '../NotFoundSource'
5
5
  import { BusinessProductsListParams } from '../../types'
6
6
  import { OText } from '../shared'
7
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
8
+ import { Platform, View, TouchableOpacity } from 'react-native'
9
+ import { useTheme } from 'styled-components/native'
7
10
  import {
8
11
  ProductsContainer,
9
12
  ErrorMessage,
10
- WrapperNotFound
13
+ WrapperNotFound,
14
+ ProductsWrapper
11
15
  } from './styles'
12
- import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
13
- import { Platform, View, TouchableOpacity } from 'react-native'
14
- import { useTheme } from 'styled-components/native'
15
16
  import { ScrollView } from 'react-native-gesture-handler'
16
17
 
17
18
  const BusinessProductsListUI = (props: BusinessProductsListParams) => {
@@ -42,8 +43,11 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
42
43
  if (categoryState?.products.length > allProducts.length) {
43
44
  setAllProducts(categoryState?.products.sort((a: any, b: any) => a.id - b.id))
44
45
  }
46
+ if (searchValue) {
47
+ setAllProducts(categoryState?.products.sort((a: any, b: any) => a.id - b.id))
48
+ }
45
49
  }
46
- }, [category, categoryState])
50
+ }, [category, categoryState, searchValue])
47
51
 
48
52
  return (
49
53
  <ProductsContainer>
@@ -67,7 +71,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
67
71
  >
68
72
  <OText style={{...theme.labels.subtitle, fontWeight: Platform.OS == 'ios' ? '600' : 'bold'}} mBottom={10}>{t('FEATURED', 'Featured')}</OText>
69
73
  </TouchableOpacity>
70
- <ScrollView horizontal showsHorizontalScrollIndicator={false}>
74
+ <ProductsWrapper>
71
75
  {allProducts?.map((product: any, index: number) => product.featured && (
72
76
  <SingleProductCard
73
77
  key={index}
@@ -77,7 +81,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
77
81
  onProductClick={onProductClick}
78
82
  />
79
83
  ))}
80
- </ScrollView>
84
+ </ProductsWrapper>
81
85
  </>
82
86
  )
83
87
  }
@@ -95,7 +99,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
95
99
  >
96
100
  <OText style={{...theme.labels.subtitle, fontWeight: Platform.OS === 'ios' ? '600' : 'bold'}} mBottom={10}>{category.name}</OText>
97
101
  </TouchableOpacity>
98
- <ScrollView horizontal showsHorizontalScrollIndicator={false}>
102
+ <ProductsWrapper>
99
103
  {
100
104
  products.map((product: any, index: number) => (
101
105
  <SingleProductCard
@@ -107,7 +111,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
107
111
  />
108
112
  ))
109
113
  }
110
- </ScrollView>
114
+ </ProductsWrapper>
111
115
  </>
112
116
  )
113
117
  }
@@ -118,29 +122,27 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
118
122
 
119
123
  {
120
124
  (categoryState.loading || isBusinessLoading) && (
121
- <>
125
+ <Placeholder style={{ padding: 5, marginBottom: 20 }} Animation={Fade}>
126
+ <PlaceholderLine width={50} height={16} style={{ marginBottom: 20 }} />
122
127
  {[...Array(categoryState?.pagination?.nextPageItems).keys()].map((item, i) => (
123
- <Placeholder key={i} style={{ padding: 5, marginBottom: 20 }} Animation={Fade}>
124
- <PlaceholderLine width={50} height={20} style={{ marginBottom: 20 }} />
125
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
126
- <View style={{flexBasis: '47%'}}>
127
- <PlaceholderLine width={80} height={100} style={{ marginBottom: 10 }} />
128
- <Placeholder>
129
- <PlaceholderLine width={60} style={{marginBottom: 12}}/>
130
- <PlaceholderLine width={20} />
131
- </Placeholder>
132
- </View>
133
- <View style={{flexBasis: '47%'}}>
134
- <PlaceholderLine width={80} height={100} style={{ marginBottom: 10 }} />
135
- <Placeholder>
136
- <PlaceholderLine width={60} style={{marginBottom: 25}}/>
137
- <PlaceholderLine width={20} />
138
- </Placeholder>
139
- </View>
128
+ <View key={i} style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
129
+ <View style={{flexBasis: '47%'}}>
130
+ <PlaceholderLine width={80} height={100} style={{ marginBottom: 10 }} />
131
+ <Placeholder>
132
+ <PlaceholderLine width={20} />
133
+ <PlaceholderLine width={60} style={{marginBottom: 12}}/>
134
+ </Placeholder>
140
135
  </View>
141
- </Placeholder>
136
+ <View style={{flexBasis: '47%'}}>
137
+ <PlaceholderLine width={80} height={100} style={{ marginBottom: 10 }} />
138
+ <Placeholder>
139
+ <PlaceholderLine width={20} />
140
+ <PlaceholderLine width={60} style={{marginBottom: 25}}/>
141
+ </Placeholder>
142
+ </View>
143
+ </View>
142
144
  ))}
143
- </>
145
+ </Placeholder>
144
146
  )
145
147
  }
146
148
  {
@@ -11,4 +11,9 @@ export const ErrorMessage = styled.View`
11
11
 
12
12
  export const WrapperNotFound = styled.View`
13
13
  height: 500px;
14
- `
14
+ `
15
+ export const ProductsWrapper = styled.View`
16
+ flex-direction: row;
17
+ flex-wrap: wrap;
18
+ align-items: flex-start;
19
+ `
@@ -1,6 +1,5 @@
1
- import React, { useState } from 'react'
2
- import { View, TouchableOpacity, StyleSheet, ScrollView } from 'react-native'
3
- import MaterialIcon from 'react-native-vector-icons/MaterialIcons'
1
+ import React, { useEffect, useState } from 'react'
2
+ import { View, StyleSheet, ScrollView, Animated, Dimensions } from 'react-native'
4
3
  import {
5
4
  BusinessAndProductList,
6
5
  useLanguage,
@@ -28,13 +27,14 @@ import { FloatingButton } from '../FloatingButton'
28
27
  import { ProductForm } from '../ProductForm'
29
28
  import { UpsellingProducts } from '../UpsellingProducts'
30
29
  import { useTheme } from 'styled-components/native'
31
- import { useSafeAreaInsets } from 'react-native-safe-area-context'
32
30
  import { OrderSummary } from '../OrderSummary'
33
31
  import { Cart } from '../Cart'
34
- import { SingleProductCard } from '../../../../../src/components/SingleProductCard'
32
+ import { SingleProductCard } from '../SingleProductCard'
35
33
  import NavBar from '../NavBar'
36
34
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
37
35
 
36
+ const { width, height } = Dimensions.get('screen')
37
+
38
38
  const PIXELS_TO_SCROLL = 1000
39
39
 
40
40
  const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
@@ -58,6 +58,43 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
58
58
  updateProductModal
59
59
  } = props
60
60
 
61
+ const styles = StyleSheet.create({
62
+ mainContainer: {
63
+ flex: 1,
64
+ display: categorySelected.id !== null ? 'none' : 'flex'
65
+ },
66
+ BackIcon: {
67
+ paddingRight: 20,
68
+ },
69
+ headerItem: {
70
+ flexDirection: 'row',
71
+ alignItems: 'center',
72
+ marginHorizontal: 20,
73
+ },
74
+ btnBackArrow: {
75
+ borderWidth: 0,
76
+ color: '#FFF',
77
+ backgroundColor: 'rgba(0,0,0,0.3)',
78
+ borderRadius: 16,
79
+ paddingHorizontal: 15,
80
+ marginRight: 15,
81
+ marginTop: 20
82
+ },
83
+ searchIcon: {
84
+ borderWidth: 0,
85
+ color: '#FFF',
86
+ backgroundColor: 'rgba(0,0,0,0.3)',
87
+ borderRadius: 24,
88
+ padding: 15,
89
+ justifyContent: 'center'
90
+ },
91
+ productsWrapper: {
92
+ flexDirection: 'row',
93
+ flexWrap: 'wrap',
94
+ alignItems: 'flex-start'
95
+ }
96
+ })
97
+
61
98
  const theme = useTheme()
62
99
  const [, t] = useLanguage()
63
100
  const [{ auth }] = useSession()
@@ -71,7 +108,11 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
71
108
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
72
109
  const [openCart, setOpenCart] = useState(false)
73
110
 
74
- const { top, bottom } = useSafeAreaInsets();
111
+ const [alignment] = useState(new Animated.Value(0))
112
+ const actionSheetIntropolate = alignment.interpolate({
113
+ inputRange: [0, 1],
114
+ outputRange: [-height, 0]
115
+ })
75
116
 
76
117
  const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
77
118
 
@@ -117,6 +158,22 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
117
158
  }
118
159
  }
119
160
 
161
+ useEffect(() => {
162
+ if (categorySelected.id === null) {
163
+ Animated.timing(alignment, {
164
+ toValue: 0,
165
+ duration: 500,
166
+ useNativeDriver: false
167
+ }).start()
168
+ } else {
169
+ Animated.timing(alignment, {
170
+ toValue: 1,
171
+ duration: 500,
172
+ useNativeDriver: false
173
+ }).start()
174
+ }
175
+ }, [categorySelected.id])
176
+
120
177
  return (
121
178
  <>
122
179
  <BusinessProductsListingContainer
@@ -129,7 +186,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
129
186
  <WrapHeader>
130
187
  {!loading && business?.id && (
131
188
  <>
132
- <TopHeader style={{ marginTop: top }}>
189
+ <TopHeader>
133
190
  <View style={{ ...styles.headerItem, flex: 1 }}>
134
191
  <OButton
135
192
  imgLeftSrc={theme.images.general.arrow_left}
@@ -213,6 +270,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
213
270
  handleClick={() => onRedirect('CartPage', { cart: currentCart })}
214
271
  />
215
272
  )}
273
+
216
274
  <OModal
217
275
  open={!!curProduct || (!!productModal.product && !orderState.loading)}
218
276
  onClose={handleCloseProductModal}
@@ -230,18 +288,16 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
230
288
  />
231
289
  </OModal>
232
290
 
233
- <OModal
234
- open={categorySelected.id !== null}
235
- onClose={() => handleChangeCategory({ id: null, name: 'All' })}
236
- entireModal
237
- customClose
238
- >
239
- <ScrollView
291
+ {categorySelected.id !== null && (
292
+ <Animated.ScrollView
240
293
  contentContainerStyle={{
241
294
  paddingHorizontal: 40,
242
295
  paddingVertical: 20
243
296
  }}
244
297
  onScroll={(e: any) => handleScroll(e)}
298
+ style={{
299
+ bottom: actionSheetIntropolate
300
+ }}
245
301
  >
246
302
  <NavBar
247
303
  title={categorySelected?.name}
@@ -249,7 +305,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
249
305
  showCall={false}
250
306
  style={{ paddingHorizontal: 0, marginHorizontal: -7 }}
251
307
  />
252
- <View>
308
+ <View style={styles.productsWrapper}>
253
309
  {categorySelected.id && (
254
310
  categoryState.products?.map((product: any, index: number) => (
255
311
  <SingleProductCard
@@ -265,27 +321,30 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
265
321
 
266
322
  {
267
323
  categoryState.loading && (
268
- <>
269
- {[...Array(10).keys()].map((item, i) => (
270
- <Placeholder key={i} style={{ marginBottom: 10 }} Animation={Fade}>
271
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
272
- <View
273
- style={{ width: 80, height: 80 }}
274
- >
275
- <PlaceholderLine width={80} height={70} />
324
+ <Placeholder style={{ padding: 5, marginBottom: 20 }} Animation={Fade}>
325
+ {[...Array(categoryState?.pagination?.nextPageItems).keys()].map((item, i) => (
326
+ <View key={i} style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
327
+ <View style={{flexBasis: '47%'}}>
328
+ <PlaceholderLine width={80} height={100} style={{ marginBottom: 10 }} />
329
+ <Placeholder>
330
+ <PlaceholderLine width={20} />
331
+ <PlaceholderLine width={60} style={{marginBottom: 12}}/>
332
+ </Placeholder>
276
333
  </View>
334
+ <View style={{flexBasis: '47%'}}>
335
+ <PlaceholderLine width={80} height={100} style={{ marginBottom: 10 }} />
277
336
  <Placeholder>
278
- <PlaceholderLine width={60} style={{marginBottom: 30}}/>
279
337
  <PlaceholderLine width={20} />
338
+ <PlaceholderLine width={60} style={{marginBottom: 25}}/>
280
339
  </Placeholder>
340
+ </View>
281
341
  </View>
342
+ ))}
282
343
  </Placeholder>
283
- ))}
284
- </>
285
344
  )
286
345
  }
287
- </ScrollView>
288
- </OModal>
346
+ </Animated.ScrollView>
347
+ )}
289
348
 
290
349
  {openUpselling && (
291
350
  <UpsellingProducts
@@ -302,37 +361,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
302
361
  )
303
362
  }
304
363
 
305
- const styles = StyleSheet.create({
306
- mainContainer: {
307
- flex: 1,
308
- },
309
- BackIcon: {
310
- paddingRight: 20,
311
- },
312
- headerItem: {
313
- flexDirection: 'row',
314
- alignItems: 'center',
315
- marginHorizontal: 20,
316
- },
317
- btnBackArrow: {
318
- borderWidth: 0,
319
- color: '#FFF',
320
- backgroundColor: 'rgba(0,0,0,0.3)',
321
- borderRadius: 16,
322
- paddingHorizontal: 15,
323
- marginRight: 15,
324
- marginTop: 20
325
- },
326
- searchIcon: {
327
- borderWidth: 0,
328
- color: '#FFF',
329
- backgroundColor: 'rgba(0,0,0,0.3)',
330
- borderRadius: 24,
331
- padding: 15,
332
- justifyContent: 'center'
333
- }
334
- })
335
-
336
364
  export const BusinessProductsListing = (props: BusinessProductsListingParams) => {
337
365
  const businessProductslistingProps = {
338
366
  ...props,
@@ -1,4 +1,4 @@
1
- import React, {useEffect} from 'react'
1
+ import React from 'react'
2
2
  import { useLanguage, useConfig, useOrder, useUtils } from 'ordering-components/native'
3
3
  import { SingleProductCardParams } from '../../types'
4
4
  import {
@@ -23,9 +23,8 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
23
23
 
24
24
  const styles = StyleSheet.create({
25
25
  container: {
26
- marginBottom: 15,
27
- width: (windowWidth - 140) / 2,
28
- minHeight: (windowWidth - 140) / 2 + 50
26
+ width: (windowWidth - 80) / 2,
27
+ height: (windowWidth - 80) / 2 + 40
29
28
  },
30
29
  textStyle: {
31
30
  flex: 1,
@@ -37,8 +36,8 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
37
36
  lineHeight: 18
38
37
  },
39
38
  productStyle: {
40
- width: (windowWidth - 200) / 2,
41
- height: (windowWidth - 200) / 2,
39
+ width: (windowWidth - 160) / 2,
40
+ height: (windowWidth - 160) / 2,
42
41
  borderRadius: 3,
43
42
  marginTop: 5
44
43
  },
@@ -70,10 +69,6 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
70
69
 
71
70
  const maxProductQuantity = Math.min(maxCartProductConfig, maxCartProductInventory)
72
71
 
73
- useEffect(() => {
74
-
75
- }, [product]);
76
-
77
72
  return (
78
73
  <CardContainer style={styles.container}
79
74
  onPress={() => onProductClick?.(product)}
@@ -1,11 +1,11 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
3
  export const CardContainer = styled.TouchableOpacity`
4
- flex: 1;
4
+ /* flex-grow: 1; */
5
5
  align-items: flex-start;
6
6
  padding: 10px;
7
7
  position: relative;
8
- margin-end: 10px;
8
+ /* margin-end: 10px; */
9
9
  border-radius: 3px;
10
10
  `
11
11
  export const CardInfo = styled.View`