ordering-ui-react-native 0.16.64 → 0.16.67

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.64",
3
+ "version": "0.16.67",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
3
3
  import {
4
4
  BusinessController as BusinessSingleCard,
@@ -11,7 +11,7 @@ import {
11
11
  ToastType
12
12
  } from 'ordering-components/native';
13
13
  import { OIcon, OText } from '../shared';
14
- import { StyleSheet, TouchableOpacity, View } from 'react-native';
14
+ import { StyleSheet, TouchableOpacity, View, Animated } from 'react-native';
15
15
  import { InView } from 'react-native-intersection-observer'
16
16
  import { BusinessControllerParams } from '../../types';
17
17
  import { convertHoursToMinutes, shape } from '../../utils';
@@ -59,6 +59,8 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
59
59
  const [, t] = useLanguage();
60
60
  const theme = useTheme()
61
61
  const [isIntersectionObserver, setIsIntersectionObserver] = useState(!enableIntersection)
62
+ const fadeAnim = useRef(new Animated.Value(0)).current;
63
+
62
64
  const styles = StyleSheet.create({
63
65
  headerStyle: {
64
66
  borderTopLeftRadius: 7.6,
@@ -144,8 +146,25 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
144
146
  }
145
147
  }
146
148
 
149
+ const fadeIn = () => {
150
+ Animated.timing(fadeAnim, {
151
+ toValue: 1,
152
+ duration: 500,
153
+ useNativeDriver: true
154
+ }).start();
155
+ };
156
+
157
+ const handleChangeInterSection = (inView: boolean) => {
158
+ setIsIntersectionObserver(inView)
159
+ fadeIn()
160
+ }
161
+
162
+ useEffect(() => {
163
+ if (!enableIntersection) fadeIn()
164
+ }, [enableIntersection])
165
+
147
166
  return (
148
- <InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => setIsIntersectionObserver(inView)}>
167
+ <InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeInterSection(inView)}>
149
168
  {isIntersectionObserver ? (
150
169
  <Card activeOpacity={1} onPress={() => handleBusinessClick(business)} style={style}>
151
170
  {business?.ribbon?.enabled && (
@@ -167,6 +186,13 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
167
186
  </RibbonBox>
168
187
  )}
169
188
  <BusinessHero>
189
+ <Animated.View
190
+ style={[
191
+ {
192
+ opacity: fadeAnim
193
+ }
194
+ ]}
195
+ >
170
196
  <FastImage
171
197
  style={{ height: 120 }}
172
198
  source={{
@@ -175,6 +201,7 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
175
201
  }}
176
202
  resizeMode={FastImage.resizeMode.cover}
177
203
  />
204
+ </Animated.View>
178
205
  {(businessFeatured ?? business?.featured) && (
179
206
  <View style={styles.featured}>
180
207
  <FontAwesomeIcon name="crown" size={26} color="gold" />
@@ -129,7 +129,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
129
129
  onProductClick={() => onProductClick(product)}
130
130
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
131
131
  handleUpdateProducts={handleUpdateProducts}
132
- navigation={navigation}
132
+ navigation={navigation}
133
133
  />
134
134
  ))
135
135
  }
@@ -8,7 +8,7 @@ import {
8
8
  useValidationFields,
9
9
  } from 'ordering-components/native';
10
10
  import { useTheme } from 'styled-components/native';
11
- import { CContainer, CheckoutAction, Divider } from './styles';
11
+ import { CContainer, CheckoutAction, Divider, DriverTipsContainer } from './styles';
12
12
 
13
13
  import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
14
14
 
@@ -25,6 +25,7 @@ import { TaxInformation } from '../TaxInformation';
25
25
  import { CartStoresListing } from '../CartStoresListing';
26
26
  import { OAlert } from '../../../../../src/components/shared'
27
27
  import { PlaceSpot } from '../PlaceSpot'
28
+ import { DriverTips } from '../DriverTips'
28
29
 
29
30
  const CartUI = (props: any) => {
30
31
  const {
@@ -66,6 +67,10 @@ const CartUI = (props: any) => {
66
67
  const businessId = business?.business_id ?? null
67
68
  const placeSpotTypes = [4]
68
69
 
70
+ const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
71
+ ? JSON.parse(configs?.driver_tip_options?.value) || []
72
+ : configs?.driver_tip_options?.value || []
73
+
69
74
  const momentFormatted = !orderState?.option?.moment
70
75
  ? t('RIGHT_NOW', 'Right Now')
71
76
  : parseDate(orderState?.option?.moment, { outputFormat: 'YYYY-MM-DD HH:mm' })
@@ -355,6 +360,32 @@ const CartUI = (props: any) => {
355
360
  </OSTable>
356
361
  )}
357
362
 
363
+ {isMultiCheckout &&
364
+ cart &&
365
+ cart?.valid &&
366
+ orderState?.options?.type === 1 &&
367
+ cart?.status !== 2 &&
368
+ validationFields?.fields?.checkout?.driver_tip?.enabled &&
369
+ driverTipsOptions && driverTipsOptions?.length > 0 &&
370
+ (
371
+ <DriverTipsContainer>
372
+ <OText size={14} lineHeight={20} color={theme.colors.textNormal}>
373
+ {t('DRIVER_TIPS', 'Driver Tips')}
374
+ </OText>
375
+ <DriverTips
376
+ uuid={cart?.uuid}
377
+ businessId={cart?.business_id}
378
+ driverTipsOptions={driverTipsOptions}
379
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
380
+ isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
381
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
382
+ ? cart?.driver_tip
383
+ : cart?.driver_tip_rate}
384
+ useOrderContext
385
+ />
386
+ </DriverTipsContainer>
387
+ )}
388
+
358
389
  <OSTotal>
359
390
  <OSTable style={{ marginTop: 15 }}>
360
391
  <OText size={14} lineHeight={21} weight={'600'}>
@@ -33,3 +33,7 @@ export const Divider = styled.View`
33
33
  margin-top: 5px;
34
34
  margin-bottom: 10px;
35
35
  `
36
+
37
+ export const DriverTipsContainer = styled.View`
38
+ padding: 5px 0;
39
+ `
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import {
3
3
  useLanguage,
4
4
  useConfig,
@@ -11,7 +11,7 @@ import {
11
11
  import { useTheme } from 'styled-components/native';
12
12
  import { SingleProductCardParams } from '../../types';
13
13
  import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper } from './styles';
14
- import { StyleSheet, View, TouchableOpacity, Image } from 'react-native';
14
+ import { StyleSheet, View, TouchableOpacity, Image, Animated } from 'react-native';
15
15
  import { InView } from 'react-native-intersection-observer'
16
16
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
17
17
  import { OButton, OText } from '../shared';
@@ -43,6 +43,8 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
43
43
  const [orderingTheme] = useOrderingTheme()
44
44
  const hideAddButton = orderingTheme?.theme?.business_view?.components?.products?.components?.add_to_cart_button?.hidden
45
45
 
46
+ const fadeAnim = useRef(new Animated.Value(0)).current;
47
+
46
48
  const styles = StyleSheet.create({
47
49
  container: {
48
50
  borderWidth: 1,
@@ -122,6 +124,14 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
122
124
  maxCartProductInventory,
123
125
  );
124
126
 
127
+ const fadeIn = () => {
128
+ Animated.timing(fadeAnim, {
129
+ toValue: 1,
130
+ duration: 500,
131
+ useNativeDriver: true
132
+ }).start();
133
+ };
134
+
125
135
  const handleChangeFavorite = () => {
126
136
  if (auth) {
127
137
  handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
@@ -130,8 +140,17 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
130
140
  }
131
141
  }
132
142
 
143
+ const handleChangeIntersection = () => {
144
+ setIsIntersectionObserver(true);
145
+ fadeIn();
146
+ }
147
+
148
+ useEffect(() => {
149
+ if (!enableIntersection) fadeIn()
150
+ }, [enableIntersection])
151
+
133
152
  return (
134
- <InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => setIsIntersectionObserver(true)}>
153
+ <InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
135
154
  {isIntersectionObserver ? (
136
155
  <CardContainer
137
156
  showAddButton={!hideAddButton}
@@ -204,24 +223,24 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
204
223
  </OText>
205
224
  </RibbonBox>
206
225
  )}
207
- {product?.images ? (
208
- <FastImage
209
- style={styles.productStyle}
210
- source={{
211
- uri: optimizeImage(product?.images, 'h_250,c_limit'),
212
- priority: FastImage.priority.normal,
213
- }}
214
- resizeMode={FastImage.resizeMode.cover}
215
- />
216
- ) : (
217
- <FastImage
218
- style={styles.productStyle}
219
- source={{
220
- uri: Image.resolveAssetSource(theme.images.dummies.product).uri,
221
- priority: FastImage.priority.normal,
222
- }}
223
- resizeMode={FastImage.resizeMode.cover}
224
- />
226
+ {product?.images && (
227
+ <Animated.View
228
+ style={[
229
+ {
230
+ // Bind opacity to animated value
231
+ opacity: fadeAnim
232
+ }
233
+ ]}
234
+ >
235
+ <FastImage
236
+ style={styles.productStyle}
237
+ source={{
238
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
239
+ priority: FastImage.priority.normal,
240
+ }}
241
+ resizeMode={FastImage.resizeMode.cover}
242
+ />
243
+ </Animated.View>
225
244
  )}
226
245
  </LogoWrapper>
227
246