ordering-ui-react-native 0.13.2 → 0.13.6

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.13.2",
3
+ "version": "0.13.6",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -25,13 +25,30 @@ import AppContainer from './AppContainer';
25
25
  Sentry.init({
26
26
  environment: Platform.OS === 'ios' ? 'ios' : 'android',
27
27
  dsn: 'https://90197fffe6a1431b8c3eb79e1e36f0ee@o460529.ingest.sentry.io/5722123',
28
- release: process.env.npm_package_version ? 'ordering-ui-native@' + process.env.npm_package_version : 'ordering-ui-native@' + '0.0.2',
28
+ release: process.env.npm_package_version ? 'ordering-ui-native@' + process.env.npm_package_version : 'ordering-ui-native@' + '0.0.4',
29
29
  ignoreErrors: [
30
30
  'is not defined',
31
31
  'is not a function',
32
32
  'can\'t find variable',
33
33
  'objects are not valid',
34
- 'element type is invalid'
34
+ 'element type is invalid',
35
+ 'requiring module',
36
+ 'has not been registered',
37
+ 'failed to connect to debugger!',
38
+ 'rendered more hooks than',
39
+ 'rendered fewer hooks than',
40
+ 'should have a queue',
41
+ 'the OS most likely terminated',
42
+ 'Connection timed out',
43
+ 'java.io.EOFException',
44
+ 'Abort',
45
+ 'Segfault',
46
+ 'Failed to allocate a',
47
+ 'Application Not Responding',
48
+ 'connection no longer valid',
49
+ 'IllegalInstruction',
50
+ 'React.Children.only expected to receive a single React element child.',
51
+ 'unrecognized selector sent to instance'
35
52
  ],
36
53
  });
37
54
 
@@ -191,7 +191,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
191
191
  <>
192
192
  {!(business?.categories?.length === 0) && (
193
193
  <BusinessProductsCategories
194
- categories={[{ id: null, name: t('ALL', 'All') }, { id: 'featured', name: t('FEATURED', 'Featured') }, ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)]}
194
+ categories={[{ id: null, name: t('ALL', 'All') }, { id: 'featured', name: t('FEATURED', 'Featured') }, ...business?.categories?.sort((a: any, b: any) => a.rank - b.rank)]}
195
195
  categorySelected={categorySelected}
196
196
  onClickCategory={handleChangeCategory}
197
197
  featured={featuredProducts}
@@ -203,7 +203,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
203
203
  categories={[
204
204
  { id: null, name: t('ALL', 'All') },
205
205
  { id: 'featured', name: t('FEATURED', 'Featured') },
206
- ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
206
+ ...business?.categories?.sort((a: any, b: any) => a.rank - b.rank)
207
207
  ]}
208
208
  category={categorySelected}
209
209
  categoryState={categoryState}
@@ -56,9 +56,7 @@ const BusinessMenu = (props:any): React.ReactElement => {
56
56
  clearTimeout(timerId.current);
57
57
  timerId.current = setTimeout(() => {
58
58
  setClearCart(true)
59
- navigation.reset({
60
- routes: [{ name: 'Intro' }],
61
- })
59
+ navigation.navigate('Intro')
62
60
  }, 60000*2);
63
61
  }, []);
64
62
 
@@ -1,14 +1,12 @@
1
1
  import React from 'react'
2
- import { View, StyleSheet } from 'react-native'
2
+ import { View, StyleSheet, ScrollView, TouchableOpacity } from 'react-native'
3
3
  import { BusinessAndProductList, useLanguage } from 'ordering-components/native'
4
- import Carousel from 'react-native-snap-carousel';
5
- import { BusinessProductsListingParams, Business, Product } from '../../types'
4
+ import { BusinessProductsListingParams, Business } from '../../types'
6
5
  import { OCard, OText, OIcon } from '../shared'
7
6
  import GridContainer from '../../layouts/GridContainer'
8
- import PromoCard from '../PromoCard';
9
7
  import Spinner from 'react-native-loading-spinner-overlay';
10
8
  import { LANDSCAPE, useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
11
- import { useTheme } from 'styled-components/native';
9
+ import styled, { useTheme } from 'styled-components/native';
12
10
 
13
11
  const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
14
12
  const {navigation, businessState, resetInactivityTimeout, clearInactivityTimeout, bottomSheetVisibility } = props;
@@ -18,6 +16,27 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
18
16
  const theme = useTheme();
19
17
  const [, t] = useLanguage();
20
18
  const [orientationState] = useDeviceOrientation();
19
+ const WIDTH_SCREEN = orientationState?.dimensions?.width
20
+
21
+ const styles = StyleSheet.create({
22
+ logo: {
23
+ width: 500,
24
+ height: 400,
25
+ alignSelf: 'center',
26
+ },
27
+ soldOut: {
28
+ top: 0,
29
+ left: 0,
30
+ position: 'absolute',
31
+ width: WIDTH_SCREEN * 0.15,
32
+ height: 50,
33
+ justifyContent: 'center',
34
+ backgroundColor: theme.colors.white,
35
+ alignItems: 'center',
36
+ borderRadius: 15,
37
+ opacity: 0.8,
38
+ },
39
+ });
21
40
 
22
41
  const _categories: any = business?.original?.categories;
23
42
  let _promos: any = [];
@@ -39,13 +58,30 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
39
58
  </View>
40
59
  );
41
60
 
42
- const _renderItem = ({item, index}: {item: Product; index: number}) => {
61
+ const RenderCategories = ({ item, cardStyle, widthScreen }: any) => {
62
+ const Category = styled.ImageBackground`
63
+ position: relative;
64
+ height: 150px;
65
+ width: ${(props: any) => props.w * 0.45}px;
66
+ border-radius: 10px;
67
+ padding: 10px;
68
+ display: flex;
69
+ flex-direction: column;
70
+ justify-content: center;
71
+ align-items: center;
72
+ `
73
+ const WrapText = styled.View`
74
+ height: 90px;
75
+ display: flex;
76
+ justify-content: center;
77
+ align-items: center;
78
+ border-radius: 10px;
79
+ `
80
+
43
81
  return (
44
- <PromoCard
45
- title={item?.name}
46
- {...(!!item?.description && {description: item?.description})}
47
- image={{uri: item?.images}}
48
- isOutOfStock={!item?.inventoried}
82
+ <TouchableOpacity
83
+ key={item.id}
84
+ activeOpacity={1}
49
85
  onPress={() => {
50
86
  resetInactivityTimeout()
51
87
  navigation.navigate('ProductDetails', {
@@ -54,37 +90,71 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
54
90
  product: item,
55
91
  });
56
92
  }}
57
- />
58
- );
59
- };
60
-
61
- let _carousel: Carousel<Product> | null;
93
+ >
94
+ <Category
95
+ style={cardStyle}
96
+ source={{uri: item.images}}
97
+ resizeMode="cover"
98
+ w={widthScreen}
99
+ borderRadius={16}
100
+ >
101
+ {item?.inventoried && (
102
+ <View style={styles.soldOut}>
103
+ <OText size={28} color={theme.colors.error}>
104
+ {t('SOLD_OUT', 'SOLD OUT')}
105
+ </OText>
106
+ </View>
107
+ )}
108
+ <WrapText>
109
+ <OText
110
+ color={theme.colors.white}
111
+ mLeft={0}
112
+ size={32}
113
+ numberOfLines={1}
114
+ // mBottom={8}
115
+ style={{...props?.titleStyle}}
116
+ weight="bold"
117
+ >
118
+ {item.name}
119
+ </OText>
120
+ {!!item?.description && (
121
+ <OText
122
+ color={theme.colors.white}
123
+ numberOfLines={1}
124
+ // mBottom={4}
125
+ size={18}
126
+ style={{...props?.descriptionStyle}}
127
+ weight="400"
128
+ >
129
+ {item.description}
130
+ </OText>
131
+ )}
132
+ </WrapText>
133
+ </Category>
134
+ </TouchableOpacity>
135
+ )
136
+ }
62
137
 
63
138
  const _renderPromos = (): React.ReactElement => (
64
139
  <>
65
140
  {_renderTitle(t('FEATURED', 'Featured'))}
66
- <Carousel
67
- keyExtractor={(item: any) => item.id}
68
- ref={(c: any) => {
69
- _carousel = c;
70
- }}
71
- data={_promos || []}
72
- renderItem={_renderItem}
73
- sliderWidth={orientationState?.dimensions?.width}
74
- itemWidth={orientationState?.dimensions?.width * 0.4}
75
- alwaysBounceHorizontal={false}
76
- slideStyle={{
77
- width: orientationState?.dimensions?.width * 0.45,
78
- marginLeft: 20,
79
- }}
80
- inactiveSlideScale={1}
81
- snapToAlignment="start"
82
- activeSlideAlignment="start"
83
- inactiveSlideOpacity={1}
84
- initialScrollIndex={0}
85
- onScrollToIndexFailed={(_: any) => {}}
86
- enableMomentum={true}
87
- />
141
+ <View style={{ paddingVertical: 20, marginLeft: 20, width: '100%' }}>
142
+ <ScrollView
143
+ horizontal
144
+ showsHorizontalScrollIndicator={false}
145
+ showsVerticalScrollIndicator={false}
146
+ style={{ width: '100%' }}
147
+ >
148
+ {_promos.map((category: any) => (
149
+ <RenderCategories
150
+ key={category.id}
151
+ item={category}
152
+ widthScreen={WIDTH_SCREEN}
153
+ cardStyle={{ marginRight: 20 }}
154
+ />
155
+ ))}
156
+ </ScrollView>
157
+ </View>
88
158
  </>
89
159
  );
90
160
 
@@ -148,23 +218,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
148
218
  );
149
219
  };
150
220
 
151
- const styles = StyleSheet.create({
152
- logo: {
153
- width: 500,
154
- height: 400,
155
- alignSelf: 'center',
156
- },
157
- wrapper: {
158
- display: 'flex',
159
- flex: 1,
160
- flexDirection: 'column',
161
- justifyContent: 'center',
162
- alignItems: 'center',
163
- height: '100%',
164
- backgroundColor: 'yellow'
165
- },
166
- });
167
-
168
221
  export const BusinessProductsListing = (props: any) => {
169
222
  const businessProductslistingProps = {
170
223
  ...props,
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import { TouchableOpacity, View, StyleSheet } from 'react-native'
3
- import { LanguageSelector as LanguageSelectorController, useLanguage } from 'ordering-components/native'
3
+ import { LanguageSelector as LanguageSelectorController } from 'ordering-components/native'
4
4
  import CountryPicker, { Flag } from 'react-native-country-picker-modal'
5
5
 
6
6
  import { Container, LanguageItem } from './styles'
@@ -17,9 +17,7 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
17
17
  handleChangeLanguage,
18
18
  } = props
19
19
 
20
- const theme = useTheme()
21
- const [{loading}] = useLanguage()
22
- const [isLoading, setIsLoading] = useState(true)
20
+ const theme = useTheme()
23
21
  const styles = StyleSheet.create({
24
22
  closeIcon: {
25
23
  width: 48, marginLeft: 32
@@ -28,15 +26,6 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
28
26
  marginLeft: 40
29
27
  }
30
28
  })
31
- useEffect(() => {
32
- if (!isLoading) return
33
- const loadingLanguage = setTimeout(() =>{
34
- setIsLoading(false)
35
- }, 1000);
36
- return () => {
37
- clearTimeout(loadingLanguage);
38
- }
39
- }, [])
40
29
 
41
30
  const _languages = languagesState?.languages?.map((language: any) => {
42
31
  return {
@@ -59,7 +48,7 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
59
48
 
60
49
  return (
61
50
  <>
62
- { isLoading ?
51
+ { languagesState.loading ?
63
52
  (<Container>
64
53
  <Placeholder style={{ width: 130, paddingTop: 10 }} Animation={Fade}>
65
54
  <PlaceholderLine height={15}/>
@@ -78,7 +67,7 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
78
67
  renderFlagButton={() => (
79
68
  <TouchableOpacity
80
69
  onPress={() => setCountryModalVisible(true)}
81
- disabled={loading}
70
+ disabled={languagesState.loading}
82
71
  >
83
72
  <LanguageItem>
84
73
  <Flag
@@ -102,7 +91,7 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
102
91
  handleChangeLanguage(item.value);
103
92
  setCountryModalVisible(false);
104
93
  }}
105
- disabled={loading}
94
+ disabled={languagesState.loading}
106
95
  >
107
96
  <LanguageItem>
108
97
  <View style={styles.flagsContainer} />
@@ -3,7 +3,7 @@ import styled from 'styled-components/native'
3
3
  import { OIcon, OButton, OText } from '../shared'
4
4
  import { ImageStyle, TextStyle, View, Platform } from 'react-native'
5
5
  import { OrderTypeSelector } from '../OrderTypeSelector'
6
- import { useConfig } from 'ordering-components/native'
6
+ import { useConfig, useLanguage } from 'ordering-components/native'
7
7
  import { useTheme } from 'styled-components/native'
8
8
 
9
9
  const Wrapper = styled.View`
@@ -60,6 +60,7 @@ interface Props {
60
60
  const NavBar = (props: Props) => {
61
61
  const theme = useTheme();
62
62
  const [{ configs }] = useConfig();
63
+ const [, t] = useLanguage();
63
64
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || [];
64
65
 
65
66
  return (
@@ -113,7 +114,13 @@ const NavBar = (props: Props) => {
113
114
  </TitleTopWrapper>
114
115
 
115
116
  {props?.includeOrderTypeSelector && (
116
- <View style={{ paddingHorizontal: props.rightComponent ? 4 : 20 }}>
117
+ <View
118
+ style={{
119
+ paddingHorizontal: props.rightComponent ? 4 : 20,
120
+ flexDirection: 'row'
121
+ }}
122
+ >
123
+ <OText style={{ paddingRight: 5 }}>{t('THIS_ORDER_IS_TO', 'This order is to')}</OText>
117
124
  <OrderTypeSelector configTypes={configTypes} />
118
125
  </View>
119
126
  )}
@@ -85,11 +85,11 @@ export const OrderTypeSelector = (props: any) => {
85
85
  orderTypes: props.orderType || [
86
86
  {
87
87
  value: 2,
88
- content: `${t('THIS_ORDER_IS_TO', 'This order is to')} ${t('TAKE_OUT', 'Take out')}`
88
+ content: t('TAKE_OUT', 'Take out')
89
89
  },
90
90
  {
91
91
  value: 3,
92
- content: `${t('THIS_ORDER_IS_TO', 'This order is to')} ${t('EAT_IN', 'Eat in')}`
92
+ content: t('EAT_IN', 'Eat in')
93
93
  },
94
94
  ]
95
95
  }
@@ -365,9 +365,9 @@ export const ProductOptionsUI = (props: any) => {
365
365
  </Animated.View>
366
366
  </Animated.View>
367
367
 
368
- {!isFromCheckout && (
368
+ {/* {!isFromCheckout && (
369
369
  <Spinner visible={loading} />
370
- )}
370
+ )} */}
371
371
  {!loading && !error && product && (
372
372
  <View style={{ paddingTop: isDrawer ? 10 : 20, paddingBottom: 80 }}>
373
373
  <WrapContent isDrawer={isDrawer}>
@@ -44,7 +44,7 @@ const OCard = (props: Props): React.ReactElement => {
44
44
  )}
45
45
  <OImage
46
46
  source={props.image}
47
- height={Platform.OS === 'ios' ? 250 : 150}
47
+ height={120}
48
48
  resizeMode="cover"
49
49
  borderRadius={16}
50
50
  />
@@ -15,6 +15,8 @@ export interface BusinessProductsListingParams {
15
15
  resetInactivityTimeout: any;
16
16
  clearInactivityTimeout: any;
17
17
  bottomSheetVisibility: any;
18
+ titleStyle: any;
19
+ descriptionStyle: any;
18
20
  }
19
21
 
20
22
  export interface OrderDetailsParams {
@@ -239,9 +239,9 @@ const CartUI = (props: any) => {
239
239
  </OSTotal>
240
240
  {cart?.status !== 2 && (
241
241
  <OSTable>
242
- <View style={{ width: '100%', marginTop: 20 }}>
242
+ <View style={{ flex: 1, marginTop: 20, paddingBottom: 20 }}>
243
243
  <OText>{t('COMMENTS', 'Comments')}</OText>
244
- <View style={{ flex: 1, width: '100%' }}>
244
+ <View style={{ flex: 1 }}>
245
245
  <OInput
246
246
  value={cart?.comment}
247
247
  placeholder={t('SPECIAL_COMMENTS', 'Special Comments')}
@@ -6,7 +6,7 @@ export const CContainer = styled.View`
6
6
 
7
7
  export const CartContent = styled.View`
8
8
  ${((props: any) => props.isBusinessCart && css`
9
- margin-bottom: 45px;
9
+ margin-bottom: 65px;
10
10
  `)}
11
11
  `
12
12
 
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
- import { Modal, TouchableWithoutFeedback, Dimensions, StyleSheet, View, ScrollView, Text } from 'react-native'
2
+ import { Modal, TouchableWithoutFeedback, Dimensions, StyleSheet, View, ScrollView, Text, Platform } from 'react-native'
3
3
  import { OText } from '../shared'
4
4
  import Icon from 'react-native-vector-icons/Feather'
5
- import { useTheme } from 'styled-components/native'
5
+ import styled,{ useTheme } from 'styled-components/native'
6
6
 
7
7
  const deviceHeight = Dimensions.get('window').height
8
8
 
@@ -24,6 +24,11 @@ const OBottomPopup = (props: Props) => {
24
24
 
25
25
  const theme = useTheme()
26
26
 
27
+ const KeyboardView = styled.KeyboardAvoidingView`
28
+ flex-grow: 1;
29
+ flex-shrink: 1;
30
+ `;
31
+
27
32
  const styles = StyleSheet.create({
28
33
  container: {
29
34
  flex: 1,
@@ -79,26 +84,31 @@ const OBottomPopup = (props: Props) => {
79
84
  <View style={styles.touchableOutsideStyle} />
80
85
  </TouchableWithoutFeedback>
81
86
  <View style={styles.bottomContainer}>
82
- <ScrollView showsVerticalScrollIndicator={false}>
83
- {customHeaderShow ? (
84
- <View style={styles.customHeaderStyle}>
85
- <OText size={16} numberOfLines={1} style={styles.customTitleStyle}>
87
+ <KeyboardView
88
+ enabled
89
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
90
+ >
91
+ <ScrollView showsVerticalScrollIndicator={false} >
92
+ {customHeaderShow ? (
93
+ <View style={styles.customHeaderStyle}>
94
+ <OText size={16} numberOfLines={1} style={styles.customTitleStyle}>
95
+ {title}
96
+ </OText>
97
+ <Icon
98
+ name='x'
99
+ size={30}
100
+ style={styles.closeBtnStyle}
101
+ onPress={onClose}
102
+ />
103
+ </View>
104
+ ) : (
105
+ <Text style={styles.titleStyle}>
86
106
  {title}
87
- </OText>
88
- <Icon
89
- name='x'
90
- size={30}
91
- style={styles.closeBtnStyle}
92
- onPress={onClose}
93
- />
94
- </View>
95
- ) : (
96
- <Text style={styles.titleStyle}>
97
- {title}
98
- </Text>
99
- )}
100
- {children}
101
- </ScrollView>
107
+ </Text>
108
+ )}
109
+ {children}
110
+ </ScrollView>
111
+ </KeyboardView>
102
112
  </View>
103
113
  </View>
104
114
  </Modal>