ordering-ui-react-native 0.21.35-test → 0.21.37-test
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.21.
|
|
3
|
+
"version": "0.21.37-test",
|
|
4
4
|
"description": "Reusable components made in react native",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"author": "ordering.inc",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@react-native-firebase/analytics": "^12.9.3",
|
|
46
46
|
"@react-native-firebase/app": "^12.9.3",
|
|
47
47
|
"@react-native-google-signin/google-signin": "^7.0.1",
|
|
48
|
+
"@react-native-picker/picker": "^2.4.10",
|
|
48
49
|
"@react-navigation/drawer": "^5.10.2",
|
|
49
50
|
"@react-navigation/material-bottom-tabs": "^5.3.14",
|
|
50
51
|
"@react-navigation/native": "^5.7.6",
|
|
@@ -42,6 +42,7 @@ import { NewOrderNotification } from './src/components/NewOrderNotification';
|
|
|
42
42
|
import { DriverSchedule } from './src/components/DriverSchedule';
|
|
43
43
|
import { ScheduleBlocked } from './src/components/ScheduleBlocked';
|
|
44
44
|
import { OrderDetailsLogistic } from './src/components/OrderDetailsLogistic'
|
|
45
|
+
import HandleStarPrinter from './src/components/StarPrinter';
|
|
45
46
|
//OComponents
|
|
46
47
|
import {
|
|
47
48
|
OText,
|
|
@@ -130,4 +131,6 @@ export {
|
|
|
130
131
|
useLocation,
|
|
131
132
|
// providers
|
|
132
133
|
StoreMethods,
|
|
134
|
+
//printer
|
|
135
|
+
HandleStarPrinter,
|
|
133
136
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { OText, OIconButton } from '../shared';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
StyleSheet, View, Platform, Alert
|
|
5
|
+
} from 'react-native';
|
|
4
6
|
import {
|
|
5
7
|
Content,
|
|
6
8
|
OrderCustomer,
|
|
@@ -21,12 +23,6 @@ import RNHTMLtoPDF from 'react-native-html-to-pdf';
|
|
|
21
23
|
import RNPrint from 'react-native-print';
|
|
22
24
|
import { useTheme } from 'styled-components/native';
|
|
23
25
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
24
|
-
import {
|
|
25
|
-
InterfaceType,
|
|
26
|
-
StarConnectionSettings,
|
|
27
|
-
StarXpandCommand,
|
|
28
|
-
StarPrinter
|
|
29
|
-
} from 'react-native-star-io10';
|
|
30
26
|
|
|
31
27
|
|
|
32
28
|
export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermission, getPermissions, isGrantedPermissions, checkBluetoothPermission }: any) => {
|
|
@@ -39,11 +35,7 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
|
|
|
39
35
|
const [state, setState] = useState({
|
|
40
36
|
selectedPrinter: { url: undefined },
|
|
41
37
|
});
|
|
42
|
-
|
|
43
|
-
interfaceType: InterfaceType.Bluetooth,
|
|
44
|
-
identifier: '00:11:62:00:00:00',
|
|
45
|
-
imageBase64: ''
|
|
46
|
-
});
|
|
38
|
+
|
|
47
39
|
|
|
48
40
|
const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
|
|
49
41
|
if (name !== 'No') {
|
|
@@ -351,93 +343,8 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
|
|
|
351
343
|
}
|
|
352
344
|
};
|
|
353
345
|
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
let settings = new StarConnectionSettings();
|
|
357
|
-
settings.interfaceType = printState.interfaceType;
|
|
358
|
-
settings.identifier = printState.identifier;
|
|
359
|
-
|
|
360
|
-
let printer = new StarPrinter(settings);
|
|
361
|
-
|
|
362
|
-
try {
|
|
363
|
-
let builder = new StarXpandCommand.StarXpandCommandBuilder();
|
|
364
|
-
builder.addDocument(new StarXpandCommand.DocumentBuilder()
|
|
365
|
-
.addPrinter(new StarXpandCommand.PrinterBuilder()
|
|
366
|
-
.actionPrintImage(new StarXpandCommand.Printer.ImageParameter("logo_01.png", 406))
|
|
367
|
-
.styleInternationalCharacter(StarXpandCommand.Printer.InternationalCharacterType.Usa)
|
|
368
|
-
.styleCharacterSpace(0)
|
|
369
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Center)
|
|
370
|
-
.actionPrintText("Star Clothing Boutique\n" +
|
|
371
|
-
"123 Star Road\n" +
|
|
372
|
-
"City, State 12345\n" +
|
|
373
|
-
"\n")
|
|
374
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Left)
|
|
375
|
-
.actionPrintText("Date:MM/DD/YYYY Time:HH:MM PM\n" +
|
|
376
|
-
"--------------------------------\n" +
|
|
377
|
-
"\n")
|
|
378
|
-
.actionPrintText("SKU Description Total\n" +
|
|
379
|
-
"300678566 PLAIN T-SHIRT 10.99\n" +
|
|
380
|
-
"300692003 BLACK DENIM 29.99\n" +
|
|
381
|
-
"300651148 BLUE DENIM 29.99\n" +
|
|
382
|
-
"300642980 STRIPED DRESS 49.99\n" +
|
|
383
|
-
"300638471 BLACK BOOTS 35.99\n" +
|
|
384
|
-
"\n" +
|
|
385
|
-
"Subtotal 156.95\n" +
|
|
386
|
-
"Tax 0.00\n" +
|
|
387
|
-
"--------------------------------\n")
|
|
388
|
-
.actionPrintText("Total ")
|
|
389
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
390
|
-
.styleMagnification(new StarXpandCommand.MagnificationParameter(2, 2))
|
|
391
|
-
.actionPrintText(" $156.95\n")
|
|
392
|
-
)
|
|
393
|
-
.actionPrintText("--------------------------------\n" +
|
|
394
|
-
"\n" +
|
|
395
|
-
"Charge\n" +
|
|
396
|
-
"156.95\n" +
|
|
397
|
-
"Visa XXXX-XXXX-XXXX-0123\n" +
|
|
398
|
-
"\n")
|
|
399
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
400
|
-
.styleInvert(true)
|
|
401
|
-
.actionPrintText("Refunds and Exchanges\n")
|
|
402
|
-
)
|
|
403
|
-
.actionPrintText("Within ")
|
|
404
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
405
|
-
.styleUnderLine(true)
|
|
406
|
-
.actionPrintText("30 days")
|
|
407
|
-
)
|
|
408
|
-
.actionPrintText(" with receipt\n")
|
|
409
|
-
.actionPrintText("And tags attached\n" +
|
|
410
|
-
"\n")
|
|
411
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Center)
|
|
412
|
-
.actionPrintBarcode(new StarXpandCommand.Printer.BarcodeParameter('0123456',
|
|
413
|
-
StarXpandCommand.Printer.BarcodeSymbology.Jan8)
|
|
414
|
-
.setBarDots(3)
|
|
415
|
-
.setBarRatioLevel(StarXpandCommand.Printer.BarcodeBarRatioLevel.Level0)
|
|
416
|
-
.setHeight(5)
|
|
417
|
-
.setPrintHri(true))
|
|
418
|
-
.actionFeedLine(1)
|
|
419
|
-
.actionPrintQRCode(new StarXpandCommand.Printer.QRCodeParameter('Hello World.\n')
|
|
420
|
-
.setModel(StarXpandCommand.Printer.QRCodeModel.Model2)
|
|
421
|
-
.setLevel(StarXpandCommand.Printer.QRCodeLevel.L)
|
|
422
|
-
.setCellSize(8))
|
|
423
|
-
.actionCut(StarXpandCommand.Printer.CutType.Partial)
|
|
424
|
-
)
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
let commands = await builder.getCommands();
|
|
428
|
-
|
|
429
|
-
await printer.open();
|
|
430
|
-
await printer.print(commands);
|
|
431
|
-
|
|
432
|
-
console.log(`Success`);
|
|
433
|
-
}
|
|
434
|
-
catch (error) {
|
|
435
|
-
console.log(`Error: ${String(error)}`);
|
|
436
|
-
}
|
|
437
|
-
finally {
|
|
438
|
-
await printer.close();
|
|
439
|
-
await printer.dispose();
|
|
440
|
-
}
|
|
346
|
+
const openPrint = () => {
|
|
347
|
+
navigation.navigate('HandleStarPrinter')
|
|
441
348
|
}
|
|
442
349
|
|
|
443
350
|
return (
|
|
@@ -779,7 +686,7 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
|
|
|
779
686
|
|
|
780
687
|
<View style={{ marginBottom: 0 }}>
|
|
781
688
|
<FloatingButton
|
|
782
|
-
firstButtonClick={() =>
|
|
689
|
+
firstButtonClick={() => openPrint()}
|
|
783
690
|
btnText={t('PRINT', 'Print')}
|
|
784
691
|
color={theme.colors.green}
|
|
785
692
|
widthButton={'100%'}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
InterfaceType,
|
|
4
|
+
StarConnectionSettings,
|
|
5
|
+
StarXpandCommand,
|
|
6
|
+
StarPrinter
|
|
7
|
+
} from 'react-native-star-io10';
|
|
8
|
+
import { Picker } from '@react-native-picker/picker';
|
|
9
|
+
import {
|
|
10
|
+
View,
|
|
11
|
+
Text,
|
|
12
|
+
Button,
|
|
13
|
+
TextInput,
|
|
14
|
+
} from 'react-native';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const HandleStarPrinter = () => {
|
|
18
|
+
|
|
19
|
+
const [printState, setPrintState] = useState({
|
|
20
|
+
interfaceType: InterfaceType.Bluetooth,
|
|
21
|
+
identifier: '00:11:62:00:00:00',
|
|
22
|
+
imageBase64: ''
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const _onPressPrintButton = async () => {
|
|
26
|
+
|
|
27
|
+
let settings = new StarConnectionSettings();
|
|
28
|
+
settings.interfaceType = printState.interfaceType;
|
|
29
|
+
settings.identifier = printState.identifier;
|
|
30
|
+
|
|
31
|
+
let printer = new StarPrinter(settings);
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
let builder = new StarXpandCommand.StarXpandCommandBuilder();
|
|
35
|
+
builder.addDocument(new StarXpandCommand.DocumentBuilder()
|
|
36
|
+
.addPrinter(new StarXpandCommand.PrinterBuilder()
|
|
37
|
+
.actionPrintImage(new StarXpandCommand.Printer.ImageParameter("logo_01.png", 406))
|
|
38
|
+
.styleInternationalCharacter(StarXpandCommand.Printer.InternationalCharacterType.Usa)
|
|
39
|
+
.styleCharacterSpace(0)
|
|
40
|
+
.styleAlignment(StarXpandCommand.Printer.Alignment.Center)
|
|
41
|
+
.actionPrintText("Star Clothing Boutique\n" +
|
|
42
|
+
"123 Star Road\n" +
|
|
43
|
+
"City, State 12345\n" +
|
|
44
|
+
"\n")
|
|
45
|
+
.styleAlignment(StarXpandCommand.Printer.Alignment.Left)
|
|
46
|
+
.actionPrintText("Date:MM/DD/YYYY Time:HH:MM PM\n" +
|
|
47
|
+
"--------------------------------\n" +
|
|
48
|
+
"\n")
|
|
49
|
+
.actionPrintText("SKU Description Total\n" +
|
|
50
|
+
"300678566 PLAIN T-SHIRT 10.99\n" +
|
|
51
|
+
"300692003 BLACK DENIM 29.99\n" +
|
|
52
|
+
"300651148 BLUE DENIM 29.99\n" +
|
|
53
|
+
"300642980 STRIPED DRESS 49.99\n" +
|
|
54
|
+
"300638471 BLACK BOOTS 35.99\n" +
|
|
55
|
+
"\n" +
|
|
56
|
+
"Subtotal 156.95\n" +
|
|
57
|
+
"Tax 0.00\n" +
|
|
58
|
+
"--------------------------------\n")
|
|
59
|
+
.actionPrintText("Total ")
|
|
60
|
+
.add(new StarXpandCommand.PrinterBuilder()
|
|
61
|
+
.styleMagnification(new StarXpandCommand.MagnificationParameter(2, 2))
|
|
62
|
+
.actionPrintText(" $156.95\n")
|
|
63
|
+
)
|
|
64
|
+
.actionPrintText("--------------------------------\n" +
|
|
65
|
+
"\n" +
|
|
66
|
+
"Charge\n" +
|
|
67
|
+
"156.95\n" +
|
|
68
|
+
"Visa XXXX-XXXX-XXXX-0123\n" +
|
|
69
|
+
"\n")
|
|
70
|
+
.add(new StarXpandCommand.PrinterBuilder()
|
|
71
|
+
.styleInvert(true)
|
|
72
|
+
.actionPrintText("Refunds and Exchanges\n")
|
|
73
|
+
)
|
|
74
|
+
.actionPrintText("Within ")
|
|
75
|
+
.add(new StarXpandCommand.PrinterBuilder()
|
|
76
|
+
.styleUnderLine(true)
|
|
77
|
+
.actionPrintText("30 days")
|
|
78
|
+
)
|
|
79
|
+
.actionPrintText(" with receipt\n")
|
|
80
|
+
.actionPrintText("And tags attached\n" +
|
|
81
|
+
"\n")
|
|
82
|
+
.styleAlignment(StarXpandCommand.Printer.Alignment.Center)
|
|
83
|
+
.actionPrintBarcode(new StarXpandCommand.Printer.BarcodeParameter('0123456',
|
|
84
|
+
StarXpandCommand.Printer.BarcodeSymbology.Jan8)
|
|
85
|
+
.setBarDots(3)
|
|
86
|
+
.setBarRatioLevel(StarXpandCommand.Printer.BarcodeBarRatioLevel.Level0)
|
|
87
|
+
.setHeight(5)
|
|
88
|
+
.setPrintHri(true))
|
|
89
|
+
.actionFeedLine(1)
|
|
90
|
+
.actionPrintQRCode(new StarXpandCommand.Printer.QRCodeParameter('Hello World.\n')
|
|
91
|
+
.setModel(StarXpandCommand.Printer.QRCodeModel.Model2)
|
|
92
|
+
.setLevel(StarXpandCommand.Printer.QRCodeLevel.L)
|
|
93
|
+
.setCellSize(8))
|
|
94
|
+
.actionCut(StarXpandCommand.Printer.CutType.Partial)
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
let commands = await builder.getCommands();
|
|
99
|
+
|
|
100
|
+
await printer.open();
|
|
101
|
+
await printer.print(commands);
|
|
102
|
+
|
|
103
|
+
console.log(`Success`);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.log(`Error: ${String(error)}`);
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
await printer.close();
|
|
110
|
+
await printer.dispose();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<View style={{ margin: 50 }}>
|
|
116
|
+
<View style={{ flexDirection: 'row' }}>
|
|
117
|
+
<Text style={{ width: 100 }}>Interface</Text>
|
|
118
|
+
<Picker
|
|
119
|
+
style={{ width: 200, marginLeft: 20, justifyContent: 'center' }}
|
|
120
|
+
selectedValue={printState.interfaceType}
|
|
121
|
+
onValueChange={(value) => {
|
|
122
|
+
setPrintState({ interfaceType: value });
|
|
123
|
+
}}>
|
|
124
|
+
<Picker.Item label='LAN' value={InterfaceType.Lan} />
|
|
125
|
+
<Picker.Item label='Bluetooth' value={InterfaceType.Bluetooth} />
|
|
126
|
+
<Picker.Item label='Bluetooth LE' value={InterfaceType.BluetoothLE} />
|
|
127
|
+
<Picker.Item label='USB' value={InterfaceType.Usb} />
|
|
128
|
+
</Picker>
|
|
129
|
+
</View>
|
|
130
|
+
<View style={{ flexDirection: 'row', marginTop: 30 }}>
|
|
131
|
+
<Text style={{ width: 100 }}>Identifier</Text>
|
|
132
|
+
<TextInput
|
|
133
|
+
style={{ width: 200, marginLeft: 20 }}
|
|
134
|
+
value={printState.identifier}
|
|
135
|
+
onChangeText={(value) => {
|
|
136
|
+
setPrintState({ identifier: value });
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
</View>
|
|
140
|
+
<View style={{ width: 100, marginTop: 20 }}>
|
|
141
|
+
<Button
|
|
142
|
+
title="Print"
|
|
143
|
+
onPress={_onPressPrintButton}
|
|
144
|
+
/>
|
|
145
|
+
</View>
|
|
146
|
+
</View>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default HandleStarPrinter;
|