ordering-ui-react-native 0.21.46-test → 0.21.47-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.46-test",
3
+ "version": "0.21.47-test",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -29,15 +29,15 @@ const HandleStarPrinter = ({ navigation }) => {
29
29
  });
30
30
 
31
31
  const _onPressPrintButton = async () => {
32
- var settings = new StarConnectionSettings();
32
+ const settings = new StarConnectionSettings();
33
33
  settings.interfaceType = state.interfaceType;
34
34
  settings.identifier = state.identifier;
35
35
 
36
36
 
37
- var printer = new StarPrinter(settings);
37
+ const printer = new StarPrinter(settings);
38
38
 
39
39
  try {
40
- var builder = new StarXpandCommand.StarXpandCommandBuilder();
40
+ const builder = new StarXpandCommand.StarXpandCommandBuilder();
41
41
  builder.addDocument(new StarXpandCommand.DocumentBuilder()
42
42
  .addPrinter(new StarXpandCommand.PrinterBuilder()
43
43
  .actionPrintImage(new StarXpandCommand.Printer.ImageParameter("logo_01.png", 406))
@@ -101,7 +101,7 @@ const HandleStarPrinter = ({ navigation }) => {
101
101
  )
102
102
  );
103
103
 
104
- var commands = await builder.getCommands();
104
+ const commands = await builder.getCommands();
105
105
 
106
106
  await printer.open();
107
107
  await printer.print(commands);
@@ -122,6 +122,64 @@ const HandleStarPrinter = ({ navigation }) => {
122
122
  navigation.navigate('SearchStarPrinter')
123
123
  }
124
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
+
125
183
  return (
126
184
  <View style={{ margin: 50 }}>
127
185
  <View style={{ flexDirection: 'row' }}>
@@ -152,6 +210,18 @@ const HandleStarPrinter = ({ navigation }) => {
152
210
  onPress={onSearchPrint}
153
211
  />
154
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>
155
225
  <View style={{ width: 100, marginTop: 20 }}>
156
226
  <Button
157
227
  title="Print"