ordering-ui-react-native 0.21.42-test → 0.21.44-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.42-test",
3
+ "version": "0.21.44-test",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -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 { HandleStarPrinter } from './src/components/StarPrinter';
46
- import { SearchStarPrinter } from './src/components/StarPrinter/SearchPrinter';
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,23 +4,22 @@ import {
4
4
  Text,
5
5
  Button,
6
6
  FlatList,
7
+ PermissionsAndroid,
8
+ Platform
7
9
  } from 'react-native';
8
10
 
9
- import CheckBox from '@react-native-community/checkbox';
10
-
11
11
  import {
12
12
  InterfaceType,
13
13
  StarDeviceDiscoveryManager,
14
14
  StarDeviceDiscoveryManagerFactory,
15
15
  StarPrinter
16
16
  } from 'react-native-star-io10';
17
+ import { OIconButton } from 'ordering-ui-react-native/themes/business/src/components/shared';
17
18
  import { useTheme } from 'styled-components';
18
- import { OIconButton } from '../shared';
19
-
20
- export const SearchStarPrinter = ({ navigation }: any) => {
21
19
 
22
- const theme = useTheme();
20
+ const SearchStarPrinter = ({ navigation }: any) => {
23
21
  let _manager: StarDeviceDiscoveryManager;
22
+ const theme = useTheme();
24
23
 
25
24
  const [state, setState] = useState({
26
25
  bluetoothIsEnabled: true,
@@ -28,7 +27,8 @@ export const SearchStarPrinter = ({ navigation }: any) => {
28
27
  printers: [],
29
28
  })
30
29
 
31
- let _onPressDiscoveryButton = async () => {
30
+ const _onPressDiscoveryButton = async () => {
31
+
32
32
  setState({
33
33
  ...state,
34
34
  printers: [],
@@ -37,7 +37,8 @@ export const SearchStarPrinter = ({ navigation }: any) => {
37
37
  try {
38
38
  await _manager?.stopDiscovery()
39
39
 
40
- let interfaceTypes: Array<InterfaceType> = []
40
+ const interfaceTypes: Array<InterfaceType> = []
41
+
41
42
  if (state.bluetoothIsEnabled) {
42
43
  interfaceTypes.push(InterfaceType.Bluetooth);
43
44
  }
@@ -63,6 +64,7 @@ export const SearchStarPrinter = ({ navigation }: any) => {
63
64
  console.log(`Discovery finished.`);
64
65
  };
65
66
 
67
+
66
68
  await _manager.startDiscovery();
67
69
  }
68
70
  catch (error) {
@@ -70,7 +72,7 @@ export const SearchStarPrinter = ({ navigation }: any) => {
70
72
  }
71
73
  }
72
74
 
73
- const handleArrowBack: any = () => {
75
+ const handleArrowBack = () => {
74
76
  navigation?.canGoBack() && navigation.goBack();
75
77
  };
76
78
 
@@ -83,33 +85,13 @@ export const SearchStarPrinter = ({ navigation }: any) => {
83
85
  style={{ maxWidth: 40, justifyContent: 'flex-end' }}
84
86
  onClick={() => handleArrowBack()}
85
87
  />
88
+ <Text>Interface</Text>
89
+
86
90
  <View
87
91
  style={{ width: 100, marginTop: 30 }}>
88
- <Text style={{ marginLeft: 20 }}>Bluetooth</Text>
89
- </View>
90
-
91
- <View style={{ flexDirection: 'row' }}>
92
- <CheckBox
93
- style={{ marginLeft: 20 }}
94
- value={state.bluetoothLeIsEnabled}
95
- onValueChange={(newValue) => {
96
- setState({ bluetoothLeIsEnabled: newValue });
97
- }}
98
- />
99
- <Text style={{ marginLeft: 20 }}>Bluetooth LE</Text>
100
- </View>
101
-
102
- <View style={{ flexDirection: 'row' }}>
103
- <CheckBox
104
- style={{ marginLeft: 20 }}
105
- value={state.usbIsEnabled}
106
- onValueChange={(newValue) => {
107
- setState({ usbIsEnabled: newValue });
108
- }}
109
- />
110
92
  <Button
111
93
  title="Discovery"
112
- onPress={_onPressDiscoveryButton}
94
+ onPress={async () => await _onPressDiscoveryButton()}
113
95
  />
114
96
  </View>
115
97
  <FlatList
@@ -120,3 +102,5 @@ export const SearchStarPrinter = ({ navigation }: any) => {
120
102
  </View>
121
103
  );
122
104
  };
105
+
106
+ export default SearchStarPrinter;
@@ -1,37 +1,43 @@
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';
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
- const [printState, setPrintState] = useState({
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
- let printer = new StarPrinter(settings);
37
+ var printer = new StarPrinter(settings);
32
38
 
33
39
  try {
34
- let builder = new StarXpandCommand.StarXpandCommandBuilder();
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
- let commands = await builder.getCommands();
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={printState.interfaceType}
131
+ selectedValue={state.interfaceType}
125
132
  onValueChange={(value) => {
126
- setPrintState({ interfaceType: value });
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={printState.identifier}
143
+ value={state.identifier}
136
144
  onChangeText={(value) => {
137
- setPrintState({ identifier: value });
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;