ordering-ui-react-native 0.21.43-test → 0.21.45-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
|
@@ -42,8 +42,8 @@ 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
|
|
46
|
-
import
|
|
45
|
+
import HandleStarPrinter from './src/components/StarPrinter/';
|
|
46
|
+
import SearchStarPrinter from './src/components/StarPrinter/SearchPrinter';
|
|
47
47
|
//OComponents
|
|
48
48
|
import {
|
|
49
49
|
OText,
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
Text,
|
|
5
5
|
Button,
|
|
6
6
|
FlatList,
|
|
7
|
+
PermissionsAndroid,
|
|
8
|
+
Platform
|
|
7
9
|
} from 'react-native';
|
|
8
10
|
|
|
9
11
|
import {
|
|
@@ -12,13 +14,12 @@ import {
|
|
|
12
14
|
StarDeviceDiscoveryManagerFactory,
|
|
13
15
|
StarPrinter
|
|
14
16
|
} from 'react-native-star-io10';
|
|
17
|
+
import { OIconButton } from 'ordering-ui-react-native/themes/business/src/components/shared';
|
|
15
18
|
import { useTheme } from 'styled-components';
|
|
16
|
-
import { OIconButton } from '../shared';
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const theme = useTheme();
|
|
20
|
+
const SearchStarPrinter = ({ navigation }: any) => {
|
|
21
21
|
let _manager: StarDeviceDiscoveryManager;
|
|
22
|
+
const theme = useTheme();
|
|
22
23
|
|
|
23
24
|
const [state, setState] = useState({
|
|
24
25
|
bluetoothIsEnabled: true,
|
|
@@ -26,7 +27,8 @@ export const SearchStarPrinter = ({ navigation }: any) => {
|
|
|
26
27
|
printers: [],
|
|
27
28
|
})
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
const _onPressDiscoveryButton = async () => {
|
|
31
|
+
|
|
30
32
|
setState({
|
|
31
33
|
...state,
|
|
32
34
|
printers: [],
|
|
@@ -35,7 +37,8 @@ export const SearchStarPrinter = ({ navigation }: any) => {
|
|
|
35
37
|
try {
|
|
36
38
|
await _manager?.stopDiscovery()
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
const interfaceTypes: Array<InterfaceType> = []
|
|
41
|
+
|
|
39
42
|
if (state.bluetoothIsEnabled) {
|
|
40
43
|
interfaceTypes.push(InterfaceType.Bluetooth);
|
|
41
44
|
}
|
|
@@ -61,6 +64,7 @@ export const SearchStarPrinter = ({ navigation }: any) => {
|
|
|
61
64
|
console.log(`Discovery finished.`);
|
|
62
65
|
};
|
|
63
66
|
|
|
67
|
+
|
|
64
68
|
await _manager.startDiscovery();
|
|
65
69
|
}
|
|
66
70
|
catch (error) {
|
|
@@ -68,7 +72,7 @@ export const SearchStarPrinter = ({ navigation }: any) => {
|
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
const handleArrowBack
|
|
75
|
+
const handleArrowBack = () => {
|
|
72
76
|
navigation?.canGoBack() && navigation.goBack();
|
|
73
77
|
};
|
|
74
78
|
|
|
@@ -81,10 +85,13 @@ export const SearchStarPrinter = ({ navigation }: any) => {
|
|
|
81
85
|
style={{ maxWidth: 40, justifyContent: 'flex-end' }}
|
|
82
86
|
onClick={() => handleArrowBack()}
|
|
83
87
|
/>
|
|
84
|
-
<
|
|
88
|
+
<Text>Interface</Text>
|
|
89
|
+
|
|
90
|
+
<View
|
|
91
|
+
style={{ width: 100, marginTop: 30 }}>
|
|
85
92
|
<Button
|
|
86
93
|
title="Discovery"
|
|
87
|
-
onPress={_onPressDiscoveryButton}
|
|
94
|
+
onPress={async () => await _onPressDiscoveryButton()}
|
|
88
95
|
/>
|
|
89
96
|
</View>
|
|
90
97
|
<FlatList
|
|
@@ -95,3 +102,5 @@ export const SearchStarPrinter = ({ navigation }: any) => {
|
|
|
95
102
|
</View>
|
|
96
103
|
);
|
|
97
104
|
};
|
|
105
|
+
|
|
106
|
+
export default SearchStarPrinter;
|
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
import 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';
|
|
1
|
+
import React from 'react';
|
|
9
2
|
import {
|
|
10
3
|
View,
|
|
11
4
|
Text,
|
|
12
5
|
Button,
|
|
13
6
|
TextInput,
|
|
7
|
+
PermissionsAndroid,
|
|
8
|
+
Platform
|
|
14
9
|
} from 'react-native';
|
|
15
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';
|
|
16
21
|
|
|
17
|
-
export const HandleStarPrinter = ({ navigation }: any) => {
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
const HandleStarPrinter = ({ navigation }) => {
|
|
24
|
+
|
|
25
|
+
const [state, setState] = React.useState({
|
|
20
26
|
interfaceType: InterfaceType.Bluetooth,
|
|
21
|
-
identifier: '',
|
|
27
|
+
identifier: '00:11:62:00:00:00',
|
|
22
28
|
imageBase64: ''
|
|
23
29
|
});
|
|
24
30
|
|
|
25
31
|
const _onPressPrintButton = async () => {
|
|
32
|
+
var settings = new StarConnectionSettings();
|
|
33
|
+
settings.interfaceType = state.interfaceType;
|
|
34
|
+
settings.identifier = state.identifier;
|
|
26
35
|
|
|
27
|
-
let settings = new StarConnectionSettings();
|
|
28
|
-
settings.interfaceType = printState.interfaceType;
|
|
29
|
-
settings.identifier = printState.identifier;
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
var printer = new StarPrinter(settings);
|
|
32
38
|
|
|
33
39
|
try {
|
|
34
|
-
|
|
40
|
+
var builder = new StarXpandCommand.StarXpandCommandBuilder();
|
|
35
41
|
builder.addDocument(new StarXpandCommand.DocumentBuilder()
|
|
36
42
|
.addPrinter(new StarXpandCommand.PrinterBuilder()
|
|
37
43
|
.actionPrintImage(new StarXpandCommand.Printer.ImageParameter("logo_01.png", 406))
|
|
@@ -95,7 +101,7 @@ export const HandleStarPrinter = ({ navigation }: any) => {
|
|
|
95
101
|
)
|
|
96
102
|
);
|
|
97
103
|
|
|
98
|
-
|
|
104
|
+
var commands = await builder.getCommands();
|
|
99
105
|
|
|
100
106
|
await printer.open();
|
|
101
107
|
await printer.print(commands);
|
|
@@ -111,6 +117,7 @@ export const HandleStarPrinter = ({ navigation }: any) => {
|
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
|
|
120
|
+
|
|
114
121
|
const onSearchPrint = () => {
|
|
115
122
|
navigation.navigate('SearchStarPrinter')
|
|
116
123
|
}
|
|
@@ -121,20 +128,21 @@ export const HandleStarPrinter = ({ navigation }: any) => {
|
|
|
121
128
|
<Text style={{ width: 100 }}>Interface</Text>
|
|
122
129
|
<Picker
|
|
123
130
|
style={{ width: 200, marginLeft: 20, justifyContent: 'center' }}
|
|
124
|
-
selectedValue={
|
|
131
|
+
selectedValue={state.interfaceType}
|
|
125
132
|
onValueChange={(value) => {
|
|
126
|
-
|
|
133
|
+
setState({ ...state, interfaceType: value });
|
|
127
134
|
}}>
|
|
128
135
|
<Picker.Item label='Bluetooth' value={InterfaceType.Bluetooth} />
|
|
136
|
+
<Picker.Item label='Bluetooth LE' value={InterfaceType.BluetoothLE} />
|
|
129
137
|
</Picker>
|
|
130
138
|
</View>
|
|
131
139
|
<View style={{ flexDirection: 'row', marginTop: 30 }}>
|
|
132
140
|
<Text style={{ width: 100 }}>Identifier</Text>
|
|
133
141
|
<TextInput
|
|
134
142
|
style={{ width: 200, marginLeft: 20 }}
|
|
135
|
-
value={
|
|
143
|
+
value={state.identifier}
|
|
136
144
|
onChangeText={(value) => {
|
|
137
|
-
|
|
145
|
+
setState({ ...state, identifier: value });
|
|
138
146
|
}}
|
|
139
147
|
/>
|
|
140
148
|
</View>
|
|
@@ -147,10 +155,11 @@ export const HandleStarPrinter = ({ navigation }: any) => {
|
|
|
147
155
|
<View style={{ width: 100, marginTop: 20 }}>
|
|
148
156
|
<Button
|
|
149
157
|
title="Print"
|
|
150
|
-
onPress={_onPressPrintButton}
|
|
158
|
+
onPress={async () => await _onPressPrintButton()}
|
|
151
159
|
/>
|
|
152
160
|
</View>
|
|
153
161
|
</View>
|
|
154
162
|
);
|
|
155
163
|
};
|
|
156
164
|
|
|
165
|
+
export default HandleStarPrinter;
|