ordering-ui-react-native 0.12.12 → 0.12.16

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.
@@ -230,139 +230,139 @@ export const ProductOptionsUI = (props: any) => {
230
230
 
231
231
  return (
232
232
  <>
233
- <Animated.View style={[styles.header, { height: headerHeight }]}>
234
- <Animated.View style={{ opacity: navBar1ContainerOpacity }}>
235
- <NavBar
236
- {...navBarProps}
237
- titleColor={theme.colors.white}
238
- {...((navigation || onClose) && { leftImg: theme.images.general.arrow_left_white })}
239
- btnStyle={{
240
- width: 55,
241
- height: 55,
242
- backgroundColor: 'black',
243
- borderRadius: 100,
244
- opacity: 0.8,
245
- left: 20,
246
- }}
247
- imgLeftStyle={{ width: 27, height: 27 }}
248
- />
249
- </Animated.View>
250
- <Animated.View style={{ opacity: navBar2ContainerOpacity, position: 'absolute' }}>
251
- <NavBar
252
- {...navBarProps}
253
- {...((navigation || onClose) && { leftImg: theme.images.general.arrow_left })}
254
- btnStyle={{
255
- width: 55,
256
- height: 55,
257
- backgroundColor: 'transparent',
258
- borderRadius: 100,
259
- left: 20,
260
- }}
261
- imgLeftStyle={{ width: 27, height: 27 }}
262
- />
263
- </Animated.View>
264
-
265
- <Animated.View style={{
266
- backgroundColor: 'white',
267
- width: orientationState?.dimensions?.width,
268
- opacity: collapsedBarContainerOpacity,
269
- }}>
270
- <View
271
- style={{
272
- flexDirection: 'row',
273
- alignItems: 'center',
274
- padding: 20,
275
- paddingTop: 0,
276
- paddingBottom: 10
277
- }}
278
- >
279
- <OImage
280
- source={{uri: product?.images}}
281
- width={70}
282
- height={70}
283
- resizeMode="cover"
284
- borderRadius={6}
233
+ <ScrollView
234
+ style={styles.mainContainer}
235
+ contentContainerStyle={styles.scrollContainer}
236
+ onScroll={Animated.event(
237
+ [{ nativeEvent: { contentOffset: { y: scrollY }} }],
238
+ {useNativeDriver: false})
239
+ }
240
+ scrollEventThrottle={16}
241
+ >
242
+ <Animated.View style={[styles.header, { height: headerHeight }]}>
243
+ <Animated.View style={{ opacity: navBar1ContainerOpacity }}>
244
+ <NavBar
245
+ {...navBarProps}
246
+ titleColor={theme.colors.white}
247
+ {...((navigation || onClose) && { leftImg: theme.images.general.arrow_left_white })}
248
+ btnStyle={{
249
+ width: 55,
250
+ height: 55,
251
+ backgroundColor: 'black',
252
+ borderRadius: 100,
253
+ opacity: 0.8,
254
+ left: 20,
255
+ }}
256
+ imgLeftStyle={{ width: 27, height: 27 }}
257
+ />
258
+ </Animated.View>
259
+ <Animated.View style={{ opacity: navBar2ContainerOpacity, position: 'absolute' }}>
260
+ <NavBar
261
+ {...navBarProps}
262
+ {...((navigation || onClose) && { leftImg: theme.images.general.arrow_left })}
263
+ btnStyle={{
264
+ width: 55,
265
+ height: 55,
266
+ backgroundColor: 'transparent',
267
+ borderRadius: 100,
268
+ left: 20,
269
+ }}
270
+ imgLeftStyle={{ width: 27, height: 27 }}
285
271
  />
286
- <OText
287
- size={orientationState?.dimensions?.width * 0.025}
288
- weight="bold"
289
- mLeft={20}
290
- numberOfLines={2}
272
+ </Animated.View>
273
+
274
+ <Animated.View style={{
275
+ backgroundColor: 'white',
276
+ width: orientationState?.dimensions?.width,
277
+ opacity: collapsedBarContainerOpacity,
278
+ }}>
279
+ <View
280
+ style={{
281
+ flexDirection: 'row',
282
+ alignItems: 'center',
283
+ padding: 20,
284
+ paddingTop: 0,
285
+ paddingBottom: 10
286
+ }}
291
287
  >
292
- {product?.name}
293
- </OText>
294
- </View>
295
- <View
296
- style={{
297
- position: 'absolute',
298
- bottom: -2,
299
- height: 1,
300
- backgroundColor: 'white',
301
- width: orientationState?.dimensions?.width,
302
- ...styles.shadow,
303
- }}
304
- />
305
- </Animated.View>
288
+ <OImage
289
+ source={{uri: product?.images}}
290
+ width={70}
291
+ height={70}
292
+ resizeMode="cover"
293
+ borderRadius={6}
294
+ />
295
+ <OText
296
+ size={orientationState?.dimensions?.width * 0.025}
297
+ weight="bold"
298
+ mLeft={20}
299
+ numberOfLines={2}
300
+ >
301
+ {product?.name}
302
+ </OText>
303
+ </View>
304
+ <View
305
+ style={{
306
+ position: 'absolute',
307
+ bottom: -2,
308
+ height: 1,
309
+ backgroundColor: 'white',
310
+ width: orientationState?.dimensions?.width,
311
+ ...styles.shadow,
312
+ }}
313
+ />
314
+ </Animated.View>
306
315
 
307
- <Animated.View style={{
308
- opacity: heroContainerOpacity,
309
- position: 'absolute',
310
- zIndex: -100,
311
- transform: [{translateY: heroTranslateY }],
312
- }}>
313
- <View
314
- style={{
315
- width: orientationState?.dimensions?.width,
316
- height: HEADER_EXPANDED_HEIGHT,
317
- position: 'absolute',
318
- zIndex: 1,
319
- backgroundColor: 'rgba(24, 28, 50, 0.4)',
320
- }}
321
- >
322
- <ImageBackground source={{ uri: product?.images }} resizeMode='cover' style={{ flex:1, justifyContent: 'center' }} />
316
+ <Animated.View style={{
317
+ opacity: heroContainerOpacity,
318
+ position: 'absolute',
319
+ zIndex: -100,
320
+ transform: [{translateY: heroTranslateY }],
321
+ }}>
322
+ <View
323
+ style={{
324
+ width: orientationState?.dimensions?.width,
325
+ height: HEADER_EXPANDED_HEIGHT,
326
+ position: 'absolute',
327
+ zIndex: 1,
328
+ backgroundColor: 'rgba(24, 28, 50, 0.4)',
329
+ }}
330
+ >
331
+ <ImageBackground source={{ uri: product?.images }} resizeMode='cover' style={{ flex:1, justifyContent: 'center' }} />
323
332
 
324
- </View>
333
+ </View>
325
334
 
326
- <Animated.View
327
- style={{
328
- transform: [{translateY: heroTranslateY }],
329
- width: orientationState?.dimensions?.width * 0.75,
330
- height: HEADER_EXPANDED_HEIGHT / 2,
331
- position: 'relative',
332
- top: HEADER_EXPANDED_HEIGHT / 3,
333
- zIndex: 100,
334
- padding: 20,
335
- }}
336
- >
337
- <OText
338
- color={theme.colors.white}
339
- size={orientationState?.dimensions?.width * 0.048}
340
- weight="bold"
341
- mBottom={10}
342
- numberOfLines={2}
335
+ <Animated.View
336
+ style={{
337
+ transform: [{translateY: heroTranslateY }],
338
+ width: orientationState?.dimensions?.width * 0.75,
339
+ height: HEADER_EXPANDED_HEIGHT / 2,
340
+ position: 'relative',
341
+ top: HEADER_EXPANDED_HEIGHT / 3,
342
+ zIndex: 100,
343
+ padding: 20,
344
+ }}
343
345
  >
344
- {product?.name || productCart?.name}
345
- </OText>
346
+ <OText
347
+ color={theme.colors.white}
348
+ size={orientationState?.dimensions?.width * 0.048}
349
+ weight="bold"
350
+ mBottom={10}
351
+ numberOfLines={2}
352
+ >
353
+ {product?.name || productCart?.name}
354
+ </OText>
346
355
 
347
- <OText
348
- color={theme.colors.white}
349
- numberOfLines={4}
350
- >
351
- {product?.description || productCart?.description}
352
- </OText>
356
+ <OText
357
+ color={theme.colors.white}
358
+ numberOfLines={4}
359
+ >
360
+ {product?.description || productCart?.description}
361
+ </OText>
362
+ </Animated.View>
353
363
  </Animated.View>
354
364
  </Animated.View>
355
- </Animated.View>
356
365
 
357
- <ScrollView
358
- style={styles.mainContainer}
359
- contentContainerStyle={styles.scrollContainer}
360
- onScroll={Animated.event(
361
- [{ nativeEvent: { contentOffset: { y: scrollY }} }],
362
- {useNativeDriver: false})
363
- }
364
- scrollEventThrottle={16}
365
- >
366
366
  {!isFromCheckout && (
367
367
  <Spinner visible={loading} />
368
368
  )}
@@ -40,6 +40,7 @@ import { BusinessFeaturedController } from '../BusinessFeaturedController';
40
40
  import { HighestRatedBusinesses } from '../HighestRatedBusinesses';
41
41
  import { getTypesText } from '../../utils';
42
42
  import { OrderProgress } from '../OrderProgress';
43
+ import { useIsFocused } from '@react-navigation/native';
43
44
 
44
45
  const PIXELS_TO_SCROLL = 1000;
45
46
 
@@ -56,7 +57,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
56
57
  } = props;
57
58
 
58
59
  const theme = useTheme();
59
-
60
+ const isFocused = useIsFocused();
60
61
 
61
62
  const styles = StyleSheet.create({
62
63
  container: {
@@ -226,11 +227,13 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
226
227
  </View>
227
228
  </OrderControlContainer>
228
229
  </HeaderWrapper>
229
- <OrderProgressWrapper>
230
- <OrderProgress
231
- {...props}
232
- />
233
- </OrderProgressWrapper>
230
+ {isFocused && (
231
+ <OrderProgressWrapper>
232
+ <OrderProgress
233
+ {...props}
234
+ />
235
+ </OrderProgressWrapper>
236
+ )}
234
237
  {featuredBusiness && featuredBusiness.length > 0 && (
235
238
  <FeaturedWrapper>
236
239
  <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('FEATURED_BUSINESS', 'Featured business')}</OText>
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useEffect, useState } from 'react'
2
2
  import {
3
3
  OrderList,
4
4
  useLanguage,
@@ -10,7 +10,7 @@ import moment from 'moment';
10
10
  import { OText } from '../shared'
11
11
  import { NotFoundSource } from '../NotFoundSource'
12
12
  import { View, StyleSheet, TouchableOpacity } from 'react-native'
13
- import { Placeholder, Fade } from "rn-placeholder";
13
+ import { Placeholder, Fade, PlaceholderLine } from "rn-placeholder";
14
14
  import FastImage from 'react-native-fast-image'
15
15
  import {
16
16
  ProgressContentWrapper,
@@ -29,8 +29,8 @@ const OrderProgressUI = (props: any) => {
29
29
  const theme = useTheme();
30
30
 
31
31
  const [, t] = useLanguage()
32
- const { loading, error, orders: values } = orderList
33
32
  const [{ optimizeImage, parseDate, parseTime }] = useUtils()
33
+ const [lastOrder, setLastOrder] = useState<any>(null)
34
34
  const imageFails = theme.images.general.emptyActiveOrders
35
35
 
36
36
  const styles = StyleSheet.create({
@@ -103,13 +103,14 @@ const OrderProgressUI = (props: any) => {
103
103
  return objectStatus && objectStatus
104
104
  }
105
105
 
106
- const convertDiffToHours = (time: any, order: any) => {
106
+ const convertDiffToHours = (order: any) => {
107
+ const time = order.delivery_type === 1 ? order?.business?.delivery_time : order?.business?.pickup_time
107
108
  const deliveryTime = order?.delivery_datetime_utc
108
- ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD hh:mm A' })
109
- : parseDate(order?.delivery_datetime, { utc: false, outputFormat: 'YYYY-MM-DD hh:mm A' })
109
+ ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD HH:mm' })
110
+ : parseDate(order?.delivery_datetime, { utc: false, outputFormat: 'YYYY-MM-DD HH:mm' })
110
111
  const [hour, minute] = time.split(':')
111
112
  const result = time ? (parseInt(hour, 10) * 60) + parseInt(minute, 10) : 0
112
- const returnedDate = moment(new Date(deliveryTime)).add(result, 'minutes').format('hh:mm A')
113
+ const returnedDate = moment(deliveryTime).add(result, 'minutes').format('hh:mm A')
113
114
  return returnedDate
114
115
  }
115
116
 
@@ -117,17 +118,30 @@ const OrderProgressUI = (props: any) => {
117
118
  navigation && navigation.navigate(index)
118
119
  }
119
120
 
121
+ useEffect(() => {
122
+ if (orderList?.orders.length > 0) {
123
+ const sortedOrders = orderList.orders.sort((a: any, b:any) => a.id > b.id ? -1 : 1)
124
+ setLastOrder(sortedOrders[0])
125
+ }
126
+ }, [orderList?.orders])
127
+
120
128
  return (
121
129
  <>
122
- {orderList?.loading && <Placeholder height={150} Animation={Fade} />}
123
- {!orderList?.loading && orderList?.orders?.length > 0 && orderList?.orders.map((order: any) => (
124
- <View style={styles.main} key={order.id}>
130
+ {orderList?.loading && (
131
+ <Placeholder Animation={Fade} height={130}>
132
+ <PlaceholderLine height={50} style={{ borderRadius: 8, marginBottom: 10 }} />
133
+ <PlaceholderLine height={15} style={{ marginBottom: 10 }} />
134
+ <PlaceholderLine height={30} style={{ borderRadius: 8, marginBottom: 10 }} />
135
+ </Placeholder>
136
+ )}
137
+ {!orderList?.loading && orderList?.orders?.length > 0 && lastOrder && (
138
+ <View style={styles.main}>
125
139
  <OrderInfoWrapper style={{ flex: 1 }}>
126
140
  <View style={styles.logoWrapper}>
127
141
  <FastImage
128
142
  style={{ width: 50, height: 50 }}
129
143
  source={{
130
- uri: optimizeImage(order?.business?.logo, 'h_50,c_limit'),
144
+ uri: optimizeImage(lastOrder?.business?.logo, 'h_50,c_limit'),
131
145
  priority: FastImage.priority.normal,
132
146
  }}
133
147
  resizeMode={FastImage.resizeMode.cover}
@@ -161,24 +175,24 @@ const OrderProgressUI = (props: any) => {
161
175
  </OrderInfoWrapper>
162
176
  <View style={{ flex: 1 }}>
163
177
  <ProgressContentWrapper>
164
- <ProgressBar style={{ width: getOrderStatus(order.status)?.percentage ? `${getOrderStatus(order.status)?.percentage}%` : '0%' }} />
178
+ <ProgressBar style={{ width: getOrderStatus(lastOrder.status)?.percentage ? `${getOrderStatus(lastOrder.status)?.percentage}%` : '0%' }} />
165
179
  </ProgressContentWrapper>
166
180
  <ProgressTextWrapper>
167
- <OText size={12}>{getOrderStatus(order.status)?.value}</OText>
181
+ <OText size={12}>{getOrderStatus(lastOrder.status)?.value}</OText>
168
182
  <TimeWrapper>
169
183
  <OText size={11}>{t('ESTIMATED_DELIVERY', 'Estimated delivery')}</OText>
170
184
  <OText size={11}>
171
- {order?.delivery_datetime_utc
172
- ? parseTime(order?.delivery_datetime_utc, { outputFormat: 'hh:mm A' })
173
- : parseTime(order?.delivery_datetime, { utc: false })}
185
+ {lastOrder?.delivery_datetime_utc
186
+ ? parseTime(lastOrder?.delivery_datetime_utc, { outputFormat: 'hh:mm A' })
187
+ : parseTime(lastOrder?.delivery_datetime, { utc: false })}
174
188
  &nbsp;-&nbsp;
175
- {convertDiffToHours(order.delivery_type === 1 ? order?.business?.delivery_time : order?.business?.pickup_time, order)}
189
+ {convertDiffToHours(lastOrder)}
176
190
  </OText>
177
191
  </TimeWrapper>
178
192
  </ProgressTextWrapper>
179
193
  </View>
180
194
  </View>
181
- ))}
195
+ )}
182
196
  {!orderList?.loading && orderList?.orders?.length === 0 && (
183
197
  <NotFoundSource
184
198
  image={imageFails}