ordering-ui-react-native 0.8.3 → 0.8.7

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.
Files changed (47) hide show
  1. package/package.json +2 -1
  2. package/src/components/OrdersOption/index.tsx +1 -12
  3. package/src/navigators/HomeNavigator.tsx +27 -2
  4. package/src/pages/Checkout.tsx +3 -3
  5. package/src/types/react-native-background-timer/index.d.ts +1 -0
  6. package/themes/business/index.tsx +6 -0
  7. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +167 -240
  8. package/themes/business/src/components/Chat/index.tsx +68 -54
  9. package/themes/business/src/components/DriverMap/index.tsx +86 -116
  10. package/themes/business/src/components/GoogleMap/index.tsx +43 -39
  11. package/themes/business/src/components/MessagesOption/index.tsx +73 -59
  12. package/themes/business/src/components/MessagesOption/styles.tsx +1 -1
  13. package/themes/business/src/components/OrderDetails/index.tsx +104 -92
  14. package/themes/business/src/components/OrderDetails/styles.tsx +6 -2
  15. package/themes/business/src/components/OrderDetailsDelivery/index.tsx +816 -0
  16. package/themes/business/src/components/OrderDetailsDelivery/styles.tsx +144 -0
  17. package/themes/business/src/components/OrderMessage/index.tsx +122 -23
  18. package/themes/business/src/components/OrdersOption/index.tsx +52 -66
  19. package/themes/business/src/components/PreviousMessages/index.tsx +2 -2
  20. package/themes/business/src/components/PreviousOrders/index.tsx +5 -5
  21. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -1
  22. package/themes/business/src/components/StoresList/index.tsx +51 -49
  23. package/themes/business/src/components/UserFormDetails/index.tsx +2 -1
  24. package/themes/business/src/components/UserProfileForm/index.tsx +18 -30
  25. package/themes/business/src/components/UserProfileForm/styles.tsx +0 -2
  26. package/themes/business/src/components/shared/OInput.tsx +3 -2
  27. package/themes/business/src/hooks/useLocation.tsx +7 -3
  28. package/themes/business/src/layouts/SafeAreaContainer.tsx +43 -0
  29. package/themes/business/src/types/index.tsx +8 -0
  30. package/themes/doordash/index.tsx +4 -4
  31. package/themes/doordash/src/components/LoginForm/index.tsx +2 -5
  32. package/themes/doordash/src/components/SingleProductCard/index.tsx +1 -1
  33. package/themes/doordash/src/components/SocialShare/index.tsx +34 -5
  34. package/themes/doordash/src/components/shared/OModal.tsx +1 -6
  35. package/themes/instacart/src/components/AddressForm/index.tsx +2 -60
  36. package/themes/instacart/src/components/AddressList/index.tsx +6 -3
  37. package/themes/instacart/src/components/Home/index.tsx +39 -14
  38. package/themes/instacart/src/components/Home/styles.tsx +7 -0
  39. package/themes/instacart/src/components/LoginForm/index.tsx +3 -3
  40. package/themes/instacart/src/components/LoginForm/styles.tsx +1 -3
  41. package/themes/instacart/src/components/LogoutButton/index.tsx +7 -6
  42. package/themes/instacart/src/components/SocialShare/index.tsx +56 -19
  43. package/themes/instacart/src/components/SocialShare/styles.ts +0 -8
  44. package/themes/instacart/src/components/UserProfileForm/index.tsx +1 -1
  45. package/themes/instacart/src/components/shared/OIcon.tsx +2 -1
  46. package/themes/instacart/src/layouts/Container.tsx +1 -1
  47. package/themes/instacart/src/types/index.tsx +12 -12
@@ -87,16 +87,13 @@ const StoresListUI = (props: BusinessesListingParams) => {
87
87
 
88
88
  const styles = StyleSheet.create({
89
89
  container: {
90
- padding: Platform.OS === 'ios' && orientation === 'Portrait' ? 0 : 20,
91
90
  paddingBottom: 20,
92
- paddingHorizontal: 20,
93
91
  marginBottom: 0,
94
92
  flex: 1,
95
93
  },
96
94
  header: {
97
95
  flexDirection: 'row',
98
96
  justifyContent: 'space-between',
99
- marginBottom: 25,
100
97
  },
101
98
  sectionTitle: {
102
99
  fontStyle: 'normal',
@@ -115,7 +112,7 @@ const StoresListUI = (props: BusinessesListingParams) => {
115
112
  });
116
113
 
117
114
  return (
118
- <ScrollView style={styles.container} onScroll={(e: any) => handleScroll(e)}>
115
+ <>
119
116
  <View style={styles.header}>
120
117
  <OText style={styles.sectionTitle}>{t('STORES', 'Stores')}</OText>
121
118
 
@@ -131,53 +128,58 @@ const StoresListUI = (props: BusinessesListingParams) => {
131
128
  />
132
129
  </View>
133
130
  </View>
134
-
135
- {!loading && businesses?.length === 0 && (
136
- <NotFoundSource
137
- content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
138
- image={theme.images.general.notFound}
139
- conditioned={false}
140
- />
141
- )}
142
-
143
- {!error &&
144
- businesses?.map((business: any) => (
145
- <BusinessController
146
- key={business?.id}
147
- business={business}
148
- handleCustomClick={handleBusinessClick}
149
- orderType={orderState?.options?.type}
150
- isBusinessOpen={business?.open}
151
- setIsUpdateStore={setIsUpdateStore}
152
- isUpdateStore={isUpdateStore}
131
+ <ScrollView
132
+ showsVerticalScrollIndicator={false}
133
+ style={styles.container}
134
+ onScroll={(e: any) => handleScroll(e)}>
135
+ {!loading && businesses?.length === 0 && (
136
+ <NotFoundSource
137
+ content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
138
+ image={theme.images.general.notFound}
139
+ conditioned={false}
153
140
  />
154
- ))}
155
-
156
- {loadBusinesses && (
157
- <View>
158
- {[...Array(6)].map((item, i) => (
159
- <Placeholder key={i} Animation={Fade}>
160
- <View style={{ flex: 1, flexDirection: 'row', marginBottom: 10 }}>
161
- <PlaceholderLine
162
- width={orientation === 'Portrait' ? 22 : 11}
163
- height={74}
164
- style={{
165
- marginRight: 20,
166
- marginBottom: 20,
167
- borderRadius: 7.6,
168
- }}
169
- />
170
- <Placeholder>
171
- <PlaceholderLine width={30} style={{ marginTop: 5 }} />
172
- <PlaceholderLine width={50} />
173
- <PlaceholderLine width={20} />
174
- </Placeholder>
175
- </View>
176
- </Placeholder>
141
+ )}
142
+
143
+ {!error &&
144
+ businesses?.map((business: any) => (
145
+ <BusinessController
146
+ key={business?.id}
147
+ business={business}
148
+ handleCustomClick={handleBusinessClick}
149
+ orderType={orderState?.options?.type}
150
+ isBusinessOpen={business?.open}
151
+ setIsUpdateStore={setIsUpdateStore}
152
+ isUpdateStore={isUpdateStore}
153
+ />
177
154
  ))}
178
- </View>
179
- )}
180
- </ScrollView>
155
+
156
+ {loadBusinesses && (
157
+ <View>
158
+ {[...Array(6)].map((item, i) => (
159
+ <Placeholder key={i} Animation={Fade}>
160
+ <View
161
+ style={{ flex: 1, flexDirection: 'row', marginBottom: 10 }}>
162
+ <PlaceholderLine
163
+ width={orientation === 'Portrait' ? 22 : 11}
164
+ height={74}
165
+ style={{
166
+ marginRight: 20,
167
+ marginBottom: 20,
168
+ borderRadius: 7.6,
169
+ }}
170
+ />
171
+ <Placeholder>
172
+ <PlaceholderLine width={30} style={{ marginTop: 5 }} />
173
+ <PlaceholderLine width={50} />
174
+ <PlaceholderLine width={20} />
175
+ </Placeholder>
176
+ </View>
177
+ </Placeholder>
178
+ ))}
179
+ </View>
180
+ )}
181
+ </ScrollView>
182
+ </>
181
183
  );
182
184
  };
183
185
 
@@ -211,7 +211,6 @@ export const UserFormDetailsUI = (props: any) => {
211
211
  fontFamily: 'Poppins',
212
212
  fontStyle: 'normal',
213
213
  fontWeight: '600',
214
- paddingHorizontal: 16,
215
214
  },
216
215
  errorText: {
217
216
  color: theme.colors.error,
@@ -229,6 +228,8 @@ export const UserFormDetailsUI = (props: any) => {
229
228
  borderTopWidth: 0,
230
229
  borderRightWidth: 0,
231
230
  borderLeftWidth: 0,
231
+ paddingHorizontal: 0,
232
+ borderRadius: 0,
232
233
  },
233
234
  editButton: {
234
235
  height: 44,
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { View, StyleSheet } from 'react-native';
2
+ import { View, StyleSheet, ScrollView, ActivityIndicator } from 'react-native';
3
3
  import { useForm } from 'react-hook-form';
4
4
  import { launchImageLibrary } from 'react-native-image-picker';
5
5
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
@@ -45,6 +45,7 @@ const ProfileUI = (props: ProfileParams) => {
45
45
  cleanFormState,
46
46
  handleToggleAvalaibleStatusDriver,
47
47
  userState,
48
+ isAvailableLoading,
48
49
  } = props;
49
50
 
50
51
  const [{ user }] = useSession();
@@ -136,24 +137,11 @@ const ProfileUI = (props: ProfileParams) => {
136
137
  }, [user?.country_phone_code]);
137
138
 
138
139
  const styles = StyleSheet.create({
139
- header: {
140
- marginBottom: 25,
141
- flexDirection: 'row',
142
- justifyContent: 'space-between',
143
- },
144
- title: {
145
- fontFamily: 'Poppins',
146
- fontStyle: 'normal',
147
- fontWeight: '600',
148
- fontSize: 26,
149
- color: theme.colors.textGray,
150
- },
151
140
  label: {
152
141
  color: theme.colors.textGray,
153
142
  fontFamily: 'Poppins',
154
143
  fontStyle: 'normal',
155
144
  fontWeight: '600',
156
- paddingHorizontal: 16,
157
145
  },
158
146
  inputStyle: {
159
147
  marginBottom: 25,
@@ -162,6 +150,8 @@ const ProfileUI = (props: ProfileParams) => {
162
150
  borderTopWidth: 0,
163
151
  borderRightWidth: 0,
164
152
  borderLeftWidth: 0,
153
+ paddingHorizontal: 0,
154
+ borderRadius: 0,
165
155
  },
166
156
  editButton: {
167
157
  height: 44,
@@ -182,10 +172,6 @@ const ProfileUI = (props: ProfileParams) => {
182
172
 
183
173
  return (
184
174
  <>
185
- <View style={styles.header}>
186
- <OText style={styles.title}>{t('PROFILE', 'Profile')}</OText>
187
- </View>
188
-
189
175
  {(formState?.loading || state?.loading) && (
190
176
  <View
191
177
  style={{
@@ -259,7 +245,7 @@ const ProfileUI = (props: ProfileParams) => {
259
245
  )}
260
246
 
261
247
  {!formState?.loading && !state?.loading && (
262
- <>
248
+ <ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1 }}>
263
249
  <CenterView>
264
250
  <OIcon
265
251
  url={optimizeImage(user?.photo, 'h_300,c_limit')}
@@ -279,15 +265,17 @@ const ProfileUI = (props: ProfileParams) => {
279
265
  </CenterView>
280
266
 
281
267
  {user?.level === 4 && (
282
- <UDWrapper>
283
- <EnabledStatusDriver>
284
- <OText style={{ ...styles.label, paddingHorizontal: 0 }}>
285
- {t(
286
- 'AVAILABLE_TO_RECEIVE_ORDERS',
287
- 'Available to receive orders',
288
- )}
289
- </OText>
268
+ <EnabledStatusDriver>
269
+ <OText style={{ ...styles.label, paddingHorizontal: 0 }}>
270
+ {t(
271
+ 'AVAILABLE_TO_RECEIVE_ORDERS',
272
+ 'Available to receive orders',
273
+ )}
274
+ </OText>
290
275
 
276
+ {isAvailableLoading ? (
277
+ <ActivityIndicator size="small" color={theme.colors.primary} />
278
+ ) : (
291
279
  <ToggleSwitch
292
280
  isOn={userState?.result?.result?.available}
293
281
  onColor={theme.colors.primary}
@@ -302,8 +290,8 @@ const ProfileUI = (props: ProfileParams) => {
302
290
  disabled={userState?.loading}
303
291
  animationSpeed={200}
304
292
  />
305
- </EnabledStatusDriver>
306
- </UDWrapper>
293
+ )}
294
+ </EnabledStatusDriver>
307
295
  )}
308
296
 
309
297
  {!isEdit ? (
@@ -396,7 +384,7 @@ const ProfileUI = (props: ProfileParams) => {
396
384
 
397
385
  <LogoutButton />
398
386
  </Actions>
399
- </>
387
+ </ScrollView>
400
388
  )}
401
389
  </>
402
390
  );
@@ -24,7 +24,6 @@ export const EnabledStatusDriver = styled.View`
24
24
  justify-content: space-between;
25
25
  align-items: center;
26
26
  width: 100%;
27
- padding: 20px;
28
27
  `;
29
28
 
30
29
  export const Actions = styled.View`
@@ -32,7 +31,6 @@ export const Actions = styled.View`
32
31
  border-top-width: 5px;
33
32
  border-top-color: ${(props: any) => props.theme.colors.inputChat};
34
33
  padding-vertical: 10px;
35
- padding-horizontal: 20px;
36
34
  display: flex;
37
35
  flex-direction: column;
38
36
  justify-content: space-between;
@@ -11,9 +11,10 @@ import OIcon from './OIcon';
11
11
 
12
12
  const Wrapper = styled.View`
13
13
  background-color: ${(props: any) => props.theme.colors.backgroundLight};
14
- border-radius: 25px;
14
+ border-radius: ${(props: any) => (props.border ? props.border : '25px')};
15
15
  border-width: 1px;
16
- padding-horizontal: 16px;
16
+ padding-horizontal: ${(props: any) =>
17
+ props.paddingHorizontal ? props.paddingHorizontal : '16px'};
17
18
  height: 50px;
18
19
  flex-direction: row;
19
20
  align-items: center;
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState, useRef } from 'react';
2
- import GeoLocation from '@react-native-community/geolocation';
2
+ import GeoLocation from 'react-native-geolocation-service';
3
3
  import { Location } from '../types';
4
4
 
5
5
  export const useLocation = () => {
@@ -7,10 +7,12 @@ export const useLocation = () => {
7
7
  const [initialPosition, setInitialPosition] = useState<Location>({
8
8
  longitude: 0,
9
9
  latitude: 0,
10
+ speed: 0,
10
11
  });
11
12
  const [userLocation, setUserLocation] = useState<Location>({
12
13
  longitude: 0,
13
14
  latitude: 0,
15
+ speed: 0,
14
16
  });
15
17
  const [routeLines, setRoutesLines] = useState<Location[]>([]);
16
18
  const isMounted = useRef(true);
@@ -43,10 +45,11 @@ export const useLocation = () => {
43
45
  resolve({
44
46
  latitude: coords.latitude,
45
47
  longitude: coords.longitude,
48
+ speed: coords.speed,
46
49
  });
47
50
  },
48
51
  err => reject({ err }),
49
- { enableHighAccuracy: true, timeout: 5000, maximumAge: 10000 },
52
+ { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 },
50
53
  );
51
54
  });
52
55
  };
@@ -58,12 +61,13 @@ export const useLocation = () => {
58
61
  const location: Location = {
59
62
  latitude: coords.latitude,
60
63
  longitude: coords.longitude,
64
+ speed: coords.speed,
61
65
  };
62
66
  setUserLocation(location);
63
67
  setRoutesLines(routes => [...routes, location]);
64
68
  },
65
69
  err => console.log(err),
66
- { enableHighAccuracy: true, distanceFilter: 20 },
70
+ { enableHighAccuracy: true, distanceFilter: 1 },
67
71
  );
68
72
  };
69
73
 
@@ -1,6 +1,49 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ Dimensions,
4
+ Platform,
5
+ StatusBar,
6
+ StyleSheet,
7
+ View,
8
+ } from 'react-native';
1
9
  import styled from 'styled-components/native';
2
10
 
3
11
  export const SafeAreaContainer = styled.SafeAreaView`
4
12
  flex: 1;
5
13
  background-color: ${(props: any) => props.theme.colors.backgroundPage};
6
14
  `;
15
+
16
+ export const SafeAreaContainerLayout = (props: any) => {
17
+ const [orientation, setOrientation] = useState(
18
+ Dimensions.get('window').width < Dimensions.get('window').height
19
+ ? 'Portrait'
20
+ : 'Landscape',
21
+ );
22
+
23
+ Dimensions.addEventListener('change', ({ window: { width, height } }) => {
24
+ if (width < height) {
25
+ setOrientation('Portrait');
26
+ } else {
27
+ setOrientation('Landscape');
28
+ }
29
+ });
30
+
31
+ return (
32
+ <>
33
+ <SafeAreaContainer>
34
+ <View
35
+ style={{
36
+ paddingHorizontal: 20,
37
+ paddingTop: 20,
38
+ paddingBottom: 0,
39
+ flex: 1,
40
+ }}>
41
+ <StatusBar
42
+ barStyle={Platform.OS === 'ios' ? 'dark-content' : 'default'}
43
+ />
44
+ {props.children}
45
+ </View>
46
+ </SafeAreaContainer>
47
+ </>
48
+ );
49
+ };
@@ -28,6 +28,7 @@ export interface ProfileParams {
28
28
  toggleIsEdit?: any;
29
29
  cleanFormState?: any;
30
30
  setFormState?: any;
31
+ isAvailableLoading?: boolean;
31
32
  handleChangeInput?: any;
32
33
  handleButtonUpdateClick?: any;
33
34
  handleToggleAvalaibleStatusDriver?: any;
@@ -329,6 +330,8 @@ export interface OrderDetailsParams {
329
330
  titleAccept?: textTranslate;
330
331
  titleReject?: textTranslate;
331
332
  appTitle?: textTranslate;
333
+ drivers?: any;
334
+ loadingDriver?: boolean;
332
335
  navigation?: any;
333
336
  messagesReadList?: any;
334
337
  urlToShare?: string;
@@ -343,6 +346,9 @@ export interface OrderDetailsParams {
343
346
  isFromCheckout?: boolean;
344
347
  driverLocation?: any;
345
348
  goToBusinessList?: boolean;
349
+ permissions?: any;
350
+ askLocationPermission?: any;
351
+ redirectToSettings?: any;
346
352
  }
347
353
  export interface ProductItemAccordionParams {
348
354
  isCartPending?: boolean;
@@ -458,6 +464,7 @@ export interface UpsellingProductsParams {
458
464
  export interface Location {
459
465
  latitude: number;
460
466
  longitude: number;
467
+ speed: number;
461
468
  }
462
469
 
463
470
  export interface GoogleMapsParams {
@@ -470,6 +477,7 @@ export interface GoogleMapsParams {
470
477
  markerTitle?: string;
471
478
  showAcceptOrReject?: boolean;
472
479
  order?: any;
480
+ driverLocation?: any;
473
481
  saveLocation?: boolean;
474
482
  handleOpenMapView?: () => void;
475
483
  isBusinessMarker?: boolean;
@@ -6,10 +6,6 @@ import { BusinessProductsList } from "./src/components/BusinessProductsList";
6
6
  import { CartContent } from "./src/components/CartContent";
7
7
  import { Checkout } from "./src/components/Checkout";
8
8
  import { ForgotPasswordForm } from "./src/components/ForgotPasswordForm";
9
- import { Help } from './src/components/Help';
10
- import { HelpAccountAndPayment } from './src/components/HelpAccountAndPayment';
11
- import { HelpGuide } from './src/components/HelpGuide';
12
- import { HelpOrder } from './src/components/HelpOrder';
13
9
  import { LoginForm } from "./src/components/LoginForm";
14
10
  import { MomentOption } from "./src/components/MomentOption";
15
11
  import { OrdersOption } from "./src/components/OrdersOption";
@@ -19,6 +15,10 @@ import { ReviewOrder } from "./src/components/ReviewOrder";
19
15
  import { SignupForm } from "./src/components/SignupForm";
20
16
  import { BusinessProductsListing } from "./src/components/BusinessProductsListing";
21
17
  import { NotFoundSource } from "./src/components/NotFoundSource";
18
+ import { Help } from './src/components/Help';
19
+ import { HelpAccountAndPayment } from './src/components/HelpAccountAndPayment';
20
+ import { HelpGuide } from './src/components/HelpGuide';
21
+ import { HelpOrder } from './src/components/HelpOrder';
22
22
 
23
23
  import {
24
24
  OAlert,
@@ -265,10 +265,7 @@ const LoginFormUI = (props: LoginParams) => {
265
265
  </LoginWith>
266
266
  )}
267
267
  {/* Social login button group */}
268
- {configs && Object.keys(configs).length > 0 && (
269
- (configs?.facebook_login?.value === 'true' ||
270
- configs?.facebook_login?.value === '1') &&
271
- configs?.facebook_id?.value &&
268
+ {configs && Object.keys(configs).length > 0 &&
272
269
  (
273
270
  <>
274
271
  <ButtonsWrapper>
@@ -309,7 +306,7 @@ const LoginFormUI = (props: LoginParams) => {
309
306
  <View style={{ height: 1, backgroundColor: theme.colors.border, width: width }} />
310
307
  </>
311
308
  )
312
- )}
309
+ }
313
310
 
314
311
  {(useLoginByCellphone || useLoginByEmail) && (
315
312
  <FormInput>
@@ -80,7 +80,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
80
80
  <OText numberOfLines={1} ellipsizeMode='tail' style={{ ...styles.textStyle, ...theme.labels.middle } as TextStyle}>{product?.name}</OText>
81
81
  <OText color={theme.colors.textSecondary} numberOfLines={2} ellipsizeMode='tail' style={{ ...styles.textStyle, ...theme.labels.normal } as TextStyle}>{product?.description}</OText>
82
82
  <OText color={theme.colors.textThird} style={theme.labels.normal as TextStyle}>{parsePrice(product?.price)}</OText>
83
- <OText color={theme.colors.textThird} style={theme.labels.normal as TextStyle}>{JSON.stringify(product?.rank)}</OText>
83
+ {/* <OText color={theme.colors.textThird} style={theme.labels.normal as TextStyle}>{JSON.stringify(product?.rank)}</OText> */}
84
84
  </CardInfo>
85
85
  <ImageBackground source={{ uri: optimizeImage(product?.images, 'h_200,c_limit') }} style={{ width: 115, height: 115, borderRadius: 7.6, borderTopLeftRadius: 0, borderBottomLeftRadius: 0, overflow: 'hidden' }} />
86
86
 
@@ -1,10 +1,11 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import { ImageSourcePropType, ImageStyle, Platform, StyleSheet } from 'react-native';
3
3
  import Share from 'react-native-share';
4
4
  import { OIcon } from '../shared';
5
5
  import { FavItem, FavMenu } from './styles';
6
6
  import { useTheme } from 'styled-components/native';
7
7
  import { TouchableOpacity } from 'react-native-gesture-handler';
8
+ import { ToastType, useToast } from 'ordering-components/native';
8
9
 
9
10
  interface SSFTypes {
10
11
  icon?: ImageSourcePropType,
@@ -27,6 +28,7 @@ const SocialShareFav = (props: SSFTypes) => {
27
28
  const { icon, style, mode, data } = props;
28
29
 
29
30
  const theme = useTheme();
31
+ const [, { showToast }] = useToast();
30
32
 
31
33
  const SApps: Array<any> = [
32
34
  {
@@ -74,24 +76,51 @@ const SocialShareFav = (props: SSFTypes) => {
74
76
  ];
75
77
 
76
78
  const [showMenu, setShowMenu] = useState(false);
79
+ const [result, setResult] = useState<{success: boolean, message: string}>({success: true, message: ''});
80
+
81
+ const getErrorString = (error: any, defaultValue?: any) => {
82
+ let e = defaultValue || 'Something went wrong. Please try again';
83
+ if (typeof error === 'string') {
84
+ e = error;
85
+ } else if (error && error.message) {
86
+ e = error.message;
87
+ } else if (error && error.props) {
88
+ e = error.props;
89
+ }
90
+ return e;
91
+ }
77
92
 
78
93
  const onShare = async (social: any) => {
79
94
  const options = {
80
95
  title: 'Share via',
81
- message: 'some message',
82
- url: 'some share url',
96
+ message: 'Awesome Restaurant!, Please enjoy your meal ;)',
97
+ url: 'https://www.ordering.co',
83
98
  social: social,
84
- whatsAppNumber: "9199999999", // country code + phone number
99
+ whatsAppNumber: "8615640383320", // country code + phone number
85
100
  // filename: 'test' , // only for base64 file in Android
86
101
  }
87
102
  setShowMenu(false);
88
- const shareResult = await Share.shareSingle(options);
103
+ try {
104
+ const shareResult = await Share.shareSingle(options);
105
+ setResult({success: shareResult.success, message: shareResult.message});
106
+ } catch (error) {
107
+ setResult({success: false, message: 'error: '.concat(getErrorString(error, `Wrong ${social} configuration!`))});
108
+ }
89
109
  }
90
110
 
91
111
  const onOpenMenu = () => {
92
112
  setShowMenu(!showMenu);
93
113
  }
94
114
 
115
+ useEffect(() => {
116
+ if (result.message.length < 3) return;
117
+ if (result.success) {
118
+ showToast(ToastType.Success, result.message);
119
+ } else {
120
+ showToast(ToastType.Error, result.message);
121
+ }
122
+ }, [result])
123
+
95
124
  return (
96
125
  <>
97
126
  <FavItem onPress={onOpenMenu}>
@@ -52,17 +52,12 @@ const OModal = (props: Props): React.ReactElement => {
52
52
 
53
53
  return (
54
54
  <Modal
55
- // animationType="slide"
56
- // transparent={isTransparent}
57
- // visible={open}
58
- // presentationStyle={transition || 'fullScreen'}
59
- // onRequestClose={() => { onClose() }}
60
55
  avoidKeyboard={false}
61
56
  isVisible={open}
62
57
  coverScreen={overScreen ? overScreen : false}
63
58
  style={{ height: '100%', flex: 1, position: 'absolute', backgroundColor: '#F8F9FA', margin: 0, marginTop: top, marginBottom: bottom, paddingBottom: bottom, ...style, zIndex: 10000 }}
64
59
  >
65
- <View style={styles.container}>
60
+ <View style={{...styles.container, paddingBottom: top}}>
66
61
  {!entireModal ? (
67
62
  <View style={styles.centeredView}>
68
63
  <View style={titleSectionStyle ? titleSectionStyle : styles.titleSection}>