ordering-ui-react-native 0.17.48 → 0.17.50

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.48",
3
+ "version": "0.17.50",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -14,6 +14,8 @@ Sound.setCategory('Playback')
14
14
 
15
15
  const windowWidth = Dimensions.get('screen').width
16
16
 
17
+ const SOUND_LOOP = 3
18
+
17
19
  const NewOrderNotificationUI = (props: any) => {
18
20
  const { isBusinessApp } = props
19
21
  const [events] = useEvent()
@@ -22,8 +24,7 @@ const NewOrderNotificationUI = (props: any) => {
22
24
  const [{ user, token }] = useSession()
23
25
  const [ordering] = useApi()
24
26
  const { getCurrentLocation } = useLocation();
25
- const [soundTimeout, setSoundTimeout] = useState<any>(null)
26
- let [currentEvent, setCurrentEvent] = useState<any>(null)
27
+ const [currentEvent, setCurrentEvent] = useState<any>(null)
27
28
 
28
29
  const evtList: any = {
29
30
  1: {
@@ -43,29 +44,27 @@ const NewOrderNotificationUI = (props: any) => {
43
44
  },
44
45
  }
45
46
 
46
- const notificationSound = new Sound(theme.sounds.notification, (e) => { console.log(e) });
47
+ const notificationSound = new Sound(theme.sounds.notification);
47
48
 
48
- const handlePlayNotificationSound = () => {
49
- if (currentEvent) return
50
- let times = 0
51
- const _timeout = setInterval(function () {
52
- notificationSound.play(success => {
53
- if (success) {
54
- times = times + 1
55
- }
56
- })
57
- setSoundTimeout(_timeout)
58
- if (times === 3) {
59
- clearInterval(_timeout)
60
- clearInterval(soundTimeout)
61
- }
62
- }, 2500)
49
+ let _timeout: any = null
50
+
51
+ const handleCloseEvents = () => {
52
+ notificationSound.stop()
53
+ setCurrentEvent(null)
54
+ clearInterval(_timeout)
63
55
  }
64
56
 
65
- const handleCloseModal = () => {
66
- clearInterval(soundTimeout)
67
- currentEvent = null
68
- setCurrentEvent({ evt: null })
57
+ const handlePlayNotificationSound = (eventObj: any = null) => {
58
+ setCurrentEvent(eventObj)
59
+ let times = 1
60
+ if (times < SOUND_LOOP) {
61
+ _timeout = setInterval(() => {
62
+ notificationSound.setVolume(1).play(success => success && (times = times + 1))
63
+ if (times === SOUND_LOOP) {
64
+ clearInterval(_timeout)
65
+ }
66
+ }, 2500)
67
+ }
69
68
  }
70
69
 
71
70
  const handleEventNotification = async (evtType: number, value: any) => {
@@ -79,26 +78,15 @@ const NewOrderNotificationUI = (props: any) => {
79
78
  }),
80
79
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
81
80
  })
82
- } catch (error) {
83
- console.log(error)
84
- }
81
+ } catch {}
85
82
  const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
86
83
  const assignedSecondsDiff = duration.asSeconds()
87
84
  if (assignedSecondsDiff < 5 && !isBusinessApp) {
88
- handlePlayNotificationSound()
89
- clearInterval(soundTimeout)
90
- currentEvent = { evt: 2, orderId: value?.id }
91
- setCurrentEvent({ evt: 2, orderId: value?.id })
85
+ handlePlayNotificationSound({ evt: 2, orderId: value?.id })
92
86
  }
93
87
  }
94
88
  if (evtType === 3 || value.author_id === user.id) return
95
- handlePlayNotificationSound()
96
- clearInterval(soundTimeout)
97
- currentEvent = {
98
- evt: evtType,
99
- orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
100
- }
101
- setCurrentEvent({
89
+ handlePlayNotificationSound({
102
90
  evt: evtType,
103
91
  orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
104
92
  })
@@ -116,10 +104,7 @@ const NewOrderNotificationUI = (props: any) => {
116
104
  }, [])
117
105
 
118
106
  useEffect(() => {
119
- notificationSound.setVolume(1);
120
- return () => {
121
- notificationSound.release();
122
- }
107
+ return () => handleCloseEvents()
123
108
  }, [])
124
109
 
125
110
  return (
@@ -133,7 +118,7 @@ const NewOrderNotificationUI = (props: any) => {
133
118
  <View style={styles.modalView}>
134
119
  <TouchableOpacity
135
120
  style={styles.wrapperIcon}
136
- onPress={() => handleCloseModal()}
121
+ onPress={() => handleCloseEvents()}
137
122
  >
138
123
  <Icon name="x" size={30} />
139
124
  </TouchableOpacity>
@@ -95,6 +95,7 @@ import { LogoutButton } from './src/components/LogoutButton';
95
95
  import { UserFormDetailsUI } from './src/components/UserFormDetails';
96
96
  import { WalletTransactionItem } from './src/components/WalletTransactionItem';
97
97
  import { Promotions } from './src/components/Promotions'
98
+ import { PageBanner } from './src/components/PageBanner'
98
99
  import { USER_TYPE, ORDER_TYPES } from './src/config/constants'
99
100
 
100
101
  import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from './src/components/OrderSummary/styles';
@@ -257,6 +258,7 @@ export {
257
258
  UserFormDetailsUI,
258
259
  WalletTransactionItem,
259
260
  Promotions,
261
+ PageBanner,
260
262
  MyOrders,
261
263
  ORDER_TYPES,
262
264
  USER_TYPE,
@@ -42,6 +42,7 @@ import Animated from 'react-native-reanimated'
42
42
  import { ProfessionalFilter } from '../ProfessionalFilter';
43
43
  import { ServiceForm } from '../ServiceForm';
44
44
  import { BusinessesListing } from '../BusinessesListing/Layout/Original'
45
+ import { PageBanner } from '../PageBanner'
45
46
 
46
47
  const PIXELS_TO_SCROLL = 2000
47
48
 
@@ -403,6 +404,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
403
404
  />
404
405
  </ProfessionalFilterWrapper>
405
406
  )}
407
+ <PageBanner position='app_business_page' />
406
408
  <View
407
409
  style={{
408
410
  height: 8,
@@ -55,6 +55,7 @@ import { OrderProgress } from '../../../OrderProgress';
55
55
  import { useFocusEffect, useIsFocused } from '@react-navigation/native';
56
56
  import FastImage from 'react-native-fast-image';
57
57
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
58
+ import { PageBanner } from '../../../PageBanner'
58
59
 
59
60
  const PIXELS_TO_SCROLL = 2000;
60
61
 
@@ -549,6 +550,9 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
549
550
  />
550
551
  )
551
552
  }
553
+
554
+ <PageBanner position='app_business_listing' />
555
+
552
556
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
553
557
  <ListWrapper>
554
558
  {!businessId && (
@@ -1134,8 +1134,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1134
1134
  )}
1135
1135
  <Total>
1136
1136
  <Table>
1137
- <OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>{t('TOTAL', 'Total')}</OText>
1138
- <OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>
1137
+ <OText size={14} style={{ fontWeight: 'bold' }} color={theme.colors.textNormal}>{t('TOTAL', 'Total')}</OText>
1138
+ <OText size={14} style={{ fontWeight: 'bold' }} color={theme.colors.textNormal}>
1139
1139
  {parsePrice(order?.summary?.total ?? order?.total)}
1140
1140
  </OText>
1141
1141
  </Table>
@@ -0,0 +1,104 @@
1
+ import React from 'react'
2
+ import { useUtils, PageBanner as PageBannerController } from 'ordering-components/native'
3
+
4
+ import { View, StyleSheet } from 'react-native'
5
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
6
+ import Swiper from 'react-native-swiper'
7
+ import FastImage from 'react-native-fast-image';
8
+ import IconAntDesign from 'react-native-vector-icons/AntDesign';
9
+ import { useTheme } from 'styled-components/native';
10
+ import { PageBannerWrapper } from './styles'
11
+
12
+ const PageBannerUI = (props: any) => {
13
+ const {
14
+ pageBannerState
15
+ } = props
16
+
17
+ const theme = useTheme();
18
+ const [{ optimizeImage }] = useUtils();
19
+
20
+ const styles = StyleSheet.create({
21
+ mainSwiper: {
22
+ height: 300,
23
+ },
24
+ swiperButton: {
25
+ marginHorizontal: 25,
26
+ alignItems: 'center',
27
+ justifyContent: 'center',
28
+ width: 32,
29
+ height: 32,
30
+ borderRadius: 16,
31
+ backgroundColor: 'rgba(208,208,208,0.5)'
32
+ },
33
+ sliderWrapper: {
34
+ width: '100%',
35
+ height: 300
36
+ }
37
+ })
38
+
39
+ return (
40
+ <>
41
+ {pageBannerState.loading ? (
42
+ <PageBannerWrapper>
43
+ <Placeholder
44
+ Animation={Fade}
45
+ >
46
+ <PlaceholderLine
47
+ height={300}
48
+ style={{ marginBottom: 20, borderRadius: 8 }}
49
+ />
50
+ </Placeholder>
51
+ </PageBannerWrapper>
52
+ ) : (
53
+ <>
54
+ {pageBannerState.banner?.items && pageBannerState.banner?.items.length > 0 && (
55
+ <PageBannerWrapper>
56
+ <Swiper
57
+ loop={false}
58
+ showsButtons={true}
59
+ style={styles.mainSwiper}
60
+ showsPagination={false}
61
+ prevButton={
62
+ <View style={styles.swiperButton}>
63
+ <IconAntDesign
64
+ name="caretleft"
65
+ color={theme.colors.white}
66
+ size={13}
67
+ />
68
+ </View>
69
+ }
70
+ nextButton={
71
+ <View style={styles.swiperButton}>
72
+ <IconAntDesign
73
+ name="caretright"
74
+ color={theme.colors.white}
75
+ size={13}
76
+ />
77
+ </View>
78
+ }
79
+ >
80
+ {pageBannerState.banner?.items.map((img, i) => (
81
+ <View key={i} style={styles.sliderWrapper}>
82
+ <FastImage
83
+ style={{ height: '100%', width: '100%' }}
84
+ resizeMode='cover'
85
+ source={{ uri: optimizeImage(img.url, 'h_300,c_limit') }}
86
+ />
87
+ </View>
88
+ ))}
89
+ </Swiper>
90
+ </PageBannerWrapper>
91
+ )}
92
+ </>
93
+ )}
94
+ </>
95
+ )
96
+ }
97
+
98
+ export const PageBanner = (props: any) => {
99
+ const pageBannerProps = {
100
+ ...props,
101
+ UIComponent: PageBannerUI
102
+ }
103
+ return <PageBannerController {...pageBannerProps} />
104
+ }
@@ -0,0 +1,8 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const PageBannerWrapper = styled.View`
4
+ margin-horizontal: 40px;
5
+ border-radius: 8px;
6
+ overflow: hidden;
7
+ margin-vertical: 30px;
8
+ `