ordering-ui-react-native 0.16.53 → 0.16.54

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.
@@ -0,0 +1,118 @@
1
+ import React, { useState } from 'react'
2
+ import FontAwesome from 'react-native-vector-icons/FontAwesome';
3
+ import { useLanguage, useUtils } from 'ordering-components/native'
4
+
5
+ import {
6
+ ReviewOrderContainer,
7
+ BusinessLogo,
8
+ FormReviews,
9
+ ActionContainer,
10
+ RatingStarContainer,
11
+ PlacedDate
12
+ } from './styles'
13
+ import { OButton, OIcon, OText } from '../shared'
14
+ import { StyleSheet, View, I18nManager } from 'react-native';
15
+ import { FloatingBottomContainer } from '../../layouts/FloatingBottomContainer'
16
+
17
+ import { useTheme } from 'styled-components/native'
18
+
19
+ export const ReviewTrigger = (props: any) => {
20
+ const {
21
+ order,
22
+ handleOpenOrderReview
23
+ } = props
24
+
25
+ const theme = useTheme()
26
+
27
+ const styles = StyleSheet.create({
28
+ logoWrapper: {
29
+ shadowColor: theme.colors.black,
30
+ shadowRadius: 3,
31
+ shadowOffset: { width: 1, height: 4 },
32
+ elevation: 3,
33
+ borderRadius: 8,
34
+ shadowOpacity: 0.1,
35
+ overflow: 'hidden'
36
+ },
37
+ inputTextArea: {
38
+ borderColor: theme.colors.lightGray,
39
+ borderRadius: 8,
40
+ marginTop: 10,
41
+ marginBottom: 40,
42
+ height: 100,
43
+ alignItems: 'flex-start'
44
+ },
45
+ statusBar: {
46
+ transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
47
+ height: 10,
48
+ borderRadius: 5,
49
+ marginTop: 5
50
+ },
51
+ ratingItemContainer: {
52
+ position: 'absolute',
53
+ top: -20
54
+ },
55
+ ratingItem: {
56
+ left: '-50%',
57
+ flexDirection: 'column',
58
+ alignItems: 'center'
59
+ },
60
+ ratingLineStyle: {
61
+ height: 10,
62
+ width: 1,
63
+ marginBottom: 10,
64
+ backgroundColor: theme.colors.dusk
65
+ },
66
+ reviewedStyle: {
67
+ flexDirection: 'row',
68
+ justifyContent: 'center',
69
+ marginVertical: 20
70
+ },
71
+ })
72
+
73
+ const [, t] = useLanguage()
74
+ const [{ parseDate }] = useUtils()
75
+ const placedOnDate = parseDate(order?.delivery_datetime, { utc: true, outputFormat: 'dddd MMMM DD, YYYY' })
76
+ const [star, setStar] = useState(5)
77
+
78
+ return (
79
+ <>
80
+ <ReviewOrderContainer>
81
+ <BusinessLogo>
82
+ <View style={styles.logoWrapper}>
83
+ <OIcon
84
+ url={order?.logo}
85
+ width={80}
86
+ height={80}
87
+ />
88
+ </View>
89
+ </BusinessLogo>
90
+ {!!order?.business_name && <OText style={{ textAlign: 'center', marginTop: 15 }} color={theme.colors.textNormal}>{order?.business_name}</OText>}
91
+ <View style={{ flex: 1, justifyContent: 'flex-end' }}>
92
+ <FormReviews>
93
+ <RatingStarContainer>
94
+ {[...Array(5).keys()].map((index: number) => (<FontAwesome name={(index <= (star - 1)) ? 'star' : 'star-o'} size={28} key={`star-symbol-${index}`} onPress={() => setStar(index + 1)} color={theme?.colors?.primary} />)
95
+ )}
96
+ </RatingStarContainer>
97
+ <PlacedDate>
98
+ <OText color={theme.colors.textNormal}>{t('DONOT_FORGET_RATE_YOUR_ORDER', 'Do not forget to rate your order placed on ')}</OText>
99
+ <OText color={theme.colors.textNormal} style={{ fontWeight: "bold" }}>{placedOnDate}</OText>
100
+ </PlacedDate>
101
+ </FormReviews>
102
+ </View>
103
+ </ReviewOrderContainer>
104
+ <FloatingBottomContainer>
105
+ <ActionContainer>
106
+ <OButton
107
+ textStyle={{ color: theme.colors.white, paddingRight: 10 }}
108
+ text={t('GOTO_REVIEW', 'Go to review')}
109
+ style={{ borderRadius: 8 }}
110
+ imgRightSrc={theme.images.general.arrow_right}
111
+ imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
112
+ onClick={() => handleOpenOrderReview(star)}
113
+ />
114
+ </ActionContainer>
115
+ </FloatingBottomContainer>
116
+ </>
117
+ )
118
+ }
@@ -16,32 +16,13 @@ export const FormReviews = styled.View`
16
16
  margin-top: 30px;
17
17
  `
18
18
 
19
- export const CommentsButtonGroup = styled.View`
20
- flex-direction: row;
21
- flex-wrap: wrap;
22
- `
23
-
24
19
  export const ActionContainer = styled.View`
25
20
  flex-direction: row;
26
21
  align-items: center;
27
- justify-content: space-between;
22
+ justify-content: center;
28
23
  padding: 3px 30px;
29
24
  `
30
25
 
31
- export const SkipButton = styled.TouchableOpacity`
32
- `
33
-
34
- export const RatingBarContainer = styled.View`
35
- margin-top: 10px;
36
- margin-bottom: 25px;
37
- `
38
-
39
- export const RatingTextContainer = styled.View`
40
- flex-direction: row;
41
- align-items: center;
42
- justify-content: space-between;
43
- margin-top: 10px;
44
- `
45
26
  export const RatingStarContainer = styled.View`
46
27
  flex-direction: row;
47
28
  align-items: center;
@@ -50,4 +31,4 @@ export const RatingStarContainer = styled.View`
50
31
  `
51
32
  export const PlacedDate = styled.View`
52
33
  margin-top: 30px;
53
- `
34
+ `
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import {
3
3
  useLanguage,
4
4
  useConfig,
@@ -10,6 +10,8 @@ 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
12
  import { StyleSheet, View, TouchableOpacity, Image } from 'react-native';
13
+ import { InView } from 'react-native-intersection-observer'
14
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
13
15
  import { OButton, OText } from '../shared';
14
16
  import FastImage from 'react-native-fast-image'
15
17
  import IconAntDesign from 'react-native-vector-icons/AntDesign'
@@ -29,7 +31,8 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
29
31
  onProductClick,
30
32
  productAddedToCartLength,
31
33
  style,
32
- handleFavoriteProduct
34
+ handleFavoriteProduct,
35
+ enableIntersection
33
36
  } = props;
34
37
 
35
38
  const theme = useTheme();
@@ -87,7 +90,8 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
87
90
  const [, t] = useLanguage();
88
91
  const [stateConfig] = useConfig();
89
92
  const [{ parsePrice, optimizeImage }] = useUtils();
90
- const [orderState] = useOrder();
93
+ const [orderState] = useOrder()
94
+ const [isIntersectionObserver, setIsIntersectionObserver] = useState(!enableIntersection)
91
95
 
92
96
  const editMode = typeof product?.code !== 'undefined';
93
97
 
@@ -118,122 +122,126 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
118
122
  }
119
123
 
120
124
  return (
121
- <CardContainer
122
- showAddButton={showAddButton}
123
- style={[
124
- styles.container,
125
- (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
126
- (style && { ...style }),
127
- ]}
128
- onPress={() => onProductClick?.(product)}
129
- >
130
- <View style={{ flexDirection: 'row' }}>
131
- {productAddedToCartLength > 0 && (
132
- <QuantityContainer style={[styles.quantityContainer, {
133
- transform: [{ translateX: 10 }, { translateY: -10 }],
134
- }]}>
135
- <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
136
- </QuantityContainer>
137
- )}
138
- <CardInfo>
139
- <View style={styles.titleWrapper}>
140
- <OText
141
- size={12}
142
- weight={'500'}
143
- numberOfLines={1}
144
- ellipsizeMode="tail"
145
- style={styles.line18}>
146
- {product?.name}
147
- </OText>
148
- <TouchableOpacity
149
- onPress={handleChangeFavorite}
150
- >
151
- <IconAntDesign
152
- name={product?.favorite ? 'heart' : 'hearto'}
153
- color={theme.colors.danger5}
154
- size={18}
155
- />
156
- </TouchableOpacity>
157
- </View>
158
- <PricesContainer>
159
- <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
160
- {product?.offer_price !== null && product?.in_offer && (
161
- <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
125
+ <InView style={{ minHeight: 140 }} triggerOnce={true} onChange={(inView: boolean) => setIsIntersectionObserver(true)}>
126
+ {isIntersectionObserver && (
127
+ <CardContainer
128
+ showAddButton={showAddButton}
129
+ style={[
130
+ styles.container,
131
+ (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
132
+ (style && { ...style }),
133
+ ]}
134
+ onPress={() => onProductClick?.(product)}
135
+ >
136
+ <View style={{ flexDirection: 'row' }}>
137
+ {productAddedToCartLength > 0 && (
138
+ <QuantityContainer style={[styles.quantityContainer, {
139
+ transform: [{ translateX: 10 }, { translateY: -10 }],
140
+ }]}>
141
+ <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
142
+ </QuantityContainer>
162
143
  )}
163
- </PricesContainer>
164
- <OText
165
- size={10}
166
- numberOfLines={2}
167
- ellipsizeMode="tail"
168
- color={theme.colors.textSecondary}
169
- style={styles.line15}>
170
- {product?.description}
171
- </OText>
172
- </CardInfo>
173
- <LogoWrapper>
174
- {product?.ribbon?.enabled && (
175
- <RibbonBox
176
- bgColor={product?.ribbon?.color}
177
- isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
178
- isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
179
- >
144
+ <CardInfo>
145
+ <View style={styles.titleWrapper}>
146
+ <OText
147
+ size={12}
148
+ weight={'500'}
149
+ numberOfLines={1}
150
+ ellipsizeMode="tail"
151
+ style={styles.line18}>
152
+ {product?.name}
153
+ </OText>
154
+ <TouchableOpacity
155
+ onPress={handleChangeFavorite}
156
+ >
157
+ <IconAntDesign
158
+ name={product?.favorite ? 'heart' : 'hearto'}
159
+ color={theme.colors.danger5}
160
+ size={18}
161
+ />
162
+ </TouchableOpacity>
163
+ </View>
164
+ <PricesContainer>
165
+ <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
166
+ {product?.offer_price !== null && product?.in_offer && (
167
+ <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
168
+ )}
169
+ </PricesContainer>
180
170
  <OText
181
171
  size={10}
182
- weight={'400'}
183
- color={theme.colors.white}
184
172
  numberOfLines={2}
185
- ellipsizeMode='tail'
186
- lineHeight={13}
187
- >
188
- {product?.ribbon?.text}
173
+ ellipsizeMode="tail"
174
+ color={theme.colors.textSecondary}
175
+ style={styles.line15}>
176
+ {product?.description}
189
177
  </OText>
190
- </RibbonBox>
191
- )}
192
- {product?.images ? (
193
- <FastImage
194
- style={styles.productStyle}
195
- source={{
196
- uri: optimizeImage(product?.images, 'h_250,c_limit'),
197
- priority: FastImage.priority.normal,
198
- }}
199
- resizeMode={FastImage.resizeMode.cover}
200
- />
201
- ) : (
202
- <FastImage
203
- style={styles.productStyle}
204
- source={{
205
- uri: Image.resolveAssetSource(theme.images.dummies.product).uri,
206
- priority: FastImage.priority.normal,
178
+ </CardInfo>
179
+ <LogoWrapper>
180
+ {product?.ribbon?.enabled && (
181
+ <RibbonBox
182
+ bgColor={product?.ribbon?.color}
183
+ isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
184
+ isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
185
+ >
186
+ <OText
187
+ size={10}
188
+ weight={'400'}
189
+ color={theme.colors.white}
190
+ numberOfLines={2}
191
+ ellipsizeMode='tail'
192
+ lineHeight={13}
193
+ >
194
+ {product?.ribbon?.text}
195
+ </OText>
196
+ </RibbonBox>
197
+ )}
198
+ {product?.images ? (
199
+ <FastImage
200
+ style={styles.productStyle}
201
+ source={{
202
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
203
+ priority: FastImage.priority.normal,
204
+ }}
205
+ resizeMode={FastImage.resizeMode.cover}
206
+ />
207
+ ) : (
208
+ <FastImage
209
+ style={styles.productStyle}
210
+ source={{
211
+ uri: Image.resolveAssetSource(theme.images.dummies.product).uri,
212
+ priority: FastImage.priority.normal,
213
+ }}
214
+ resizeMode={FastImage.resizeMode.cover}
215
+ />
216
+ )}
217
+ </LogoWrapper>
218
+
219
+ {(isSoldOut || maxProductQuantity <= 0) && (
220
+ <SoldOut>
221
+ <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
222
+ {t('SOLD_OUT', 'SOLD OUT')}
223
+ </OText>
224
+ </SoldOut>
225
+ )}
226
+ </View>
227
+ {showAddButton && (
228
+ <OButton
229
+ onClick={() => onProductClick?.(product)}
230
+ style={{
231
+ width: '100%',
232
+ borderRadius: 7.6,
233
+ marginTop: 10,
234
+
207
235
  }}
208
- resizeMode={FastImage.resizeMode.cover}
236
+ bgColor={isSoldOut ? '#B8B8B8' : theme?.colors?.white}
237
+ borderColor={theme?.colors.primary}
238
+ textStyle={{ color: theme.colors.primary }}
239
+ text={t('ADD', 'Add')}
209
240
  />
210
241
  )}
211
- </LogoWrapper>
212
-
213
- {(isSoldOut || maxProductQuantity <= 0) && (
214
- <SoldOut>
215
- <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
216
- {t('SOLD_OUT', 'SOLD OUT')}
217
- </OText>
218
- </SoldOut>
219
- )}
220
- </View>
221
- {showAddButton && (
222
- <OButton
223
- onClick={() => onProductClick?.(product)}
224
- style={{
225
- width: '100%',
226
- borderRadius: 7.6,
227
- marginTop: 10,
228
-
229
- }}
230
- bgColor={isSoldOut ? '#B8B8B8' : theme?.colors?.white}
231
- borderColor={theme?.colors.primary}
232
- textStyle={{color: theme.colors.primary}}
233
- text={t('ADD', 'Add')}
234
- />
242
+ </CardContainer>
235
243
  )}
236
- </CardContainer>
244
+ </InView>
237
245
  );
238
246
  }, SingleProductCardPropsAreEqual);
239
247
 
@@ -6,6 +6,7 @@ const deviceHeight = Dimensions.get('window').height
6
6
 
7
7
  interface Props {
8
8
  open: boolean;
9
+ transparent?: boolean;
9
10
  title?: string;
10
11
  children?: any;
11
12
  onClose?: any;
@@ -17,6 +18,7 @@ interface Props {
17
18
  const OBottomPopup = (props: Props) => {
18
19
  const {
19
20
  open,
21
+ transparent,
20
22
  title,
21
23
  onClose,
22
24
  children,
@@ -26,10 +28,11 @@ const OBottomPopup = (props: Props) => {
26
28
  closeIcon
27
29
  } = props
28
30
  const { top, bottom } = useSafeAreaInsets();
31
+
29
32
  return (
30
33
  <Modal
31
34
  animationType='slide'
32
- transparent={false}
35
+ transparent={transparent}
33
36
  visible={open}
34
37
  onRequestClose={() => onClose()}
35
38
  presentationStyle={'fullScreen'}
@@ -69,7 +72,7 @@ const styles = StyleSheet.create({
69
72
  container: {
70
73
  flex: 1,
71
74
  backgroundColor: '#000000AA',
72
- justifyContent: 'flex-end',
75
+ justifyContent: 'flex-end'
73
76
  },
74
77
  touchableOutsideStyle: {
75
78
  flex: 1,
@@ -417,8 +417,9 @@ export interface ProductItemAccordionParams {
417
417
  isFromCheckout?: any
418
418
  }
419
419
  export interface ReviewOrderParams {
420
- order?: { id: number, business_id: number, business_name?: string, delivery_datetime?: string, logo: string, driver: any, products: Array<any>, review: any, user_review: any };
420
+ order?: { id: number, business_id: number, logo: string, driver: any, products: Array<any>, review: any, user_review: any };
421
421
  stars?: any;
422
+ defaultStar?: number;
422
423
  handleChangeInput?: any;
423
424
  handleChangeRating?: any;
424
425
  handleSendReview?: any;
@@ -428,8 +429,6 @@ export interface ReviewOrderParams {
428
429
  handleReviewState?: any;
429
430
  setStars?: any;
430
431
  onNavigationRedirect?: any;
431
- closeReviewOrder?: () => void;
432
- skipReview?: () => void;
433
432
  }
434
433
  export interface ReviewProductParams {
435
434
  navigation?: any,
@@ -438,7 +437,6 @@ export interface ReviewProductParams {
438
437
  formState?: any,
439
438
  handleChangeFormState?: any,
440
439
  handleSendProductReview?: any;
441
- closeReviewProduct?: () => void;
442
440
  }
443
441
  export interface SingleProductReviewParams {
444
442
  product: any,
@@ -454,7 +452,6 @@ export interface ReviewDriverParams {
454
452
  dirverReviews?: any,
455
453
  setDriverReviews?: any,
456
454
  handleSendDriverReview?: any;
457
- closeReviewDriver?: () => void;
458
455
  }
459
456
  export interface MessagesParams {
460
457
  type?: string,