ordering-ui-react-native 0.15.5 → 0.15.8

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.15.5",
3
+ "version": "0.15.8",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useLanguage, useOrder } from 'ordering-components/native';
3
3
  import { useTheme } from 'styled-components/native';
4
- import { StyleSheet, View, Dimensions } from 'react-native';
4
+ import { StyleSheet, View, Dimensions, Platform, useWindowDimensions } from 'react-native';
5
5
  import { OButton, OIcon, OText } from '../shared';
6
6
  import { LogoWrapper, Slogan } from './styles';
7
7
  import { LanguageSelector } from '../LanguageSelector'
@@ -11,6 +11,7 @@ import { _setStoreData } from '../../providers/StoreUtil';
11
11
  const windowHeight = Dimensions.get('window').height
12
12
 
13
13
  export const Home = (props: any) => {
14
+ const { width, height } = useWindowDimensions();
14
15
  const { onNavigationRedirect } = props;
15
16
 
16
17
  const theme = useTheme();
@@ -25,7 +26,7 @@ export const Home = (props: any) => {
25
26
  return (
26
27
  <View style={styles.container}>
27
28
  <View style={styles.wrapperContent}>
28
- <View style={styles.languageSelector}>
29
+ <View style={{ paddingTop: (height <= 756 && Platform.OS !== 'ios') ? (height * 0.05) : 0, marginLeft: 10 }}>
29
30
  <LanguageSelector />
30
31
  </View>
31
32
  <LogoWrapper>
@@ -74,9 +75,6 @@ export const Home = (props: any) => {
74
75
  };
75
76
 
76
77
  const styles = StyleSheet.create({
77
- languageSelector: {
78
- marginRight: 10
79
- },
80
78
  textLink: {
81
79
  flexDirection: 'row',
82
80
  textAlign: 'center',
@@ -1,140 +1,108 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { I18nManager, TouchableOpacity, ActivityIndicator, View, Platform } from 'react-native'
3
- import { useTheme } from 'styled-components/native'
4
- import {
5
- LanguageSelector as LanguageSelectorController,
6
- useLanguage
7
- } from 'ordering-components/native'
8
- import { StyleSheet } from 'react-native'
9
- import RNRestart from 'react-native-restart'
10
- import Picker from 'react-native-country-picker-modal';
1
+ import React, { useState } from 'react'
2
+ import { LanguageSelector as LanguageSelectorController, useOrder } from 'ordering-components/native'
3
+ import { useTheme } from 'styled-components/native';
4
+ import { I18nManager, Platform, StyleSheet, View } from 'react-native'
11
5
 
12
- import { Container, SelectItemBtn, SelectItem } from './styles'
6
+ import RNPickerSelect from 'react-native-picker-select'
7
+ import { Container, DummyContainer } from './styles'
13
8
  import { LanguageSelectorParams } from '../../types'
14
- import { OText } from '../shared'
9
+ import { OIcon } from '../shared'
10
+ import RNRestart from 'react-native-restart'
15
11
 
16
12
  const LanguageSelectorUI = (props: LanguageSelectorParams) => {
13
+
17
14
  const {
18
15
  languagesState,
19
16
  currentLanguage,
20
17
  handleChangeLanguage,
21
- isFromProfile
18
+ pickerStyle
22
19
  } = props
23
20
 
24
- const theme = useTheme()
25
- const [languageState] = useLanguage()
26
- const [isOpen, setIsOpen] = useState(false);
27
- const [optionSelected, setOptionSelected] = useState<any>(null)
28
- let current;
21
+ const [orderState] = useOrder()
22
+ const theme = useTheme();
29
23
 
30
- const styles = StyleSheet.create({
31
- itemSelected: {
24
+ const [language, setLanguage] = useState(currentLanguage)
25
+
26
+ const _pickerStyle = StyleSheet.create({
27
+ inputAndroid: {
28
+ color: '#000',
29
+ borderWidth: 1,
30
+ borderColor: theme.colors.clear,
31
+ padding: 10,
32
+ height: 40,
32
33
  backgroundColor: theme.colors.disabled,
34
+ borderRadius: 8
33
35
  },
34
- closeBtn: {
35
- width: 40,
36
+ inputIOS: {
37
+ color: '#000',
38
+ padding: 10,
36
39
  height: 40,
40
+ borderWidth: 1,
41
+ marginStart: 20,
42
+ borderColor: theme.colors.clear,
43
+ backgroundColor: theme.colors.clear,
44
+ },
45
+ icon: {
46
+ width: 10,
47
+ marginTop: 9,
48
+ marginEnd: 10
49
+ },
50
+ placeholder: {
51
+ color: theme.colors.secundaryContrast
52
+ },
53
+ chevronDown: {
54
+ display: 'none'
55
+ },
56
+ chevronUp: {
57
+ display: 'none'
37
58
  }
38
59
  })
39
60
 
40
61
  const _languages = languagesState?.languages?.map((language: any) => {
41
62
  return {
42
- key: language.code,
43
- value: language.code,
44
- label: language.name.toUpperCase()
63
+ value: language?.code,
64
+ label: language?.name,
65
+ inputLabel: language?.name
45
66
  }
46
67
  })
47
68
  _languages && _languages.sort((a: any, b: any) =>
48
- (a.label > b.label) ? 1 : ((b.label > a.label) ? -1 : 0)
69
+ (a.content > b.content) ? 1 : ((b.content > a.content) ? -1 : 0)
49
70
  )
50
71
 
51
- const langSelectedObj: any = _languages && _languages.find((item: any) => item.value === currentLanguage) || {}
52
-
53
72
  const changeDirection = async (language: any) => {
54
- if(language !== 'ar'){
55
- if (I18nManager.isRTL){
73
+ if (language !== 'ar') {
74
+ if (I18nManager.isRTL) {
56
75
  await I18nManager.forceRTL(false)
57
76
  RNRestart.Restart();
58
77
  }
59
78
  } else {
60
- if(!I18nManager.isRTL){
79
+ if (!I18nManager.isRTL) {
61
80
  await I18nManager.forceRTL(true)
62
81
  RNRestart.Restart();
63
82
  }
64
83
  }
65
84
  }
66
85
 
67
- const handlerChangeLanguage = (langCode: any) => {
68
- setOptionSelected(langCode)
69
- changeDirection(langCode)
70
- handleChangeLanguage(langCode)
86
+ const handlerChangeLanguage = (langCode?: any) => {
87
+ changeDirection(Platform.OS === 'ios' ? language : langCode)
88
+ handleChangeLanguage(Platform.OS === 'ios' ? language : langCode)
71
89
  }
72
90
 
73
- useEffect(() => {
74
- if (optionSelected === languageState?.language?.code && !languageState.loading) {
75
- setIsOpen(false)
76
- }
77
- }, [languageState])
78
-
79
91
  return (
80
92
  <Container>
81
- {languagesState?.languages && (
82
- <Picker
83
- countryCodes={current}
84
- visible={isOpen}
85
- onClose={() => setIsOpen(false)}
86
- withCountryNameButton
87
- // @ts-ignore
88
- closeButtonStyle={{
89
- width: '100%',
90
- alignItems: 'flex-end',
91
- padding: 10
92
- }}
93
- closeButtonImageStyle={Platform.OS === 'ios' && styles.closeBtn}
94
- renderFlagButton={() => (
95
- <>
96
- <TouchableOpacity
97
- onPress={() => setIsOpen(true)}
98
- disabled={_languages.length === 0 || languageState.loading}
99
- >
100
- <SelectItemBtn isFromProfile={isFromProfile}>
101
- <OText
102
- color={theme.colors.secundaryContrast}
103
- size={14}
104
- >
105
- {langSelectedObj.key.toUpperCase()}
106
- </OText>
107
- </SelectItemBtn>
108
- </TouchableOpacity>
109
- </>
110
- )}
111
- flatListProps={{
112
- keyExtractor: (item: any) => item.value,
113
- data: _languages || [],
114
- renderItem: ({ item }: any) => (
115
- <TouchableOpacity
116
- style={langSelectedObj.value === item.value && styles.itemSelected}
117
- disabled={langSelectedObj.value === item.value || languageState.loading}
118
- onPress={() => handlerChangeLanguage(item.value)}
119
- >
120
- <SelectItem>
121
- <View style={{ width: 40 }}>
122
- {optionSelected === item.value && languageState.loading && (
123
- <ActivityIndicator size="small" color={theme.colors.primary} />
124
- )}
125
- </View>
126
- <OText
127
- size={14}
128
- style={{ marginRight: 10 }}
129
- >
130
- {item.label}
131
- </OText>
132
- </SelectItem>
133
- </TouchableOpacity>
134
- ),
135
- }}
93
+ {languagesState?.languages ? (
94
+ <RNPickerSelect
95
+ onValueChange={(val) => Platform.OS === 'ios' ? setLanguage(val) : handlerChangeLanguage(val)}
96
+ items={_languages || []}
97
+ value={Platform.OS === 'ios' ? language : currentLanguage}
98
+ style={pickerStyle ? pickerStyle : _pickerStyle}
99
+ useNativeAndroidPickerStyle={false}
100
+ placeholder={{}}
101
+ disabled={orderState.loading}
102
+ onClose={() => Platform.OS === 'ios' ? handlerChangeLanguage() : {}}
103
+ onDonePress={() => handlerChangeLanguage()}
136
104
  />
137
- )}
105
+ ) : <DummyContainer />}
138
106
  </Container>
139
107
  )
140
108
  }
@@ -1,23 +1,10 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
3
  export const Container = styled.View`
4
- align-items: flex-end;
5
- justify-content: flex-end;
6
- flex-direction: row;
7
- `
8
-
9
- export const SelectItem = styled.View`
10
- padding: 8px;
11
4
  align-items: center;
5
+ justify-content: flex-start;
12
6
  flex-direction: row;
13
- `;
14
-
15
- export const SelectItemBtn = styled(SelectItem)`
16
- border-width: 1px;
17
- border-color: transparent;
18
- border-radius: 10px;
19
- max-width: 140px;
20
- margin-vertical: 5px;
21
- padding: 15px 20px;
22
- background-color: ${(props: any) => props.isFromProfile ? 'transparent' : props.theme.colors.inputDisabled};
7
+ `
8
+ export const DummyContainer = styled.View`
9
+ height: 40px;
23
10
  `
@@ -47,6 +47,40 @@ export const UserProfileForm = (props: ProfileParams) => {
47
47
  }
48
48
  });
49
49
 
50
+ const _pickerStyle = StyleSheet.create({
51
+ inputAndroid: {
52
+ color: '#000',
53
+ borderWidth: 1,
54
+ borderColor: theme.colors.clear,
55
+ padding: 10,
56
+ height: 40,
57
+ backgroundColor: theme.colors.disabled,
58
+ borderRadius: 8
59
+ },
60
+ inputIOS: {
61
+ color: '#000',
62
+ padding: 10,
63
+ height: 40,
64
+ borderWidth: 1,
65
+ borderColor: theme.colors.clear,
66
+ backgroundColor: theme.colors.clear,
67
+ },
68
+ icon: {
69
+ width: 10,
70
+ marginTop: 9,
71
+ marginEnd: 10
72
+ },
73
+ placeholder: {
74
+ color: theme.colors.secundaryContrast
75
+ },
76
+ chevronDown: {
77
+ display: 'none'
78
+ },
79
+ chevronUp: {
80
+ display: 'none'
81
+ }
82
+ })
83
+
50
84
  const onRedirect = (route: string, params?: any) => {
51
85
  navigation.navigate(route, params)
52
86
  }
@@ -97,7 +131,7 @@ export const UserProfileForm = (props: ProfileParams) => {
97
131
  <View>
98
132
  <LanguageContainer>
99
133
  <Ionicons name='globe-outline' style={styles.iconStyle} />
100
- <LanguageSelector isFromProfile />
134
+ <LanguageSelector pickerStyle={_pickerStyle} />
101
135
  </LanguageContainer>
102
136
  <LogoutButton />
103
137
  </View>
@@ -113,6 +113,7 @@ export interface LanguageSelectorParams {
113
113
  currentLanguage?: string;
114
114
  handleChangeLanguage?: any;
115
115
  isFromProfile?: boolean,
116
+ pickerStyle?: any
116
117
  }
117
118
  export interface BusinessesListingParams {
118
119
  navigation?: any;
@@ -29,7 +29,7 @@ const types = ['food', 'laundry', 'alcohol', 'groceries'];
29
29
  export const BusinessBasicInformation = (
30
30
  props: BusinessBasicInformationParams,
31
31
  ) => {
32
- const { navigation, businessState, isBusinessInfoShow, logo, header } = props;
32
+ const { navigation, businessState, isBusinessInfoShow, logo, header, isPreOrder } = props;
33
33
  const { business, loading } = businessState;
34
34
 
35
35
  const theme = useTheme();
@@ -181,12 +181,16 @@ export const BusinessBasicInformation = (
181
181
  <WrapReviews>
182
182
  {!isBusinessInfoShow && (
183
183
  <>
184
- <TouchableOpacity onPress={() => navigation.navigate('BusinessPreorder', { business: businessState?.business, handleBusinessClick: () => navigation?.goBack() })}>
185
- <OText color={theme.colors.textSecondary} style={{ textDecorationLine: 'underline' }}>
186
- {t('PRE_ORDER', 'Preorder')}
187
- </OText>
188
- </TouchableOpacity>
189
- <OText size={12} color={theme.colors.textSecondary}>{' \u2022 '}</OText>
184
+ { isPreOrder && (
185
+ <>
186
+ <TouchableOpacity onPress={() => navigation.navigate('BusinessPreorder', { business: businessState?.business, handleBusinessClick: () => navigation?.goBack() })}>
187
+ <OText color={theme.colors.textSecondary} style={{ textDecorationLine: 'underline' }}>
188
+ {t('PRE_ORDER', 'Preorder')}
189
+ </OText>
190
+ </TouchableOpacity>
191
+ <OText size={12} color={theme.colors.textSecondary}>{' \u2022 '}</OText>
192
+ </>
193
+ )}
190
194
  <TouchableOpacity onPress={() => setOpenBusinessReviews(true)}>
191
195
  <OText color={theme.colors.textSecondary} style={{ textDecorationLine: 'underline' }}>
192
196
  {t('REVIEWS', 'Reviews')}
@@ -262,4 +266,4 @@ const styles = StyleSheet.create({
262
266
  zIndex: 100,
263
267
  left: 40
264
268
  },
265
- });
269
+ });
@@ -8,7 +8,8 @@ import {
8
8
  useSession,
9
9
  useUtils,
10
10
  ToastType,
11
- useToast
11
+ useToast,
12
+ useConfig
12
13
  } from 'ordering-components/native'
13
14
  import { OButton, OIcon, OModal, OText } from '../shared'
14
15
  import { BusinessBasicInformation } from '../BusinessBasicInformation'
@@ -52,7 +53,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
52
53
  const [orderState] = useOrder()
53
54
  const [{ parsePrice }] = useUtils()
54
55
  const [, { showToast }] = useToast()
55
-
56
+ const [{ configs }] = useConfig()
57
+ const isPreOrder = configs?.preorder_status_enabled?.value === '1'
56
58
  const styles = StyleSheet.create({
57
59
  mainContainer: {
58
60
  flex: 1,
@@ -231,6 +233,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
231
233
  openBusinessInformation={openBusinessInformation}
232
234
  header={header}
233
235
  logo={logo}
236
+ isPreOrder={isPreOrder}
234
237
  />
235
238
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
236
239
  {!loading && business?.id && (
@@ -134,6 +134,7 @@ const CheckoutUI = (props: any) => {
134
134
 
135
135
 
136
136
  const isWalletEnabled = configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
137
+ const isPreOrder = configs?.preorder_status_enabled?.value === '1'
137
138
 
138
139
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
139
140
  ? JSON.parse(configs?.driver_tip_options?.value) || []
@@ -149,6 +150,12 @@ const CheckoutUI = (props: any) => {
149
150
  }
150
151
  })
151
152
 
153
+ const handleMomentClick = () => {
154
+ if (isPreOrder) {
155
+ navigation.navigate('MomentOption')
156
+ }
157
+ }
158
+
152
159
  const handlePlaceOrder = () => {
153
160
  if (!userErrors.length) {
154
161
  handlerClickPlaceOrder && handlerClickPlaceOrder()
@@ -260,19 +267,21 @@ const CheckoutUI = (props: any) => {
260
267
  />
261
268
  </CHMomentWrapper>
262
269
  <CHMomentWrapper
263
- onPress={() => navigation.navigate('MomentOption')}
264
- disabled={loading}
270
+ onPress={() => handleMomentClick()}
271
+ disabled={loading}
265
272
  >
266
273
  <OText size={12} numberOfLines={1} ellipsizeMode='tail' color={theme.colors.textSecondary}>
267
274
  {options?.moment
268
275
  ? parseDate(options?.moment, { outputFormat: configs?.dates_moment_format?.value })
269
276
  : t('ASAP_ABBREVIATION', 'ASAP')}
270
277
  </OText>
271
- <OIcon
272
- src={theme.images.general.arrow_down}
273
- width={10}
274
- style={{ marginStart: 8 }}
275
- />
278
+ { isPreOrder && (
279
+ <OIcon
280
+ src={theme.images.general.arrow_down}
281
+ width={10}
282
+ style={{ marginStart: 8 }}
283
+ />
284
+ )}
276
285
  </CHMomentWrapper>
277
286
  </ChHeader>
278
287
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 18, marginHorizontal: -40 }} />
@@ -290,7 +290,15 @@ export const ProductOptionsUI = (props: any) => {
290
290
  }
291
291
  if (img?.video) {
292
292
  const keys = img?.video.split('/')
293
- const _videoId = keys[keys.length - 1]
293
+ let _videoId = keys[keys.length - 1]
294
+ if (_videoId.includes('watch')) {
295
+ const __url = _videoId.split('=')[1]
296
+ _videoId = __url
297
+ }
298
+ if (_videoId.includes('?')) {
299
+ const __url = _videoId.split('?')[0]
300
+ _videoId = __url
301
+ }
294
302
  videoList.push(_videoId)
295
303
  }
296
304
  }
@@ -193,6 +193,7 @@ export interface BusinessBasicInformationParams {
193
193
  isBusinessInfoShow?: boolean;
194
194
  header?: any;
195
195
  logo?: any;
196
+ isPreOrder?: boolean;
196
197
  }
197
198
  export interface BusinessProductsCategoriesParams {
198
199
  categories: Array<any>;