ordering-ui-react-native 0.17.62 → 0.17.64

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.17.62",
3
+ "version": "0.17.64",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -166,14 +166,16 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
166
166
  style={bpStyles.catWrap}
167
167
  onLayout={(event: any) => handleOnLayout(event, category.id)}
168
168
  >
169
- <View style={bpStyles.catIcon}>
170
- <OIcon
171
- url={optimizeImage(category.image, 'h_250,c_limit')}
172
- width={41}
173
- height={41}
174
- style={{ borderRadius: 7.6 }}
175
- />
176
- </View>
169
+ {!!category.image && (
170
+ <View style={bpStyles.catIcon}>
171
+ <OIcon
172
+ url={optimizeImage(category.image, 'h_250,c_limit')}
173
+ width={41}
174
+ height={41}
175
+ style={{ borderRadius: 7.6 }}
176
+ />
177
+ </View>
178
+ )}
177
179
  <OText size={16} weight="600">
178
180
  {category.name}
179
181
  </OText>
@@ -394,7 +394,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
394
394
  <BackgroundGray isIos={Platform.OS === 'ios'} />
395
395
  )}
396
396
  <IOScrollView
397
- stickyHeaderIndices={[business?.professionals?.length > 0 ? 3 : 2]}
397
+ stickyHeaderIndices={[business?.professionals?.length > 0 ? 4 : 3]}
398
398
  style={{
399
399
  ...styles.mainContainer,
400
400
  marginBottom: currentCart?.products?.length > 0 && categoryState.products.length !== 0 ?
@@ -39,8 +39,7 @@ import {
39
39
  BusinessLogosContainer
40
40
  } from './styles';
41
41
 
42
- import { SearchBar } from '../../../SearchBar';
43
- import { OButton, OIcon, OText, OBottomPopup, OModal } from '../../../shared';
42
+ import { OIcon, OText, OModal } from '../../../shared';
44
43
  import { BusinessesListingParams } from '../../../../types';
45
44
  import { NotFoundSource } from '../../../NotFoundSource';
46
45
  import { BusinessTypeFilter } from '../../../BusinessTypeFilter';
@@ -49,12 +48,13 @@ import { OrderTypeSelector } from '../../../OrderTypeSelector';
49
48
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
50
49
  import { BusinessFeaturedController } from '../../../BusinessFeaturedController';
51
50
  import { HighestRatedBusinesses } from '../../../HighestRatedBusinesses';
52
- import { getTypesText, convertToRadian } from '../../../../utils';
51
+ import { getTypesText } from '../../../../utils';
53
52
  import { OrderProgress } from '../../../OrderProgress';
54
53
  import { useFocusEffect, useIsFocused } from '@react-navigation/native';
55
54
  import FastImage from 'react-native-fast-image';
56
55
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
57
56
  import { PageBanner } from '../../../PageBanner'
57
+ import { CitiesControl } from '../../../CitiesControl'
58
58
 
59
59
  const PIXELS_TO_SCROLL = 2000;
60
60
 
@@ -62,12 +62,10 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
62
62
  const {
63
63
  navigation,
64
64
  businessesList,
65
- searchValue,
66
65
  getBusinesses,
67
66
  handleChangeBusinessType,
68
67
  handleBusinessClick,
69
68
  paginationProps,
70
- handleChangeSearch,
71
69
  businessId,
72
70
  isGuestUser,
73
71
  handleUpdateBusinessList,
@@ -79,8 +77,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
79
77
  const [orderingTheme] = useOrderingTheme()
80
78
  const isFocused = useIsFocused();
81
79
  const appState = useRef(AppState.currentState)
82
- const searchBarRef = useRef<any>()
83
- const [appStateVisible, setAppStateVisible] = useState(appState.current);
84
80
  const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
85
81
  const hideCities = theme?.business_listing_view?.components?.cities?.hidden ?? true
86
82
  const [refreshing] = useState(false);
@@ -193,6 +189,10 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
193
189
  }
194
190
  };
195
191
 
192
+ const convertToRadian = (value: number) => {
193
+ return value * Math.PI / 180
194
+ }
195
+
196
196
  const getDistance = (lat1: any, lon1: any, lat2: any, lon2: any) => {
197
197
  const R = 6371 // km
198
198
  const dLat = convertToRadian(lat2 - lat1)
@@ -494,6 +494,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
494
494
  <TouchableOpacity
495
495
  style={styles.buttonCityStyle}
496
496
  onPress={() => setIsOpenCities(true)}
497
+ disabled={orderState?.loading}
497
498
  >
498
499
  <OText size={18} color={theme.colors.backgroundGray} weight='bold' style={{ textAlign: 'center' }}>
499
500
  {citiesState?.cities?.find((city: any) => city?.id === orderState?.options?.city_id)?.name || t('FILTER_BY_CITY', 'Filter by city')}
@@ -652,36 +653,11 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
652
653
  onClose={() => setIsOpenCities(false)}
653
654
  title={t('SELECT_A_CITY', 'Select a city')}
654
655
  >
655
- <View style={{ padding: 40, width: '100%' }}>
656
- {citiesState?.cities?.map((city: any) => (
657
- <TouchableOpacity
658
- key={city?.id}
659
- style={{
660
- padding: 10,
661
- flexDirection: 'row'
662
- }}
663
- onPress={() => handleChangeCity(city?.id)}
664
- disabled={orderState?.loading}
665
- >
666
- {orderState?.options?.city_id === city?.id ? (
667
- <OIcon
668
- src={theme.images.general.option_checked}
669
- width={16}
670
- style={{ marginEnd: 24 }}
671
- />
672
- ) : (
673
- <OIcon
674
- src={theme.images.general.option_normal}
675
- width={16}
676
- style={{ marginEnd: 24 }}
677
- />
678
- )}
679
- <OText color={theme.colors.black}>
680
- {city?.name}
681
- </OText>
682
- </TouchableOpacity>
683
- ))}
684
- </View>
656
+ <CitiesControl
657
+ cities={citiesState?.cities}
658
+ onClose={() => setIsOpenCities(false)}
659
+ handleChangeCity={handleChangeCity}
660
+ />
685
661
  </OModal>
686
662
  </IOScrollView>
687
663
  );
@@ -0,0 +1,89 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { StyleSheet, useWindowDimensions, Keyboard, View } from 'react-native';
3
+ import { useLanguage, useOrder } from 'ordering-components/native';
4
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
+ import { useTheme } from 'styled-components/native';
6
+
7
+ import { OButton, OIcon, OText } from '../shared';
8
+
9
+ import { CityElement, Container } from './styles'
10
+
11
+ export const CitiesControl = (props: any) => {
12
+ const {
13
+ cities,
14
+ onClose,
15
+ handleChangeCity
16
+ } = props;
17
+
18
+ const theme = useTheme();
19
+ const [, t] = useLanguage();
20
+ const [orderState] = useOrder();
21
+ const { height } = useWindowDimensions();
22
+ const { top, bottom } = useSafeAreaInsets();
23
+
24
+ const [isKeyboardShow, setIsKeyboardShow] = useState(false);
25
+ const [cityState, setCityState] = useState(orderState?.options?.city_id)
26
+
27
+ const handleClick = () => {
28
+ cityState !== orderState?.options?.city_id && handleChangeCity(cityState)
29
+ onClose && onClose()
30
+ }
31
+
32
+ useEffect(() => {
33
+ const keyboardDidShowListener = Keyboard.addListener(
34
+ 'keyboardDidShow',
35
+ () => setIsKeyboardShow(true)
36
+ );
37
+ const keyboardDidHideListener = Keyboard.addListener(
38
+ 'keyboardDidHide',
39
+ () => setIsKeyboardShow(false)
40
+ );
41
+ return () => {
42
+ keyboardDidShowListener.remove();
43
+ keyboardDidHideListener.remove();
44
+ };
45
+ }, []);
46
+
47
+ return (
48
+ <Container height={height - top - bottom - 60 - (isKeyboardShow ? 250 : 0)}>
49
+ <View>
50
+ {cities?.map((city: any) => (
51
+ <CityElement
52
+ key={city?.id}
53
+ activeOpacity={1}
54
+ disabled={orderState?.loading}
55
+ onPress={() => setCityState(city?.id === cityState ? null : city?.id)}
56
+ >
57
+ <OIcon
58
+ src={cityState === city?.id
59
+ ? theme.images.general.option_checked
60
+ : theme.images.general.option_normal}
61
+ width={16}
62
+ style={{ marginEnd: 24 }}
63
+ />
64
+ <OText color={theme.colors.black}>
65
+ {city?.name}
66
+ </OText>
67
+ </CityElement>
68
+ ))}
69
+ </View>
70
+ <OButton
71
+ text={t('CONTINUE', 'Continue')}
72
+ bgColor={theme.colors.primary}
73
+ borderColor={theme.colors.primary}
74
+ style={styles.btnStyle}
75
+ textStyle={{ color: 'white' }}
76
+ onClick={() => handleClick()}
77
+ />
78
+ </Container>
79
+ )
80
+ }
81
+
82
+ const styles = StyleSheet.create({
83
+ btnStyle: {
84
+ marginTop: 20,
85
+ borderRadius: 8,
86
+ shadowOpacity: 0,
87
+ height: 44
88
+ },
89
+ })
@@ -0,0 +1,17 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const Container = styled.View`
4
+ width: 100%;
5
+ padding: 0 40px;
6
+ justify-content: space-between;
7
+ padding-bottom: 12px;
8
+
9
+ ${(props: any) => props.height && css`
10
+ height: ${props.height}px;
11
+ `}
12
+ `
13
+
14
+ export const CityElement = styled.TouchableOpacity`
15
+ padding: 10px;
16
+ flex-direction: row;
17
+ `
@@ -358,7 +358,10 @@ export const ProductOptionsUI = (props: any) => {
358
358
  useEffect(() => {
359
359
  const imageList: any = []
360
360
  const videoList: any = []
361
- product?.images?.length > 0 ? imageList.push(product.images) : imageList.push(theme?.images?.dummies?.product)
361
+ imageList.push(product?.images?.length > 0
362
+ ? product.images
363
+ : theme?.images?.dummies?.product)
364
+
362
365
  if (product?.gallery && product?.gallery.length > 0) {
363
366
  for (const img of product?.gallery) {
364
367
  if (img?.file) {
@@ -537,7 +540,7 @@ export const ProductOptionsUI = (props: any) => {
537
540
  style={styles.slide1}
538
541
  key={i}
539
542
  >
540
- {String(img).includes('image') || typeof img === 'number' ? (
543
+ {(String(img).includes('http') || typeof img === 'number') ? (
541
544
  <FastImage
542
545
  style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1, aspectRatio: 3 / 2 }}
543
546
  source={typeof img !== 'number' ? {
@@ -548,7 +551,8 @@ export const ProductOptionsUI = (props: any) => {
548
551
  ) : (
549
552
  <>
550
553
  <YoutubePlayer
551
- height={300}
554
+ height={'100%'}
555
+ width={'100%'}
552
556
  play={playing}
553
557
  videoId={img}
554
558
  onChangeState={onStateChange}
@@ -579,7 +583,7 @@ export const ProductOptionsUI = (props: any) => {
579
583
  opacity: index === thumbsSwiper ? 1 : 0.8
580
584
  }}
581
585
  >
582
- {String(img).includes('image') ? (
586
+ {String(img).includes('http') ? (
583
587
  <OIcon
584
588
  url={img}
585
589
  style={{
@@ -594,7 +598,7 @@ export const ProductOptionsUI = (props: any) => {
594
598
  />
595
599
  ) : (
596
600
  <OIcon
597
- url={'http://img.youtube.com/vi/' + img + '/0.jpg'}
601
+ url={'https://img.youtube.com/vi/' + img + '/0.jpg'}
598
602
  style={{
599
603
  borderColor: theme.colors.lightGray,
600
604
  borderRadius: 8,