ordering-ui-react-native 0.14.12 → 0.14.13
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 +1 -1
- package/themes/business/src/components/MessagesOption/index.tsx +0 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +45 -13
- package/themes/business/src/components/OrdersOption/index.tsx +2 -0
- package/themes/doordash/src/components/BusinessProductsListing/index.tsx +4 -0
- package/themes/doordash/src/components/Home/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +2 -1
- package/themes/doordash/src/components/Messages/index.tsx +24 -7
- package/themes/doordash/src/components/SignupForm/index.tsx +2 -1
- package/themes/doordash/src/components/UserFormDetails/index.tsx +2 -1
package/package.json
CHANGED
|
@@ -12,7 +12,6 @@ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
|
12
12
|
import { OText, OButton } from '../shared';
|
|
13
13
|
import { NotFoundSource } from '../NotFoundSource';
|
|
14
14
|
import { PreviousMessages } from '../PreviousMessages';
|
|
15
|
-
// import { Contacts } from '../Contacts';
|
|
16
15
|
import { FiltersTab, TabsContainer, TagsContainer, Tag } from './styles';
|
|
17
16
|
import { MessagesOptionParams } from '../../types';
|
|
18
17
|
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback } from 'react'
|
|
2
|
-
import { useEvent, useLanguage, useUtils, useSession, useApi } from 'ordering-components/native'
|
|
2
|
+
import { useEvent, useLanguage, useUtils, useSession, useApi, NewOrderNotification as NewOrderNotificationController } from 'ordering-components/native'
|
|
3
3
|
import { View, Modal, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
|
|
4
4
|
import { OText, OIcon } from '../shared'
|
|
5
5
|
import { useTheme } from 'styled-components/native'
|
|
@@ -13,7 +13,7 @@ Sound.setCategory('Playback')
|
|
|
13
13
|
|
|
14
14
|
const windowWidth = Dimensions.get('screen').width
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const NewOrderNotificationUI = (props: any) => {
|
|
17
17
|
const [events] = useEvent()
|
|
18
18
|
const theme = useTheme()
|
|
19
19
|
const [, t] = useLanguage()
|
|
@@ -23,6 +23,7 @@ export const NewOrderNotification = (props: any) => {
|
|
|
23
23
|
const { getCurrentLocation } = useLocation();
|
|
24
24
|
const [modalOpen, setModalOpen] = useState(false)
|
|
25
25
|
const [newOrderId, setNewOrderId] = useState(null)
|
|
26
|
+
const [messageOrderId, setMessageOrderId] = useState(null)
|
|
26
27
|
const [soundTimeout, setSoundTimeout] = useState<any>(null)
|
|
27
28
|
const [isFocused, setIsFocused] = useState(false)
|
|
28
29
|
|
|
@@ -34,7 +35,6 @@ export const NewOrderNotification = (props: any) => {
|
|
|
34
35
|
console.log('loaded successfully');
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
|
|
38
38
|
const handlePlayNotificationSound = () => {
|
|
39
39
|
let times = 0
|
|
40
40
|
const _timeout = setInterval(function () {
|
|
@@ -57,6 +57,8 @@ export const NewOrderNotification = (props: any) => {
|
|
|
57
57
|
const handleCloseModal = () => {
|
|
58
58
|
clearInterval(soundTimeout)
|
|
59
59
|
setModalOpen(false)
|
|
60
|
+
setNewOrderId(null)
|
|
61
|
+
setMessageOrderId(null)
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
const handleNotification = (order: any) => {
|
|
@@ -66,10 +68,20 @@ export const NewOrderNotification = (props: any) => {
|
|
|
66
68
|
setNewOrderId(order.id)
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
const handleMessageNotification = (message: any) => {
|
|
72
|
+
const { order_id: orderId } = message;
|
|
73
|
+
if (!modalOpen) setModalOpen(true)
|
|
74
|
+
clearInterval(soundTimeout)
|
|
75
|
+
handlePlayNotificationSound()
|
|
76
|
+
setMessageOrderId(orderId)
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
useEffect(() => {
|
|
70
|
-
events.on('
|
|
80
|
+
events.on('order_added_noification', handleNotification)
|
|
81
|
+
events.on('message_added_noification', handleMessageNotification)
|
|
71
82
|
return () => {
|
|
72
|
-
events.off('
|
|
83
|
+
events.off('order_added_noification', handleNotification)
|
|
84
|
+
events.off('message_added_noification', handleMessageNotification)
|
|
73
85
|
}
|
|
74
86
|
}, [])
|
|
75
87
|
|
|
@@ -97,9 +109,9 @@ export const NewOrderNotification = (props: any) => {
|
|
|
97
109
|
|
|
98
110
|
useEffect(() => {
|
|
99
111
|
if (user?.level !== 4) return
|
|
100
|
-
events.on('
|
|
112
|
+
events.on('order_updated_noification', handleUpdateOrder)
|
|
101
113
|
return () => {
|
|
102
|
-
events.off('
|
|
114
|
+
events.off('order_updated_noification', handleUpdateOrder)
|
|
103
115
|
}
|
|
104
116
|
}, [handleUpdateOrder, user])
|
|
105
117
|
|
|
@@ -149,12 +161,23 @@ export const NewOrderNotification = (props: any) => {
|
|
|
149
161
|
width={250}
|
|
150
162
|
height={200}
|
|
151
163
|
/>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
{newOrderId && (
|
|
165
|
+
<OText
|
|
166
|
+
color={theme.colors.textGray}
|
|
167
|
+
mBottom={15}
|
|
168
|
+
>
|
|
169
|
+
{t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', newOrderId)}
|
|
170
|
+
</OText>
|
|
171
|
+
)}
|
|
172
|
+
|
|
173
|
+
{messageOrderId && (
|
|
174
|
+
<OText
|
|
175
|
+
color={theme.colors.textGray}
|
|
176
|
+
mBottom={15}
|
|
177
|
+
>
|
|
178
|
+
{t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', messageOrderId)}
|
|
179
|
+
</OText>
|
|
180
|
+
)}
|
|
158
181
|
</View>
|
|
159
182
|
</NotificationContainer>
|
|
160
183
|
</Modal>
|
|
@@ -178,3 +201,12 @@ const styles = StyleSheet.create({
|
|
|
178
201
|
top: 20
|
|
179
202
|
}
|
|
180
203
|
})
|
|
204
|
+
|
|
205
|
+
export const NewOrderNotification = (props: any) => {
|
|
206
|
+
const newOrderNotificationProps = {
|
|
207
|
+
...props,
|
|
208
|
+
UIComponent: NewOrderNotificationUI
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return <NewOrderNotificationController {...newOrderNotificationProps} />;
|
|
212
|
+
};
|
|
@@ -6,6 +6,7 @@ import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
|
6
6
|
import FontistoIcon from 'react-native-vector-icons/Fontisto'
|
|
7
7
|
import { useTheme } from 'styled-components/native';
|
|
8
8
|
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
9
|
+
import { NewOrderNotification } from '../NewOrderNotification';
|
|
9
10
|
|
|
10
11
|
import { OText, OButton, OModal, OIconButton, OInput, OIcon } from '../shared';
|
|
11
12
|
import { NotFoundSource } from '../NotFoundSource';
|
|
@@ -550,6 +551,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
550
551
|
</View>
|
|
551
552
|
{/* </GestureRecognizer> */}
|
|
552
553
|
|
|
554
|
+
<NewOrderNotification />
|
|
553
555
|
{openModal && (
|
|
554
556
|
<OModal open={openModal} entireModal customClose>
|
|
555
557
|
<ModalContainer
|
|
@@ -204,6 +204,10 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
204
204
|
}
|
|
205
205
|
}, [])
|
|
206
206
|
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
isKeyboardOpen && Platform.OS === 'android' && cartRef?.current?.scrollToEnd()
|
|
209
|
+
}, [isKeyboardOpen, cartRef?.current])
|
|
210
|
+
|
|
207
211
|
return (
|
|
208
212
|
<>
|
|
209
213
|
<Animated.View style={{ flex: 1, backgroundColor: theme.colors.white, position: 'absolute', width: '100%', top: top, zIndex: 1 }}>
|
|
@@ -182,7 +182,7 @@ export const Home = (props: any) => {
|
|
|
182
182
|
</TouchableOpacity>
|
|
183
183
|
</View>
|
|
184
184
|
|
|
185
|
-
<OModal entireModal customClose transition={'pageSheet'} open={isAuth} onClose={() => setAuthState(false)} style={{borderRadius: 7.6}}>
|
|
185
|
+
<OModal overScreen={Platform.OS === 'ios'} entireModal customClose transition={'pageSheet'} open={isAuth} onClose={() => setAuthState(false)} style={{borderRadius: 7.6}}>
|
|
186
186
|
<View style={styles.authHeader}>
|
|
187
187
|
<TouchableOpacity onPress={() => setAuthState(false)} style={{}}>
|
|
188
188
|
<OIcon src={theme.images.general.close} width={16} />
|
|
@@ -410,7 +410,8 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
410
410
|
textInputProps={{
|
|
411
411
|
returnKeyType: 'next',
|
|
412
412
|
onSubmitEditing: () => inputRef?.current?.focus?.(),
|
|
413
|
-
style: { borderWidth: 0, fontSize: 12 }
|
|
413
|
+
style: { borderWidth: 0, fontSize: 12 },
|
|
414
|
+
maxLength: 10
|
|
414
415
|
}}
|
|
415
416
|
textWrapStyle={{ borderColor: theme.colors.clear, borderWidth: 0, height: 40, paddingStart: 0 }}
|
|
416
417
|
/>
|
|
@@ -9,6 +9,8 @@ import { OIcon, OIconButton, OText, OButton } from '../shared'
|
|
|
9
9
|
import { TouchableOpacity, ActivityIndicator, StyleSheet, View, Platform, Keyboard, I18nManager } from 'react-native'
|
|
10
10
|
import { Header, TitleHeader, Wrapper, QuickMessageContainer } from './styles'
|
|
11
11
|
import { MessagesParams } from '../../types'
|
|
12
|
+
import { useWindowDimensions } from 'react-native'
|
|
13
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
12
14
|
|
|
13
15
|
const MessagesUI = (props: MessagesParams) => {
|
|
14
16
|
|
|
@@ -42,6 +44,9 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
42
44
|
|
|
43
45
|
const [formattedMessages, setFormattedMessages] = useState<Array<any>>([])
|
|
44
46
|
const [isKeyboardShow, setIsKeyboardShow] = useState(false)
|
|
47
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
48
|
+
const { height } = useWindowDimensions();
|
|
49
|
+
const { top, bottom } = useSafeAreaInsets();
|
|
45
50
|
|
|
46
51
|
const handleClickQuickMessage = (text: string) => {
|
|
47
52
|
setMessage && setMessage(`${message}${text}`)
|
|
@@ -186,15 +191,22 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
186
191
|
}, [messages.messages.length])
|
|
187
192
|
|
|
188
193
|
useEffect(() => {
|
|
189
|
-
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
|
|
194
|
+
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', (e) => {
|
|
190
195
|
setIsKeyboardShow(true)
|
|
196
|
+
setKeyboardHeight(e.endCoordinates.height)
|
|
191
197
|
})
|
|
192
198
|
const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {
|
|
193
199
|
setIsKeyboardShow(false)
|
|
200
|
+
setKeyboardHeight(0)
|
|
194
201
|
})
|
|
202
|
+
const keyboardWillHideListener = Keyboard.addListener('keyboardWillHide', (e) => {
|
|
203
|
+
setIsKeyboardShow(false)
|
|
204
|
+
setKeyboardHeight(0)
|
|
205
|
+
})
|
|
195
206
|
return () => {
|
|
196
207
|
keyboardDidShowListener.remove()
|
|
197
208
|
keyboardDidHideListener.remove()
|
|
209
|
+
keyboardWillHideListener.remove()
|
|
198
210
|
}
|
|
199
211
|
}, [])
|
|
200
212
|
|
|
@@ -273,7 +285,6 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
273
285
|
containerStyle={{
|
|
274
286
|
padding: Platform.OS === 'ios' && isKeyboardShow ? 0 : 10,
|
|
275
287
|
flexDirection: 'column-reverse',
|
|
276
|
-
marginBottom: Platform.OS === 'ios' && isKeyboardShow ? 500 : 0
|
|
277
288
|
}}
|
|
278
289
|
primaryStyle={{ alignItems: 'center', justifyContent: 'flex-start' }}
|
|
279
290
|
renderAccessory={() => renderAccessory()}
|
|
@@ -362,8 +373,16 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
362
373
|
<MaterialCommunityIcon name='chevron-double-down' size={32} />
|
|
363
374
|
)
|
|
364
375
|
|
|
376
|
+
const getViewHeight = () => {
|
|
377
|
+
if (Platform.OS === 'android') {
|
|
378
|
+
return '100%'
|
|
379
|
+
} else {
|
|
380
|
+
return height - top - bottom - (isKeyboardShow ? keyboardHeight - 240 : 48)
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
365
384
|
return (
|
|
366
|
-
|
|
385
|
+
<View style={{ height: getViewHeight(), width: '100%', paddingTop: 12, backgroundColor: 'white' }}>
|
|
367
386
|
<Wrapper>
|
|
368
387
|
<Header>
|
|
369
388
|
<OIcon
|
|
@@ -396,15 +415,13 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
396
415
|
renderBubble={renderBubble}
|
|
397
416
|
renderMessageImage={renderMessageImage}
|
|
398
417
|
scrollToBottomComponent={() => renderScrollToBottomComponent()}
|
|
399
|
-
|
|
400
|
-
paddingBottom: 55
|
|
401
|
-
}}
|
|
418
|
+
|
|
402
419
|
isLoadingEarlier={messages.loading}
|
|
403
420
|
renderLoading={() => <ActivityIndicator size="small" color="#000" />}
|
|
404
421
|
keyboardShouldPersistTaps='handled'
|
|
405
422
|
/>
|
|
406
423
|
</Wrapper>
|
|
407
|
-
|
|
424
|
+
</View>
|
|
408
425
|
)
|
|
409
426
|
}
|
|
410
427
|
|
|
@@ -452,7 +452,8 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
452
452
|
textInputProps={{
|
|
453
453
|
returnKeyType: 'next',
|
|
454
454
|
onSubmitEditing: () => passwordRef?.current?.focus?.(),
|
|
455
|
-
style: { borderWidth: 0, fontSize: 12 }
|
|
455
|
+
style: { borderWidth: 0, fontSize: 12 },
|
|
456
|
+
maxLength: 10
|
|
456
457
|
}}
|
|
457
458
|
textWrapStyle={{ borderColor: theme.colors.clear, borderWidth: 0, height: 40, paddingStart: 0 }}
|
|
458
459
|
/>
|
|
@@ -226,7 +226,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
226
226
|
defaultValue={phoneUpdate ? '' : user?.cellphone}
|
|
227
227
|
defaultCode={user?.country_phone_code || null}
|
|
228
228
|
textInputProps={{
|
|
229
|
-
style: { borderWidth: 0, fontSize: 12 }
|
|
229
|
+
style: { borderWidth: 0, fontSize: 12 },
|
|
230
|
+
maxLength: 10
|
|
230
231
|
}}
|
|
231
232
|
textWrapStyle={{ borderColor: theme.colors.clear, borderWidth: 0, height: 40, paddingStart: 0 }}
|
|
232
233
|
countryButtonStyle={{ marginStart: -2, justifyContent: 'flex-start', flexBasis: '36%'}}
|