ordering-ui-react-native 0.21.49-test → 0.21.49-test-v2
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 +2 -3
- package/themes/business/index.tsx +0 -5
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -2
- package/themes/business/src/components/FloatingButton/index.tsx +34 -31
- package/themes/business/src/components/MapView/index.tsx +6 -2
- package/themes/business/src/components/MessagesOption/index.tsx +2 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +11 -6
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +12 -0
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
- package/themes/business/src/components/OrderSummary/index.tsx +3 -10
- package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
- package/themes/business/src/components/OrdersOption/index.tsx +4 -0
- package/themes/business/src/components/PreviousOrders/OrderList.tsx +17 -12
- package/themes/business/src/components/PreviousOrders/index.tsx +77 -65
- package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
- package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +7 -4
- package/themes/original/index.tsx +6 -2
- package/themes/original/src/components/AddressForm/index.tsx +2 -2
- package/themes/original/src/components/AddressForm/styles.tsx +1 -1
- package/themes/original/src/components/AddressList/styles.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +2 -2
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
- package/themes/original/src/components/BusinessInformation/index.tsx +0 -1
- package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -7
- package/themes/original/src/components/BusinessListingSearch/index.tsx +2 -3
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
- package/themes/original/src/components/BusinessPreorder/index.tsx +2 -2
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsList/index.tsx +2 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +12 -8
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
- package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +23 -403
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
- package/themes/original/src/components/Cart/index.tsx +15 -4
- package/themes/original/src/components/CartContent/index.tsx +59 -38
- package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +47 -9
- package/themes/original/src/components/Checkout/styles.tsx +17 -0
- package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
- package/themes/original/src/components/DatePicker/index.tsx +17 -0
- package/themes/original/src/components/DatePicker/styles.tsx +20 -0
- package/themes/original/src/components/Favorite/index.tsx +1 -3
- package/themes/original/src/components/Favorite/styles.tsx +0 -2
- package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +1 -1
- package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +36 -3
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +67 -4
- package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
- package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
- package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LastOrder/index.tsx +2 -1
- package/themes/original/src/components/LastOrders/index.tsx +2 -1
- package/themes/original/src/components/Messages/styles.tsx +1 -1
- package/themes/original/src/components/MomentOption/index.tsx +3 -3
- package/themes/original/src/components/MultiCart/index.tsx +1 -1
- package/themes/original/src/components/MultiCheckout/index.tsx +140 -18
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -1
- package/themes/original/src/components/MyOrders/index.tsx +5 -5
- package/themes/original/src/components/NavBar/index.tsx +0 -1
- package/themes/original/src/components/NetworkError/styles.tsx +2 -2
- package/themes/original/src/components/Notifications/index.tsx +2 -4
- package/themes/original/src/components/Notifications/styles.tsx +0 -1
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +709 -664
- package/themes/original/src/components/OrderDetails/styles.tsx +24 -7
- package/themes/original/src/components/OrderProgress/index.tsx +2 -1
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
- package/themes/original/src/components/OrderSummary/index.tsx +3 -1
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
- package/themes/original/src/components/OrdersOption/index.tsx +1 -1
- package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +3 -1
- package/themes/original/src/components/ProductForm/ActionButton.tsx +117 -0
- package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
- package/themes/original/src/components/ProductForm/index.tsx +52 -146
- package/themes/original/src/components/ProductItemAccordion/index.tsx +5 -0
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +1 -1
- package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
- package/themes/original/src/components/Promotions/index.tsx +2 -3
- package/themes/original/src/components/Promotions/styles.tsx +0 -2
- package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
- package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
- package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
- package/themes/original/src/components/ServiceForm/index.tsx +1 -1
- package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
- package/themes/original/src/components/StripeElementsForm/index.tsx +1 -1
- package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
- package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +86 -0
- package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
- package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
- package/themes/original/src/components/UserFormDetails/index.tsx +51 -4
- package/themes/original/src/components/UserProfile/index.tsx +1 -1
- package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
- package/themes/original/src/components/Wallets/index.tsx +1 -0
- package/themes/original/src/components/Wallets/styles.tsx +0 -1
- package/themes/original/src/components/shared/OModal.tsx +12 -14
- package/themes/original/src/layouts/Container.tsx +1 -1
- package/themes/business/src/components/StarPrinter/SearchPrinter.tsx +0 -106
- package/themes/business/src/components/StarPrinter/index.tsx +0 -235
|
@@ -59,3 +59,22 @@ export const CartDivider = styled.View`
|
|
|
59
59
|
background-color: ${(props: any) => props.theme.colors.backgroundGray100};
|
|
60
60
|
margin: 20px -40px 0;
|
|
61
61
|
`
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export const TopActionsHeader = styled.TouchableOpacity`
|
|
65
|
+
height: 60px;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
min-width: 30px;
|
|
68
|
+
padding-right: 15px;
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
export const TopHeader = styled.View`
|
|
72
|
+
width: 100%;
|
|
73
|
+
flex-direction: row;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: space-between;
|
|
76
|
+
z-index: 1;
|
|
77
|
+
height: 60px;
|
|
78
|
+
min-height: 60px;
|
|
79
|
+
`
|
|
80
|
+
|
|
@@ -13,6 +13,8 @@ import { OAlert } from '../../../../../src/components/shared'
|
|
|
13
13
|
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
14
14
|
import { sortInputFields } from '../../utils';
|
|
15
15
|
import { ListItem } from '../UserProfile/styles';
|
|
16
|
+
import moment from 'moment';
|
|
17
|
+
import { DatePickerUI } from '../DatePicker';
|
|
16
18
|
|
|
17
19
|
export const UserFormDetailsUI = (props: any) => {
|
|
18
20
|
const {
|
|
@@ -81,6 +83,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
81
83
|
const [isValid, setIsValid] = useState(false)
|
|
82
84
|
const [isChanged, setIsChanged] = useState(false)
|
|
83
85
|
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
86
|
+
const [birthdate, setBirthdate] = useState(user?.birthdate ?? null)
|
|
87
|
+
const [showDatePicker, setShowDatePicker] = useState(false)
|
|
84
88
|
const [phoneInputData, setPhoneInputData] = useState({
|
|
85
89
|
error: '',
|
|
86
90
|
phone: {
|
|
@@ -92,6 +96,7 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
92
96
|
|
|
93
97
|
const isAdmin = user?.level === 0
|
|
94
98
|
const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
|
|
99
|
+
const showInputBirthday = validationFields?.fields?.checkout?.birthdate?.enabled ?? false
|
|
95
100
|
|
|
96
101
|
const handleSuccessSignup = (user: any) => {
|
|
97
102
|
login({
|
|
@@ -206,6 +211,13 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
206
211
|
handleChangeInput(countryCode, true);
|
|
207
212
|
}
|
|
208
213
|
|
|
214
|
+
const _handleChangeDate = (date: any) => {
|
|
215
|
+
setBirthdate(date)
|
|
216
|
+
const _birthdate = moment(date).format('YYYY-MM-DD')
|
|
217
|
+
handleChangeInput({ target: { name: 'birthdate', value: _birthdate } })
|
|
218
|
+
setShowDatePicker(false)
|
|
219
|
+
}
|
|
220
|
+
|
|
209
221
|
const onRemoveAccount = () => {
|
|
210
222
|
setConfirm({
|
|
211
223
|
open: true,
|
|
@@ -268,6 +280,14 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
268
280
|
}
|
|
269
281
|
}, [phoneInputData, configs?.verification_phone_required?.value, isChanged])
|
|
270
282
|
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
if (!validationFields.loading && birthdate) {
|
|
285
|
+
setValue('birthdate', formState?.result?.result
|
|
286
|
+
? formState?.result?.result?.birthdate
|
|
287
|
+
: formState?.changes?.birthdate ?? (user && user?.birthdate) ?? '')
|
|
288
|
+
}
|
|
289
|
+
}, [validationFields, birthdate])
|
|
290
|
+
|
|
271
291
|
useEffect(() => {
|
|
272
292
|
if (!requiredFields || formState?.changes?.length === 0) return
|
|
273
293
|
const _isValid = requiredFields.every((key: any) => formState?.changes[key])
|
|
@@ -359,7 +379,21 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
359
379
|
</React.Fragment>
|
|
360
380
|
),
|
|
361
381
|
)}
|
|
362
|
-
|
|
382
|
+
{showInputBirthday && (
|
|
383
|
+
<WrapperPhone>
|
|
384
|
+
<OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
|
|
385
|
+
{t('BIRTHDATE', 'Birthdate')}
|
|
386
|
+
</OText>
|
|
387
|
+
<TouchableOpacity onPress={() => setShowDatePicker(!showDatePicker)}>
|
|
388
|
+
<OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ alignSelf: 'flex-start' }}>
|
|
389
|
+
{birthdate ? moment(birthdate).format('YYYY-MM-DD') : ''}
|
|
390
|
+
</OText>
|
|
391
|
+
</TouchableOpacity>
|
|
392
|
+
{showDatePicker && (
|
|
393
|
+
<DatePickerUI birthdate={birthdate} handleChangeDate={_handleChangeDate} />
|
|
394
|
+
)}
|
|
395
|
+
</WrapperPhone>
|
|
396
|
+
)}
|
|
363
397
|
{!!showInputPhoneNumber && ((requiredFields && requiredFields.includes('cellphone')) || !requiredFields) && (
|
|
364
398
|
<WrapperPhone>
|
|
365
399
|
<OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
|
|
@@ -468,12 +502,25 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
468
502
|
? t('SIGN_UP_AND_PLACE_ORDER', 'Sign up and place order')
|
|
469
503
|
: t('CONTINUE', 'Continue'))
|
|
470
504
|
}
|
|
471
|
-
bgColor={theme.colors.
|
|
472
|
-
textStyle={{
|
|
505
|
+
bgColor={theme.colors.primary}
|
|
506
|
+
textStyle={{
|
|
507
|
+
color: !user?.guest_id && (formState.loading || !isValid) ? theme.colors.primary : theme.colors.white,
|
|
508
|
+
fontSize: 14
|
|
509
|
+
}}
|
|
473
510
|
borderColor={theme.colors.primary}
|
|
474
511
|
isDisabled={!user?.guest_id && (formState.loading || !isValid)}
|
|
475
512
|
imgRightSrc={null}
|
|
476
|
-
style={{
|
|
513
|
+
style={{
|
|
514
|
+
borderRadius: 7.6,
|
|
515
|
+
shadowOpacity: 0,
|
|
516
|
+
width: '100%',
|
|
517
|
+
borderWidth: 1,
|
|
518
|
+
marginTop: 20,
|
|
519
|
+
marginBottom: 20,
|
|
520
|
+
backgroundColor: !user?.guest_id && (formState.loading || !isValid) ? theme.colors.lightGray : theme.colors.primary,
|
|
521
|
+
borderColor: !user?.guest_id && (formState.loading || !isValid) ? theme.colors.white : theme.colors.primary,
|
|
522
|
+
opacity: !user?.guest_id && (formState.loading || !isValid) ? 0.3 : 1,
|
|
523
|
+
}}
|
|
477
524
|
onClick={!user?.guest_id ? handleSubmit(onSubmit) : () => setIsModalOpen(true)}
|
|
478
525
|
/>
|
|
479
526
|
)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Modal, StyleSheet, Text, SafeAreaView, View, TouchableOpacity, Platform } from "react-native";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import styled from 'styled-components/native';
|
|
4
|
+
import AntDesignIcon from 'react-native-vector-icons/AntDesign'
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
open?: boolean;
|
|
@@ -50,17 +50,15 @@ const OModal = (props: Props): React.ReactElement => {
|
|
|
50
50
|
isAvoidKeyBoardView
|
|
51
51
|
} = props
|
|
52
52
|
|
|
53
|
-
const theme = useTheme();
|
|
54
|
-
|
|
55
53
|
const renderSafeAreaView = () => (
|
|
56
54
|
<SafeAreaView style={styles.container}>
|
|
57
55
|
{!entireModal ? (
|
|
58
56
|
<View style={styles.centeredView}>
|
|
59
57
|
<View style={titleSectionStyle ? titleSectionStyle : styles.titleSection}>
|
|
60
|
-
<TouchableOpacity style={{...styles.wrapperIcon, ...styleContainerCloseButton}} onPress={onClose}>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
<TouchableOpacity style={{ ...styles.wrapperIcon, ...styleContainerCloseButton }} onPress={onClose}>
|
|
59
|
+
<AntDesignIcon
|
|
60
|
+
name='close'
|
|
61
|
+
size={26}
|
|
64
62
|
style={isNotDecoration && (styleCloseButton || styles.cancelBtn)}
|
|
65
63
|
/>
|
|
66
64
|
</TouchableOpacity>
|
|
@@ -73,9 +71,9 @@ const OModal = (props: Props): React.ReactElement => {
|
|
|
73
71
|
{!customClose && (
|
|
74
72
|
<View style={titleSectionStyle ? titleSectionStyle : styles.titleSection}>
|
|
75
73
|
<TouchableOpacity style={styles.wrapperIcon} onPress={onClose}>
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
<AntDesignIcon
|
|
75
|
+
name='close'
|
|
76
|
+
size={26}
|
|
79
77
|
style={styleCloseButton || styles.cancelBtn}
|
|
80
78
|
/>
|
|
81
79
|
</TouchableOpacity>
|
|
@@ -93,7 +91,7 @@ const OModal = (props: Props): React.ReactElement => {
|
|
|
93
91
|
animationType="slide"
|
|
94
92
|
transparent={isTransparent}
|
|
95
93
|
visible={open}
|
|
96
|
-
onRequestClose={() =>
|
|
94
|
+
onRequestClose={() => onClose && onClose()}
|
|
97
95
|
style={{ height: '100%', flex: 1, position: 'absolute', ...style, zIndex: 9999 }}
|
|
98
96
|
>
|
|
99
97
|
{isAvoidKeyBoardView ? (
|
|
@@ -125,8 +123,8 @@ const styles = StyleSheet.create({
|
|
|
125
123
|
flex: 1,
|
|
126
124
|
justifyContent: 'space-between',
|
|
127
125
|
alignItems: 'flex-start',
|
|
128
|
-
paddingLeft:
|
|
129
|
-
paddingRight:
|
|
126
|
+
paddingLeft: 20,
|
|
127
|
+
paddingRight: 20,
|
|
130
128
|
marginBottom: 40
|
|
131
129
|
},
|
|
132
130
|
cancelBtn: {
|
|
@@ -6,7 +6,7 @@ import { Platform, View } from 'react-native';
|
|
|
6
6
|
const ContainerStyled = styled.ScrollView`
|
|
7
7
|
flex: 1;
|
|
8
8
|
${(props: any) => !props.noPadding && css`
|
|
9
|
-
padding: ${Platform.OS === 'ios' ? '0px
|
|
9
|
+
padding: ${Platform.OS === 'ios' ? '0px 20px' : '20px 20px'};
|
|
10
10
|
`}
|
|
11
11
|
background-color: ${(props: any) => props.theme.colors.backgroundPage};
|
|
12
12
|
`;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Text,
|
|
5
|
-
Button,
|
|
6
|
-
FlatList,
|
|
7
|
-
PermissionsAndroid,
|
|
8
|
-
Platform
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
InterfaceType,
|
|
13
|
-
StarDeviceDiscoveryManager,
|
|
14
|
-
StarDeviceDiscoveryManagerFactory,
|
|
15
|
-
StarPrinter
|
|
16
|
-
} from 'react-native-star-io10';
|
|
17
|
-
import { useTheme } from 'styled-components';
|
|
18
|
-
import { OIconButton } from '../shared';
|
|
19
|
-
|
|
20
|
-
const SearchStarPrinter = ({ navigation }: any) => {
|
|
21
|
-
let _manager: StarDeviceDiscoveryManager;
|
|
22
|
-
const theme = useTheme();
|
|
23
|
-
|
|
24
|
-
const [state, setState] = useState({
|
|
25
|
-
bluetoothIsEnabled: true,
|
|
26
|
-
bluetoothLeIsEnabled: true,
|
|
27
|
-
printers: [],
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const _onPressDiscoveryButton = async () => {
|
|
31
|
-
|
|
32
|
-
setState({
|
|
33
|
-
...state,
|
|
34
|
-
printers: [],
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
await _manager?.stopDiscovery()
|
|
39
|
-
|
|
40
|
-
const interfaceTypes: Array<InterfaceType> = []
|
|
41
|
-
|
|
42
|
-
if (state.bluetoothIsEnabled) {
|
|
43
|
-
interfaceTypes.push(InterfaceType.Bluetooth);
|
|
44
|
-
}
|
|
45
|
-
if (state.bluetoothLeIsEnabled) {
|
|
46
|
-
interfaceTypes.push(InterfaceType.BluetoothLE);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
_manager = await StarDeviceDiscoveryManagerFactory.create(interfaceTypes);
|
|
50
|
-
_manager.discoveryTime = 10000;
|
|
51
|
-
|
|
52
|
-
_manager.onPrinterFound = (printer: StarPrinter) => {
|
|
53
|
-
const printers = state.printers;
|
|
54
|
-
printers.push(printer);
|
|
55
|
-
setState({
|
|
56
|
-
...state,
|
|
57
|
-
printers: printers
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
console.log(`Found printer: ${printer.connectionSettings.identifier}.`);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
_manager.onDiscoveryFinished = () => {
|
|
64
|
-
console.log(`Discovery finished.`);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
await _manager.startDiscovery();
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
console.log(`Error: ${String(error)}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const handleArrowBack = () => {
|
|
76
|
-
navigation?.canGoBack() && navigation.goBack();
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<View style={{ margin: 50 }}>
|
|
81
|
-
<OIconButton
|
|
82
|
-
icon={theme.images.general.arrow_left}
|
|
83
|
-
iconStyle={{ width: 20, height: 20 }}
|
|
84
|
-
borderColor={theme.colors.clear}
|
|
85
|
-
style={{ maxWidth: 40, justifyContent: 'flex-end' }}
|
|
86
|
-
onClick={() => handleArrowBack()}
|
|
87
|
-
/>
|
|
88
|
-
<Text>Interface</Text>
|
|
89
|
-
|
|
90
|
-
<View
|
|
91
|
-
style={{ width: 100, marginTop: 30 }}>
|
|
92
|
-
<Button
|
|
93
|
-
title="Discovery"
|
|
94
|
-
onPress={async () => await _onPressDiscoveryButton()}
|
|
95
|
-
/>
|
|
96
|
-
</View>
|
|
97
|
-
<FlatList
|
|
98
|
-
style={{ marginTop: 30 }}
|
|
99
|
-
data={state.printers}
|
|
100
|
-
renderItem={({ item }) => <Text>{item.connectionSettings.interfaceType} : {item.connectionSettings.identifier}</Text>}
|
|
101
|
-
keyExtractor={(item, index) => index.toString()} />
|
|
102
|
-
</View>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export default SearchStarPrinter;
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Text,
|
|
5
|
-
Button,
|
|
6
|
-
TextInput,
|
|
7
|
-
PermissionsAndroid,
|
|
8
|
-
Platform
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
Picker
|
|
13
|
-
} from '@react-native-picker/picker';
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
InterfaceType,
|
|
17
|
-
StarConnectionSettings,
|
|
18
|
-
StarXpandCommand,
|
|
19
|
-
StarPrinter
|
|
20
|
-
} from 'react-native-star-io10';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const HandleStarPrinter = ({ navigation }) => {
|
|
24
|
-
|
|
25
|
-
const [state, setState] = React.useState({
|
|
26
|
-
interfaceType: InterfaceType.Bluetooth,
|
|
27
|
-
identifier: '00:11:62:00:00:00',
|
|
28
|
-
imageBase64: ''
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const _onPressPrintButton = async () => {
|
|
32
|
-
const settings = new StarConnectionSettings();
|
|
33
|
-
settings.interfaceType = state.interfaceType;
|
|
34
|
-
settings.identifier = state.identifier;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const printer = new StarPrinter(settings);
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
const builder = new StarXpandCommand.StarXpandCommandBuilder();
|
|
41
|
-
builder.addDocument(new StarXpandCommand.DocumentBuilder()
|
|
42
|
-
.addPrinter(new StarXpandCommand.PrinterBuilder()
|
|
43
|
-
.actionPrintImage(new StarXpandCommand.Printer.ImageParameter("logo_01.png", 406))
|
|
44
|
-
.styleInternationalCharacter(StarXpandCommand.Printer.InternationalCharacterType.Usa)
|
|
45
|
-
.styleCharacterSpace(0)
|
|
46
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Center)
|
|
47
|
-
.actionPrintText("Star Clothing Boutique\n" +
|
|
48
|
-
"123 Star Road\n" +
|
|
49
|
-
"City, State 12345\n" +
|
|
50
|
-
"\n")
|
|
51
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Left)
|
|
52
|
-
.actionPrintText("Date:MM/DD/YYYY Time:HH:MM PM\n" +
|
|
53
|
-
"--------------------------------\n" +
|
|
54
|
-
"\n")
|
|
55
|
-
.actionPrintText("SKU Description Total\n" +
|
|
56
|
-
"300678566 PLAIN T-SHIRT 10.99\n" +
|
|
57
|
-
"300692003 BLACK DENIM 29.99\n" +
|
|
58
|
-
"300651148 BLUE DENIM 29.99\n" +
|
|
59
|
-
"300642980 STRIPED DRESS 49.99\n" +
|
|
60
|
-
"300638471 BLACK BOOTS 35.99\n" +
|
|
61
|
-
"\n" +
|
|
62
|
-
"Subtotal 156.95\n" +
|
|
63
|
-
"Tax 0.00\n" +
|
|
64
|
-
"--------------------------------\n")
|
|
65
|
-
.actionPrintText("Total ")
|
|
66
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
67
|
-
.styleMagnification(new StarXpandCommand.MagnificationParameter(2, 2))
|
|
68
|
-
.actionPrintText(" $156.95\n")
|
|
69
|
-
)
|
|
70
|
-
.actionPrintText("--------------------------------\n" +
|
|
71
|
-
"\n" +
|
|
72
|
-
"Charge\n" +
|
|
73
|
-
"156.95\n" +
|
|
74
|
-
"Visa XXXX-XXXX-XXXX-0123\n" +
|
|
75
|
-
"\n")
|
|
76
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
77
|
-
.styleInvert(true)
|
|
78
|
-
.actionPrintText("Refunds and Exchanges\n")
|
|
79
|
-
)
|
|
80
|
-
.actionPrintText("Within ")
|
|
81
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
82
|
-
.styleUnderLine(true)
|
|
83
|
-
.actionPrintText("30 days")
|
|
84
|
-
)
|
|
85
|
-
.actionPrintText(" with receipt\n")
|
|
86
|
-
.actionPrintText("And tags attached\n" +
|
|
87
|
-
"\n")
|
|
88
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Center)
|
|
89
|
-
.actionPrintBarcode(new StarXpandCommand.Printer.BarcodeParameter('0123456',
|
|
90
|
-
StarXpandCommand.Printer.BarcodeSymbology.Jan8)
|
|
91
|
-
.setBarDots(3)
|
|
92
|
-
.setBarRatioLevel(StarXpandCommand.Printer.BarcodeBarRatioLevel.Level0)
|
|
93
|
-
.setHeight(5)
|
|
94
|
-
.setPrintHri(true))
|
|
95
|
-
.actionFeedLine(1)
|
|
96
|
-
.actionPrintQRCode(new StarXpandCommand.Printer.QRCodeParameter('Hello World.\n')
|
|
97
|
-
.setModel(StarXpandCommand.Printer.QRCodeModel.Model2)
|
|
98
|
-
.setLevel(StarXpandCommand.Printer.QRCodeLevel.L)
|
|
99
|
-
.setCellSize(8))
|
|
100
|
-
.actionCut(StarXpandCommand.Printer.CutType.Partial)
|
|
101
|
-
)
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const commands = await builder.getCommands();
|
|
105
|
-
|
|
106
|
-
await printer.open();
|
|
107
|
-
await printer.print(commands);
|
|
108
|
-
|
|
109
|
-
console.log(`Success`);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
console.log(`Error: ${String(error)}`);
|
|
113
|
-
}
|
|
114
|
-
finally {
|
|
115
|
-
await printer.close();
|
|
116
|
-
await printer.dispose();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const onSearchPrint = () => {
|
|
122
|
-
navigation.navigate('SearchStarPrinter')
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const onPrintStatus = async () => {
|
|
126
|
-
const settings = new StarConnectionSettings();
|
|
127
|
-
settings.interfaceType = InterfaceType.Lan;
|
|
128
|
-
settings.identifier = '00:11:62:00:00:00';
|
|
129
|
-
const printer = new StarPrinter(settings);
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
// Connect to the printer.
|
|
133
|
-
await printer.open();
|
|
134
|
-
|
|
135
|
-
// Get printer status.
|
|
136
|
-
const status = await printer.getStatus();
|
|
137
|
-
console.log(status);
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
// Error.
|
|
141
|
-
console.log(error);
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
// Disconnect from the printer and dispose object.
|
|
145
|
-
await printer.close();
|
|
146
|
-
await printer.dispose();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const onPrinterMonitor = async () => {
|
|
151
|
-
let printer: StarPrinter;
|
|
152
|
-
const settings = new StarConnectionSettings();
|
|
153
|
-
settings.interfaceType = InterfaceType.Lan;
|
|
154
|
-
settings.identifier = '00:11:62:00:00:00';
|
|
155
|
-
printer = new StarPrinter(settings);
|
|
156
|
-
|
|
157
|
-
// Callback for printer state changed.
|
|
158
|
-
printer.printerDelegate.onReady = () => {
|
|
159
|
-
console.log(`Printer: Ready`);
|
|
160
|
-
}
|
|
161
|
-
printer.drawerDelegate.onOpenCloseSignalSwitched = (openCloseSignal: any) => {
|
|
162
|
-
console.log(`Drawer: Open Close Signal Switched: ${String(openCloseSignal)}`);
|
|
163
|
-
}
|
|
164
|
-
printer.inputDeviceDelegate.onDataReceived = (data: any) => {
|
|
165
|
-
console.log(`Input Device: DataReceived ${String(data)}`);
|
|
166
|
-
}
|
|
167
|
-
printer.displayDelegate.onConnected = () => {
|
|
168
|
-
console.log(`Display: Connected`);
|
|
169
|
-
}
|
|
170
|
-
// ...
|
|
171
|
-
// Please refer to document for other callback.
|
|
172
|
-
|
|
173
|
-
try {
|
|
174
|
-
// Connect to the printer.
|
|
175
|
-
await printer.open();
|
|
176
|
-
}
|
|
177
|
-
catch (error) {
|
|
178
|
-
// Error.
|
|
179
|
-
console.log(error);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return (
|
|
184
|
-
<View style={{ margin: 50 }}>
|
|
185
|
-
<View style={{ flexDirection: 'row' }}>
|
|
186
|
-
<Text style={{ width: 100 }}>Interface</Text>
|
|
187
|
-
<Picker
|
|
188
|
-
style={{ width: 200, marginLeft: 20, justifyContent: 'center' }}
|
|
189
|
-
selectedValue={state.interfaceType}
|
|
190
|
-
onValueChange={(value) => {
|
|
191
|
-
setState({ ...state, interfaceType: value });
|
|
192
|
-
}}>
|
|
193
|
-
<Picker.Item label='Bluetooth' value={InterfaceType.Bluetooth} />
|
|
194
|
-
<Picker.Item label='Bluetooth LE' value={InterfaceType.BluetoothLE} />
|
|
195
|
-
</Picker>
|
|
196
|
-
</View>
|
|
197
|
-
<View style={{ flexDirection: 'row', marginTop: 30 }}>
|
|
198
|
-
<Text style={{ width: 100 }}>Identifier</Text>
|
|
199
|
-
<TextInput
|
|
200
|
-
style={{ width: 200, marginLeft: 20 }}
|
|
201
|
-
value={state.identifier}
|
|
202
|
-
onChangeText={(value) => {
|
|
203
|
-
setState({ ...state, identifier: value });
|
|
204
|
-
}}
|
|
205
|
-
/>
|
|
206
|
-
</View>
|
|
207
|
-
<View style={{ width: 100, marginTop: 20 }}>
|
|
208
|
-
<Button
|
|
209
|
-
title="Search Printer"
|
|
210
|
-
onPress={onSearchPrint}
|
|
211
|
-
/>
|
|
212
|
-
</View>
|
|
213
|
-
<View style={{ width: 100, marginTop: 20 }}>
|
|
214
|
-
<Button
|
|
215
|
-
title="Printer status"
|
|
216
|
-
onPress={onPrintStatus}
|
|
217
|
-
/>
|
|
218
|
-
</View>
|
|
219
|
-
<View style={{ width: 100, marginTop: 20 }}>
|
|
220
|
-
<Button
|
|
221
|
-
title="Printer monitor"
|
|
222
|
-
onPress={onPrinterMonitor}
|
|
223
|
-
/>
|
|
224
|
-
</View>
|
|
225
|
-
<View style={{ width: 100, marginTop: 20 }}>
|
|
226
|
-
<Button
|
|
227
|
-
title="Print"
|
|
228
|
-
onPress={async () => await _onPressPrintButton()}
|
|
229
|
-
/>
|
|
230
|
-
</View>
|
|
231
|
-
</View>
|
|
232
|
-
);
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
export default HandleStarPrinter;
|