ordering-ui-react-native 0.12.14 → 0.12.18
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/src/components/AddressList/index.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +168 -156
- package/themes/business/src/components/NewOrderNotification/index.tsx +14 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -1
- package/themes/business/src/components/OrdersOption/index.tsx +19 -15
- package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +389 -0
- package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +36 -0
- package/themes/business/src/components 2/BusinessController/index.tsx +155 -0
- package/themes/business/src/components 2/BusinessController/styles.tsx +19 -0
- package/themes/business/src/components 2/Chat/index.tsx +1152 -0
- package/themes/business/src/components 2/Chat/styles.tsx +12 -0
- package/themes/business/src/components 2/Contacts/index.tsx +299 -0
- package/themes/business/src/components 2/Contacts/styles.tsx +42 -0
- package/themes/business/src/components 2/DriverMap/index.tsx +525 -0
- package/themes/business/src/components 2/FloatingButton/index.tsx +141 -0
- package/themes/business/src/components 2/FloatingButton/styles.tsx +35 -0
- package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +204 -0
- package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +11 -0
- package/themes/business/src/components 2/GoogleMap/index.tsx +347 -0
- package/themes/business/src/components 2/Home/index.tsx +111 -0
- package/themes/business/src/components 2/Home/styles.tsx +27 -0
- package/themes/business/src/components 2/LanguageSelector/index.tsx +124 -0
- package/themes/business/src/components 2/LanguageSelector/lang_country.json +152 -0
- package/themes/business/src/components 2/LanguageSelector/styles.tsx +17 -0
- package/themes/business/src/components 2/LoginForm/index.tsx +663 -0
- package/themes/business/src/components 2/LoginForm/styles.tsx +48 -0
- package/themes/business/src/components 2/LogoutButton/index.tsx +63 -0
- package/themes/business/src/components 2/MapView/index.tsx +317 -0
- package/themes/business/src/components 2/MessagesOption/index.tsx +337 -0
- package/themes/business/src/components 2/MessagesOption/styles.tsx +27 -0
- package/themes/business/src/components 2/NewOrderNotification/index.tsx +167 -0
- package/themes/business/src/components 2/NewOrderNotification/styles.tsx +8 -0
- package/themes/business/src/components 2/NotFoundSource/index.tsx +52 -0
- package/themes/business/src/components 2/NotFoundSource/styles.tsx +17 -0
- package/themes/business/src/components 2/OrderDetails/Business.tsx +683 -0
- package/themes/business/src/components 2/OrderDetails/Delivery.tsx +454 -0
- package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +391 -0
- package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +148 -0
- package/themes/business/src/components 2/OrderDetails/styles.tsx +84 -0
- package/themes/business/src/components 2/OrderMessage/index.tsx +344 -0
- package/themes/business/src/components 2/OrderMessage/styles.tsx +5 -0
- package/themes/business/src/components 2/OrderSummary/index.tsx +700 -0
- package/themes/business/src/components 2/OrderSummary/styles.tsx +61 -0
- package/themes/business/src/components 2/OrdersOption/index.tsx +755 -0
- package/themes/business/src/components 2/OrdersOption/styles.tsx +54 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +51 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionCity/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDate/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +35 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +50 -0
- package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +49 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +46 -0
- package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +8 -0
- package/themes/business/src/components 2/PhoneInputNumber/index.tsx +160 -0
- package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +3 -0
- package/themes/business/src/components 2/PreviousMessages/index.tsx +304 -0
- package/themes/business/src/components 2/PreviousMessages/styles.tsx +32 -0
- package/themes/business/src/components 2/PreviousOrders/index.tsx +180 -0
- package/themes/business/src/components 2/PreviousOrders/styles.tsx +38 -0
- package/themes/business/src/components 2/ProductItemAccordion/index.tsx +301 -0
- package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +61 -0
- package/themes/business/src/components 2/SearchBar/index.tsx +112 -0
- package/themes/business/src/components 2/SignupForm/index.tsx +530 -0
- package/themes/business/src/components 2/SignupForm/styles.tsx +16 -0
- package/themes/business/src/components 2/StoresList/index.tsx +208 -0
- package/themes/business/src/components 2/StoresList/styles.tsx +26 -0
- package/themes/business/src/components 2/UserFormDetails/index.tsx +513 -0
- package/themes/business/src/components 2/UserFormDetails/styles.tsx +40 -0
- package/themes/business/src/components 2/UserProfileForm/index.tsx +496 -0
- package/themes/business/src/components 2/UserProfileForm/styles.tsx +36 -0
- package/themes/business/src/components 2/VerifyPhone/index.tsx +201 -0
- package/themes/business/src/components 2/VerifyPhone/styles.tsx +43 -0
- package/themes/business/src/components 2/shared/OAlert.tsx +52 -0
- package/themes/business/src/components 2/shared/OButton.tsx +149 -0
- package/themes/business/src/components 2/shared/OChatBubble.tsx +100 -0
- package/themes/business/src/components 2/shared/ODropDown.tsx +195 -0
- package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +328 -0
- package/themes/business/src/components 2/shared/OFab.tsx +54 -0
- package/themes/business/src/components 2/shared/OIcon.tsx +67 -0
- package/themes/business/src/components 2/shared/OIconButton.tsx +127 -0
- package/themes/business/src/components 2/shared/OInput.tsx +144 -0
- package/themes/business/src/components 2/shared/OLink.tsx +76 -0
- package/themes/business/src/components 2/shared/OModal.tsx +275 -0
- package/themes/business/src/components 2/shared/OSegment.tsx +86 -0
- package/themes/business/src/components 2/shared/OText.tsx +55 -0
- package/themes/business/src/components 2/shared/OTextarea.tsx +46 -0
- package/themes/business/src/components 2/shared/OToast.tsx +92 -0
- package/themes/business/src/components 2/shared/index.tsx +27 -0
- package/themes/business/src/types/index.tsx +4 -1
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +128 -83
- package/themes/kiosk/src/components/DrawerView/index.tsx +57 -0
- package/themes/kiosk/src/components/DrawerView/styles.tsx +30 -0
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +78 -58
- package/themes/kiosk/src/components/OrderDetails/index.tsx +3 -1
- package/themes/kiosk/src/components/ProductForm/index.tsx +129 -127
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +9 -6
- package/themes/original/src/components/OrderProgress/index.tsx +32 -18
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Pressable, StyleSheet, TextInput } from 'react-native';
|
|
3
|
+
import { useLanguage } from 'ordering-components/native';
|
|
4
|
+
import Spinner from 'react-native-loading-spinner-overlay';
|
|
5
|
+
import { getTraduction } from '../../utils';
|
|
6
|
+
import { OText } from '../shared';
|
|
7
|
+
import { useTheme } from 'styled-components/native';
|
|
8
|
+
import {
|
|
9
|
+
Container,
|
|
10
|
+
CountDownContainer,
|
|
11
|
+
ResendSection,
|
|
12
|
+
WrappCountdown,
|
|
13
|
+
InputsSection,
|
|
14
|
+
ErrorSection,
|
|
15
|
+
} from './styles';
|
|
16
|
+
|
|
17
|
+
const TIME_COUNTDOWN = 60 * 10; // 10 minutes
|
|
18
|
+
|
|
19
|
+
export const VerifyPhone = (props: any) => {
|
|
20
|
+
const {
|
|
21
|
+
phone,
|
|
22
|
+
formValues,
|
|
23
|
+
verifyPhoneState,
|
|
24
|
+
checkPhoneCodeState,
|
|
25
|
+
setCheckPhoneCodeState,
|
|
26
|
+
handleCheckPhoneCode,
|
|
27
|
+
handleVerifyCodeClick,
|
|
28
|
+
} = props;
|
|
29
|
+
const [, t] = useLanguage();
|
|
30
|
+
|
|
31
|
+
const theme = useTheme();
|
|
32
|
+
const [timer, setTimer] = useState(`${TIME_COUNTDOWN / 60}:00`);
|
|
33
|
+
const [verifyCode, setVerifyCode] = useState({ 0: '', 1: '', 2: '', 3: '' });
|
|
34
|
+
const [isSendCodeAgain, setIsSendCodeAgain] = useState(false);
|
|
35
|
+
|
|
36
|
+
const lastNumbers =
|
|
37
|
+
phone?.cellphone &&
|
|
38
|
+
`${phone?.cellphone.charAt(
|
|
39
|
+
phone?.cellphone.length - 2,
|
|
40
|
+
)}${phone?.cellphone.charAt(phone?.cellphone.length - 1)}`;
|
|
41
|
+
|
|
42
|
+
const handleChangeCode = (val: number, i: number) => {
|
|
43
|
+
setVerifyCode({ ...verifyCode, [i]: val });
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const checkResult = (result: any) => {
|
|
47
|
+
if (!result) return;
|
|
48
|
+
return typeof result === 'string' ? [result] : result;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleSendCodeAgain = () => {
|
|
52
|
+
setCheckPhoneCodeState && setCheckPhoneCodeState();
|
|
53
|
+
setTimer(`${TIME_COUNTDOWN / 60}:00`);
|
|
54
|
+
setIsSendCodeAgain(true);
|
|
55
|
+
handleVerifyCodeClick && handleVerifyCodeClick();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
let _timer = TIME_COUNTDOWN - 1;
|
|
60
|
+
let minutes = 0;
|
|
61
|
+
let seconds = 0;
|
|
62
|
+
const interval = setInterval(() => {
|
|
63
|
+
minutes = _timer / 60;
|
|
64
|
+
seconds = _timer % 60;
|
|
65
|
+
|
|
66
|
+
minutes = minutes < 10 ? 0 + minutes : minutes;
|
|
67
|
+
seconds = seconds < 10 ? 0 + seconds : seconds;
|
|
68
|
+
|
|
69
|
+
const formatMinutes =
|
|
70
|
+
parseInt(minutes.toString()) < 10
|
|
71
|
+
? `0${parseInt(minutes.toString())}`
|
|
72
|
+
: parseInt(minutes.toString());
|
|
73
|
+
|
|
74
|
+
const formatseconds =
|
|
75
|
+
parseInt(seconds.toString()) < 10
|
|
76
|
+
? `0${parseInt(seconds.toString())}`
|
|
77
|
+
: parseInt(seconds.toString());
|
|
78
|
+
|
|
79
|
+
setTimer(`${formatMinutes}:${formatseconds}`);
|
|
80
|
+
|
|
81
|
+
if (--_timer < 0) {
|
|
82
|
+
clearInterval(interval);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (timer === `${TIME_COUNTDOWN / 60}:00` && isSendCodeAgain) {
|
|
86
|
+
setIsSendCodeAgain(false);
|
|
87
|
+
clearInterval(interval);
|
|
88
|
+
}
|
|
89
|
+
}, 1000);
|
|
90
|
+
|
|
91
|
+
return () => clearInterval(interval);
|
|
92
|
+
}, [isSendCodeAgain]);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const codes = Object.keys(verifyCode).length;
|
|
96
|
+
const isFullInputs = codes && Object.values(verifyCode).every(val => val);
|
|
97
|
+
if (codes === 4 && isFullInputs) {
|
|
98
|
+
const values = {
|
|
99
|
+
...formValues,
|
|
100
|
+
cellphone: phone.cellphone,
|
|
101
|
+
country_phone_code: `+${phone.country_phone_code}`,
|
|
102
|
+
code: Object.values(verifyCode).join().replace(/,/g, ''),
|
|
103
|
+
};
|
|
104
|
+
handleCheckPhoneCode && handleCheckPhoneCode(values);
|
|
105
|
+
}
|
|
106
|
+
}, [verifyCode]);
|
|
107
|
+
|
|
108
|
+
const styles = StyleSheet.create({
|
|
109
|
+
inputStyle: {
|
|
110
|
+
width: 80,
|
|
111
|
+
height: 80,
|
|
112
|
+
marginBottom: 25,
|
|
113
|
+
borderWidth: 1,
|
|
114
|
+
borderColor: theme.colors.disabled,
|
|
115
|
+
borderRadius: 20,
|
|
116
|
+
textAlign: 'center',
|
|
117
|
+
fontSize: 40,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Container>
|
|
123
|
+
<OText size={30} style={{ textAlign: 'left' }}>
|
|
124
|
+
{t('VERIFY_PHONE', 'Verify Phone')}
|
|
125
|
+
</OText>
|
|
126
|
+
{lastNumbers && (
|
|
127
|
+
<OText size={20} color={theme.colors.disabled}>
|
|
128
|
+
{`${t(
|
|
129
|
+
'MESSAGE_ENTER_VERIFY_CODE',
|
|
130
|
+
'Please, enter the verification code we sent to your mobile ending with',
|
|
131
|
+
)} **${lastNumbers}`}
|
|
132
|
+
</OText>
|
|
133
|
+
)}
|
|
134
|
+
<WrappCountdown>
|
|
135
|
+
<CountDownContainer
|
|
136
|
+
color={timer === '00:00' ? theme.colors.error : theme.colors.success}>
|
|
137
|
+
<OText
|
|
138
|
+
size={30}
|
|
139
|
+
color={
|
|
140
|
+
timer === '00:00' ? theme.colors.error : theme.colors.success
|
|
141
|
+
}>
|
|
142
|
+
{timer}
|
|
143
|
+
</OText>
|
|
144
|
+
</CountDownContainer>
|
|
145
|
+
</WrappCountdown>
|
|
146
|
+
<InputsSection>
|
|
147
|
+
{[...Array(4)].map((_: any, i: number) => (
|
|
148
|
+
<TextInput
|
|
149
|
+
key={i}
|
|
150
|
+
keyboardType="number-pad"
|
|
151
|
+
placeholder={'0'}
|
|
152
|
+
style={styles.inputStyle}
|
|
153
|
+
onChangeText={(val: any) => handleChangeCode(val, i)}
|
|
154
|
+
maxLength={1}
|
|
155
|
+
editable={timer !== '00:00'}
|
|
156
|
+
/>
|
|
157
|
+
))}
|
|
158
|
+
</InputsSection>
|
|
159
|
+
{(verifyPhoneState?.result?.error
|
|
160
|
+
? verifyPhoneState
|
|
161
|
+
: checkPhoneCodeState) &&
|
|
162
|
+
!(
|
|
163
|
+
verifyPhoneState?.result?.error
|
|
164
|
+
? verifyPhoneState
|
|
165
|
+
: checkPhoneCodeState
|
|
166
|
+
)?.loading &&
|
|
167
|
+
(verifyPhoneState?.result?.error
|
|
168
|
+
? verifyPhoneState
|
|
169
|
+
: checkPhoneCodeState
|
|
170
|
+
)?.result?.error &&
|
|
171
|
+
(verifyPhoneState?.result?.error
|
|
172
|
+
? verifyPhoneState
|
|
173
|
+
: checkPhoneCodeState
|
|
174
|
+
).result?.result && (
|
|
175
|
+
<ErrorSection>
|
|
176
|
+
{checkResult(
|
|
177
|
+
(verifyPhoneState?.result?.error
|
|
178
|
+
? verifyPhoneState
|
|
179
|
+
: checkPhoneCodeState
|
|
180
|
+
).result?.result,
|
|
181
|
+
)?.map((e: any, i: number) => (
|
|
182
|
+
<OText key={i} size={20} color={theme.colors.error}>
|
|
183
|
+
{`* ${t(getTraduction(e, t))}`}
|
|
184
|
+
</OText>
|
|
185
|
+
))}
|
|
186
|
+
</ErrorSection>
|
|
187
|
+
)}
|
|
188
|
+
<ResendSection>
|
|
189
|
+
<OText size={17} style={{ marginRight: 5 }}>
|
|
190
|
+
{t('ARE_YOU_NOT_SEEING_THE_CODE', 'Are you not seeing the code?')}
|
|
191
|
+
</OText>
|
|
192
|
+
<Pressable onPress={() => handleSendCodeAgain()}>
|
|
193
|
+
<OText size={17} color={theme.colors.primary}>
|
|
194
|
+
{t('SEND_AGAIN', 'Send Again')}
|
|
195
|
+
</OText>
|
|
196
|
+
</Pressable>
|
|
197
|
+
</ResendSection>
|
|
198
|
+
<Spinner visible={checkPhoneCodeState.loading} />
|
|
199
|
+
</Container>
|
|
200
|
+
);
|
|
201
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.View`
|
|
4
|
+
width: 100%;
|
|
5
|
+
padding-top: 5px;
|
|
6
|
+
padding-left: 20px;
|
|
7
|
+
padding-right: 20px;
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
export const CountDownContainer = styled.View`
|
|
11
|
+
background-color: ${(props: any) => `${props.color}4D`};
|
|
12
|
+
border-radius: 30px;
|
|
13
|
+
padding: 5px 80px 0px;
|
|
14
|
+
margin: 0 auto;
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export const ResendSection = styled.View`
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
margin-bottom: 30px;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const WrappCountdown = styled.View`
|
|
27
|
+
padding-top: 20px;
|
|
28
|
+
padding-bottom: 20px;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export const InputsSection = styled.View`
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: row;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
export const ErrorSection = styled.View`
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
width: 100%;
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
`;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components/native';
|
|
3
|
+
import { Alert } from 'react-native';
|
|
4
|
+
import { useLanguage } from 'ordering-components/native';
|
|
5
|
+
|
|
6
|
+
const Wrapper = styled.TouchableOpacity``;
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
children: any;
|
|
10
|
+
title: string;
|
|
11
|
+
message?: string;
|
|
12
|
+
onCancel?: any;
|
|
13
|
+
onAccept?: any;
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const OAlert = (props: Props) => {
|
|
19
|
+
const [, t] = useLanguage();
|
|
20
|
+
|
|
21
|
+
const createTwoButtonAlert = () => {
|
|
22
|
+
Alert.alert(
|
|
23
|
+
props.title,
|
|
24
|
+
props.message,
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
text: t('CANCEL', 'cancel'),
|
|
28
|
+
onPress: () => props.onCancel && props.onCancel(),
|
|
29
|
+
style: 'cancel',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
text: t('ACCEPT', 'Accept'),
|
|
33
|
+
onPress: () => props.onAccept && props.onAccept(),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
{ cancelable: false },
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleClick = () => {
|
|
41
|
+
props.onClick && props.onClick();
|
|
42
|
+
createTwoButtonAlert();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Wrapper onPress={handleClick} disabled={props.disabled}>
|
|
47
|
+
{props.children}
|
|
48
|
+
</Wrapper>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default OAlert;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActivityIndicator,
|
|
3
|
+
ImageSourcePropType,
|
|
4
|
+
ImageStyle,
|
|
5
|
+
TextStyle,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import styled from 'styled-components/native';
|
|
13
|
+
|
|
14
|
+
const StyledButton = styled.View<Props>`
|
|
15
|
+
background-color: ${(props: any) => props.theme.colors.primary};
|
|
16
|
+
border-radius: 26px;
|
|
17
|
+
border-width: 2px;
|
|
18
|
+
height: 52px;
|
|
19
|
+
border-color: ${(props: any) => props.theme.colors.primary};
|
|
20
|
+
flex-direction: row;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
box-shadow: 1px 1px 2px #00000020;
|
|
24
|
+
padding-left: 20px;
|
|
25
|
+
padding-right: 20px;
|
|
26
|
+
position: relative;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const StyledButtonDisabled = styled(StyledButton)`
|
|
30
|
+
background-color: ${(props: any) => props.theme.colors.disabled};
|
|
31
|
+
border-color: ${(props: any) => props.theme.colors.disabled};
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const StyledText = styled.Text`
|
|
35
|
+
font-size: 16px;
|
|
36
|
+
color: ${(props: any) => props.theme.colors.btnFont};
|
|
37
|
+
margin-left: 10px;
|
|
38
|
+
margin-right: 10px;
|
|
39
|
+
font-family: 'Poppins-Regular';
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const StyledTextDisabled = styled(StyledText)`
|
|
43
|
+
color: ${(props: any) => props.theme.colors.primary};
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
const StyledImage = styled.Image`
|
|
47
|
+
width: 20px;
|
|
48
|
+
height: 20px;
|
|
49
|
+
resize-mode: contain;
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
const EndImage = styled.Image`
|
|
53
|
+
width: 15px;
|
|
54
|
+
height: 15px;
|
|
55
|
+
resize-mode: contain;
|
|
56
|
+
right: 20px;
|
|
57
|
+
position: absolute;
|
|
58
|
+
right: 20px;
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
interface Props {
|
|
62
|
+
testID?: string;
|
|
63
|
+
isLoading?: boolean;
|
|
64
|
+
isDisabled?: boolean;
|
|
65
|
+
onClick?: () => void;
|
|
66
|
+
style?: ViewStyle;
|
|
67
|
+
parentStyle?: ViewStyle;
|
|
68
|
+
disabledStyle?: ViewStyle;
|
|
69
|
+
textStyle?: TextStyle;
|
|
70
|
+
imgLeftSrc?: ImageSourcePropType | string;
|
|
71
|
+
imgLeftStyle?: ImageStyle;
|
|
72
|
+
imgRightSrc?: any;
|
|
73
|
+
imgRightStyle?: ImageStyle;
|
|
74
|
+
indicatorColor?: string;
|
|
75
|
+
activeOpacity?: number;
|
|
76
|
+
text?: string;
|
|
77
|
+
isCircle?: boolean;
|
|
78
|
+
bgColor?: string;
|
|
79
|
+
borderColor?: string;
|
|
80
|
+
loadingStyle?: ViewStyle;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const OButton = (props: Props): React.ReactElement => {
|
|
84
|
+
if (props.isDisabled) {
|
|
85
|
+
return (
|
|
86
|
+
<View style={props.parentStyle}>
|
|
87
|
+
<StyledButtonDisabled style={props.style}>
|
|
88
|
+
<StyledTextDisabled style={props.textStyle}>
|
|
89
|
+
{props.text}
|
|
90
|
+
</StyledTextDisabled>
|
|
91
|
+
</StyledButtonDisabled>
|
|
92
|
+
</View>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (props.isLoading) {
|
|
97
|
+
return (
|
|
98
|
+
<StyledButton style={props.style}>
|
|
99
|
+
<ActivityIndicator
|
|
100
|
+
size="small"
|
|
101
|
+
color={props.indicatorColor}
|
|
102
|
+
style={props.loadingStyle}
|
|
103
|
+
/>
|
|
104
|
+
</StyledButton>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<TouchableOpacity
|
|
110
|
+
testID={props.testID}
|
|
111
|
+
activeOpacity={props.activeOpacity}
|
|
112
|
+
onPress={props.onClick}
|
|
113
|
+
style={{
|
|
114
|
+
width: props.isCircle ? 52 : props.style?.width,
|
|
115
|
+
...props.parentStyle,
|
|
116
|
+
}}>
|
|
117
|
+
<StyledButton
|
|
118
|
+
style={
|
|
119
|
+
props.bgColor
|
|
120
|
+
? {
|
|
121
|
+
...props.style,
|
|
122
|
+
backgroundColor: props.bgColor,
|
|
123
|
+
borderColor: props.borderColor,
|
|
124
|
+
}
|
|
125
|
+
: props.style
|
|
126
|
+
}>
|
|
127
|
+
{props.imgLeftSrc ? (
|
|
128
|
+
<StyledImage style={props.imgLeftStyle} source={props.imgLeftSrc} />
|
|
129
|
+
) : null}
|
|
130
|
+
{props.text ? (
|
|
131
|
+
<StyledText style={props.textStyle}>{props.text}</StyledText>
|
|
132
|
+
) : null}
|
|
133
|
+
{props.imgRightSrc ? (
|
|
134
|
+
<EndImage style={props.imgRightStyle} source={props.imgRightSrc} />
|
|
135
|
+
) : null}
|
|
136
|
+
</StyledButton>
|
|
137
|
+
</TouchableOpacity>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
OButton.defaultProps = {
|
|
142
|
+
isLoading: false,
|
|
143
|
+
isDisabled: false,
|
|
144
|
+
indicatorColor: 'white',
|
|
145
|
+
activeOpacity: 0.5,
|
|
146
|
+
imgRightSrc: require('../../assets/icons/arrow_right.png'),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default OButton;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styled from 'styled-components/native';
|
|
3
|
+
import { OIcon } from '.';
|
|
4
|
+
import { DIRECTION } from '../../config/constants';
|
|
5
|
+
import { useTheme } from 'styled-components/native';
|
|
6
|
+
import { useUtils } from 'ordering-components/native';
|
|
7
|
+
import OText from './OText';
|
|
8
|
+
|
|
9
|
+
const Wrapper = styled.View`
|
|
10
|
+
flex: 1;
|
|
11
|
+
border-radius: 35px;
|
|
12
|
+
min-height: 50px;
|
|
13
|
+
padding-horizontal: 25px;
|
|
14
|
+
padding-vertical: 10px;
|
|
15
|
+
max-width: 80%;
|
|
16
|
+
margin-bottom: 14px;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const ImageContainer = styled.TouchableOpacity`
|
|
20
|
+
flex: 1;
|
|
21
|
+
`;
|
|
22
|
+
interface Props {
|
|
23
|
+
side?: string;
|
|
24
|
+
bgColor?: string;
|
|
25
|
+
textColor?: string;
|
|
26
|
+
contents?: any;
|
|
27
|
+
datetime?: string;
|
|
28
|
+
data?: any;
|
|
29
|
+
image?: string;
|
|
30
|
+
onClick?: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const OChatBubble = (props: Props) => {
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
const [{ optimizeImage }] = useUtils();
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Wrapper
|
|
39
|
+
style={
|
|
40
|
+
props?.side
|
|
41
|
+
? props.side === DIRECTION.RIGHT
|
|
42
|
+
? {
|
|
43
|
+
borderBottomRightRadius: 0,
|
|
44
|
+
backgroundColor: props.bgColor
|
|
45
|
+
? props.bgColor
|
|
46
|
+
: theme.colors.primary,
|
|
47
|
+
alignSelf: 'flex-end',
|
|
48
|
+
}
|
|
49
|
+
: {
|
|
50
|
+
borderBottomLeftRadius: 0,
|
|
51
|
+
backgroundColor: props.bgColor
|
|
52
|
+
? props.bgColor
|
|
53
|
+
: theme.colors.backgroundGray,
|
|
54
|
+
alignSelf: 'flex-start',
|
|
55
|
+
}
|
|
56
|
+
: {
|
|
57
|
+
borderRadius: 5,
|
|
58
|
+
backgroundColor: props.bgColor
|
|
59
|
+
? props.bgColor
|
|
60
|
+
: theme.colors.backgroundGray,
|
|
61
|
+
alignSelf: 'center',
|
|
62
|
+
}
|
|
63
|
+
}>
|
|
64
|
+
{props?.image && (
|
|
65
|
+
<ImageContainer onPress={props.onClick}>
|
|
66
|
+
<OIcon
|
|
67
|
+
cover
|
|
68
|
+
url={optimizeImage(props.image, 'h_300,c_limit')}
|
|
69
|
+
width={250}
|
|
70
|
+
height={250}
|
|
71
|
+
/>
|
|
72
|
+
</ImageContainer>
|
|
73
|
+
)}
|
|
74
|
+
<OText
|
|
75
|
+
color={
|
|
76
|
+
props.textColor
|
|
77
|
+
? props.textColor
|
|
78
|
+
: props.side == DIRECTION.RIGHT
|
|
79
|
+
? theme.colors.white
|
|
80
|
+
: 'black'
|
|
81
|
+
}>
|
|
82
|
+
{props.contents}
|
|
83
|
+
</OText>
|
|
84
|
+
<OText
|
|
85
|
+
color={
|
|
86
|
+
props.textColor
|
|
87
|
+
? props.textColor
|
|
88
|
+
: props.side == DIRECTION.RIGHT
|
|
89
|
+
? theme.colors.white
|
|
90
|
+
: 'black'
|
|
91
|
+
}
|
|
92
|
+
style={{ textAlign: 'right' }}
|
|
93
|
+
size={9}>
|
|
94
|
+
{props.datetime}
|
|
95
|
+
</OText>
|
|
96
|
+
</Wrapper>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export default OChatBubble;
|