ordering-ui-react-native 0.14.68 → 0.14.69
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.14.
|
|
3
|
+
"version": "0.14.69",
|
|
4
4
|
"description": "Reusable components made in react native",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"author": "ordering.inc",
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"react-native-uuid": "^2.0.1",
|
|
109
109
|
"react-native-vector-icons": "^7.1.0",
|
|
110
110
|
"react-native-webview": "^11.6.4",
|
|
111
|
+
"react-native-youtube-iframe": "^2.2.2",
|
|
111
112
|
"rn-placeholder": "^3.0.3",
|
|
112
113
|
"styled-components": "^5.1.1",
|
|
113
114
|
"styled-system": "^5.1.5",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import * as React from 'react'
|
|
3
3
|
import { ImageStyle } from 'react-native'
|
|
4
4
|
import styled from 'styled-components/native'
|
|
5
|
+
import { useTheme } from 'styled-components/native'
|
|
5
6
|
|
|
6
7
|
const Wrapper = styled.View``
|
|
7
8
|
|
|
@@ -23,10 +24,12 @@ interface Props {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const OImage = (props: Props): React.ReactElement => {
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
|
|
26
29
|
return (
|
|
27
30
|
<Wrapper style={{ borderRadius: props.style?.borderRadius, overflow: 'hidden', marginHorizontal: props.style?.marginHorizontal }}>
|
|
28
31
|
<SImage
|
|
29
|
-
source={props.src ? props.src : props.url ? { uri: props.url } : props.dummy ? props.dummy : require('../../assets/icons/lunch.png')}
|
|
32
|
+
source={props.src ? props.src : props.url ? { uri: props.url } : props.dummy ? props.dummy : theme.images.general.lunch || require('../../assets/icons/lunch.png')}
|
|
30
33
|
style={{
|
|
31
34
|
tintColor: props.color,
|
|
32
35
|
flex: props.isWrap ? 1 : 0,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ProductsList, useLanguage, useUtils } from 'ordering-components/native';
|
|
2
|
+
import { ProductsList, useLanguage, useUtils, useConfig } from 'ordering-components/native';
|
|
3
3
|
import { SingleProductCard } from '../SingleProductCard';
|
|
4
4
|
import { NotFoundSource } from '../NotFoundSource';
|
|
5
5
|
import { BusinessProductsListParams } from '../../types';
|
|
@@ -31,6 +31,8 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
31
31
|
|
|
32
32
|
const [, t] = useLanguage();
|
|
33
33
|
const [{ optimizeImage }] = useUtils()
|
|
34
|
+
const [{ configs }] = useConfig()
|
|
35
|
+
const isUseParentCategory = configs?.use_parent_category?.value === 'true' || configs?.use_parent_category?.value === '1'
|
|
34
36
|
|
|
35
37
|
const handleOnLayout = (event: any, categoryId: any) => {
|
|
36
38
|
const _categoriesLayout = { ...categoriesLayout }
|
|
@@ -80,52 +82,47 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
80
82
|
</View>
|
|
81
83
|
)}
|
|
82
84
|
|
|
83
|
-
{!category.id
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
</>
|
|
125
|
-
)}
|
|
126
|
-
</React.Fragment>
|
|
127
|
-
);
|
|
128
|
-
})}
|
|
85
|
+
{!category?.id && categories.filter(category => category?.id !== null).map((category, i, _categories) => {
|
|
86
|
+
const products = !isUseParentCategory
|
|
87
|
+
? categoryState?.products?.filter((product : any) => product?.category_id === category?.id) ?? []
|
|
88
|
+
: categoryState?.products?.filter((product : any) => category?.children?.some((cat : any) => cat.category_id === product?.category_id)) ?? []
|
|
89
|
+
return (
|
|
90
|
+
<React.Fragment key={'cat_' + category.id}>
|
|
91
|
+
{products.length > 0 && (
|
|
92
|
+
<>
|
|
93
|
+
<View
|
|
94
|
+
style={bpStyles.catWrap}
|
|
95
|
+
onLayout={(event: any) => handleOnLayout(event, category.id)}
|
|
96
|
+
>
|
|
97
|
+
<View style={bpStyles.catIcon}>
|
|
98
|
+
<OIcon
|
|
99
|
+
url={optimizeImage(category.image, 'h_100,c_limit')}
|
|
100
|
+
width={41}
|
|
101
|
+
height={41}
|
|
102
|
+
style={{ borderRadius: 7.6 }}
|
|
103
|
+
/>
|
|
104
|
+
</View>
|
|
105
|
+
<OText size={16} weight="600">
|
|
106
|
+
{category.name}
|
|
107
|
+
</OText>
|
|
108
|
+
</View>
|
|
109
|
+
<>
|
|
110
|
+
{products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
|
|
111
|
+
<SingleProductCard
|
|
112
|
+
key={i}
|
|
113
|
+
isSoldOut={product.inventoried && !product.quantity}
|
|
114
|
+
businessId={businessId}
|
|
115
|
+
product={product}
|
|
116
|
+
onProductClick={onProductClick}
|
|
117
|
+
productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
120
|
+
</>
|
|
121
|
+
</>
|
|
122
|
+
)}
|
|
123
|
+
</React.Fragment>
|
|
124
|
+
);
|
|
125
|
+
})}
|
|
129
126
|
|
|
130
127
|
{(categoryState.loading || isBusinessLoading) && (
|
|
131
128
|
<>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useCallback } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ProductForm as ProductOptions,
|
|
4
4
|
useSession,
|
|
@@ -12,11 +12,12 @@ import { ProductOption } from '../ProductOption';
|
|
|
12
12
|
import Swiper from 'react-native-swiper'
|
|
13
13
|
import FastImage from 'react-native-fast-image';
|
|
14
14
|
import IconAntDesign from 'react-native-vector-icons/AntDesign';
|
|
15
|
+
import YoutubePlayer from "react-native-youtube-iframe"
|
|
15
16
|
import {
|
|
16
17
|
Grayscale
|
|
17
18
|
} from 'react-native-color-matrix-image-filters'
|
|
18
19
|
|
|
19
|
-
import { View, TouchableOpacity, StyleSheet, Dimensions, I18nManager, SafeAreaView } from 'react-native';
|
|
20
|
+
import { View, TouchableOpacity, StyleSheet, Dimensions, I18nManager, SafeAreaView, Button, Alert } from 'react-native';
|
|
20
21
|
|
|
21
22
|
import {
|
|
22
23
|
WrapHeader,
|
|
@@ -158,6 +159,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
158
159
|
const [indexGallery, setIndexGallery] = useState(0)
|
|
159
160
|
const [selOpt, setSelectedOpt] = useState(0);
|
|
160
161
|
const [isHaveWeight, setIsHaveWeight] = useState(false)
|
|
162
|
+
const [playing, setPlaying] = useState(false);
|
|
161
163
|
const [qtyBy, setQtyBy] = useState({
|
|
162
164
|
weight_unit: false,
|
|
163
165
|
pieces: true
|
|
@@ -216,7 +218,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
216
218
|
|
|
217
219
|
const handleRedirectLogin = () => {
|
|
218
220
|
navigation.navigate('Login', {
|
|
219
|
-
store_slug:
|
|
221
|
+
store_slug: props.businessSlug
|
|
220
222
|
});
|
|
221
223
|
};
|
|
222
224
|
|
|
@@ -224,15 +226,34 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
224
226
|
setQtyBy({ [val]: true, [!val]: false })
|
|
225
227
|
}
|
|
226
228
|
|
|
229
|
+
const onStateChange = useCallback((state) => {
|
|
230
|
+
if (state === "ended") {
|
|
231
|
+
setPlaying(false);
|
|
232
|
+
}
|
|
233
|
+
}, []);
|
|
234
|
+
|
|
235
|
+
const togglePlaying = useCallback(() => {
|
|
236
|
+
setPlaying((prev) => !prev);
|
|
237
|
+
}, []);
|
|
238
|
+
|
|
227
239
|
useEffect(() => {
|
|
228
|
-
const
|
|
229
|
-
|
|
240
|
+
const imageList: any = []
|
|
241
|
+
const videoList: any = []
|
|
242
|
+
product?.images && imageList.push(product.images)
|
|
230
243
|
if (product?.gallery && product?.gallery.length > 0) {
|
|
231
244
|
for (const img of product?.gallery) {
|
|
232
|
-
|
|
245
|
+
if (img?.file) {
|
|
246
|
+
imageList.push(img?.file)
|
|
247
|
+
}
|
|
248
|
+
if (img?.video) {
|
|
249
|
+
const keys = img?.video.split('/')
|
|
250
|
+
const _videoId = keys[keys.length - 1]
|
|
251
|
+
videoList.push(_videoId)
|
|
252
|
+
}
|
|
233
253
|
}
|
|
234
254
|
}
|
|
235
|
-
|
|
255
|
+
const gallery = imageList.concat(videoList)
|
|
256
|
+
setGallery(gallery)
|
|
236
257
|
|
|
237
258
|
if (product?.weight && product?.weight_unit) {
|
|
238
259
|
setIsHaveWeight(true)
|
|
@@ -349,18 +370,30 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
349
370
|
</View>
|
|
350
371
|
}
|
|
351
372
|
>
|
|
352
|
-
{gallery.length > 0 && gallery.map((img, i) => (
|
|
373
|
+
{gallery && gallery.length > 0 && gallery.map((img, i) => (
|
|
353
374
|
<View
|
|
354
375
|
style={styles.slide1}
|
|
355
376
|
key={i}
|
|
356
377
|
>
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
378
|
+
{img.includes('image') ? (
|
|
379
|
+
<FastImage
|
|
380
|
+
style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1 }}
|
|
381
|
+
source={{
|
|
382
|
+
uri: optimizeImage(img, 'h_258,c_limit'),
|
|
383
|
+
priority: FastImage.priority.normal,
|
|
384
|
+
}}
|
|
385
|
+
/>
|
|
386
|
+
) : (
|
|
387
|
+
<>
|
|
388
|
+
<YoutubePlayer
|
|
389
|
+
height={300}
|
|
390
|
+
play={playing}
|
|
391
|
+
videoId={img}
|
|
392
|
+
onChangeState={onStateChange}
|
|
393
|
+
/>
|
|
394
|
+
<Button title={playing ? "pause" : "play"} onPress={togglePlaying} />
|
|
395
|
+
</>
|
|
396
|
+
)}
|
|
364
397
|
</View>
|
|
365
398
|
))}
|
|
366
399
|
</Swiper>
|
|
@@ -384,18 +417,33 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
384
417
|
opacity: index === thumbsSwiper ? 1 : 0.8
|
|
385
418
|
}}
|
|
386
419
|
>
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
420
|
+
{img.includes('image') ? (
|
|
421
|
+
<OIcon
|
|
422
|
+
url={img}
|
|
423
|
+
style={{
|
|
424
|
+
borderColor: theme.colors.lightGray,
|
|
425
|
+
borderRadius: 8,
|
|
426
|
+
minHeight: '100%',
|
|
427
|
+
opacity: isSoldOut ? 0.5 : 1
|
|
428
|
+
}}
|
|
429
|
+
width={56}
|
|
430
|
+
height={56}
|
|
431
|
+
cover
|
|
432
|
+
/>
|
|
433
|
+
) : (
|
|
434
|
+
<OIcon
|
|
435
|
+
url={'http://img.youtube.com/vi/' + img + '/0.jpg'}
|
|
436
|
+
style={{
|
|
437
|
+
borderColor: theme.colors.lightGray,
|
|
438
|
+
borderRadius: 8,
|
|
439
|
+
minHeight: '100%',
|
|
440
|
+
opacity: isSoldOut ? 0.5 : 1
|
|
441
|
+
}}
|
|
442
|
+
width={56}
|
|
443
|
+
height={56}
|
|
444
|
+
cover
|
|
445
|
+
/>
|
|
446
|
+
)}
|
|
399
447
|
</View>
|
|
400
448
|
</TouchableOpacity>
|
|
401
449
|
|
|
@@ -203,7 +203,7 @@ export interface BusinessProductsListParams {
|
|
|
203
203
|
errors?: any;
|
|
204
204
|
businessId?: number;
|
|
205
205
|
category?: any;
|
|
206
|
-
categories
|
|
206
|
+
categories: Array<any>;
|
|
207
207
|
categoryState?: any;
|
|
208
208
|
onProductClick?: any;
|
|
209
209
|
handleSearchRedirect?: () => {};
|