Updated to latest code
This commit is contained in:
30
LICENSE
30
LICENSE
@@ -1,15 +1,15 @@
|
|||||||
The Apache License v2.0
|
The Apache License v2.0
|
||||||
|
|
||||||
Copyright 2020 Incentro Business Acceleration B.V.
|
Copyright 2020 Incentro Business Acceleration B.V.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|||||||
50
README.md
50
README.md
@@ -1,25 +1,25 @@
|
|||||||
## BarcodeScanTorch
|
## BarcodeScanTorch
|
||||||
Mendix Native Barcode scanner with torch functionality
|
Mendix Native Barcode scanner with torch functionality
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
For development:
|
For development:
|
||||||
- Create customwidgets folder in root of project directory
|
- Create customwidgets folder in root of project directory
|
||||||
- Git clone this repo into customwidgets folder
|
- Git clone this repo into customwidgets folder
|
||||||
- Open command prompt in cloned folder
|
- Open command prompt in cloned folder
|
||||||
- npm i
|
- npm i
|
||||||
- npm i react-native-camera
|
- npm i react-native-camera
|
||||||
- npm run dev / npm run build
|
- npm run dev / npm run build
|
||||||
|
|
||||||
Widget can now be used inside Mendix.
|
Widget can now be used inside Mendix.
|
||||||
|
|
||||||
For plain usage:
|
For plain usage:
|
||||||
- Copy MPK file in releases to widgets directory.
|
- Copy MPK file in releases to widgets directory.
|
||||||
|
|
||||||
## Demo project
|
## Demo project
|
||||||
Not available yet.
|
Not available yet.
|
||||||
|
|
||||||
## Issues, suggestions and feature requests
|
## Issues, suggestions and feature requests
|
||||||
https://github.com/IncentroBA/barcodescantorch/issues
|
https://github.com/IncentroBA/barcodescantorch/issues
|
||||||
|
|
||||||
## Development and contribution
|
## Development and contribution
|
||||||
- Based on https://github.com/mendix/native-mobile-resources
|
- Based on https://github.com/mendix/native-mobile-resources
|
||||||
|
|||||||
BIN
dist/1.0.0/incentro.BarcodeScanTorch.mpk
vendored
BIN
dist/1.0.0/incentro.BarcodeScanTorch.mpk
vendored
Binary file not shown.
56
dist/tmp/widgets/BarcodeScanTorch.xml
vendored
56
dist/tmp/widgets/BarcodeScanTorch.xml
vendored
@@ -1,28 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<widget id="incentro.barcodescantorch.BarcodeScanTorch" supportedPlatform="Native" needsEntityContext="true" offlineCapable="true" pluginWidget="true" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
|
<widget id="incentro.barcodescantorch.BarcodeScanTorch" supportedPlatform="Native" needsEntityContext="true" offlineCapable="true" pluginWidget="true" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
|
||||||
<name>Barcode scanner w/Torch</name>
|
<name>Barcode scanner w/Torch</name>
|
||||||
<description>Scan barcode and QR code values with added torch functionality.</description>
|
<description>Scan barcode and QR code values with added torch functionality.</description>
|
||||||
<icon>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAElBMVEUAAABXV1dVVVVJsPhIsPdVVVWcEer3AAAABHRSTlMASeP9eof+WwAAAHJJREFUeAHtlzEKxTAMQ239r/tfuaHtFEpxIkog6C1e7AchixQXJsET5OQ2eIMo8LDNOQE7wegTOkEMspsAJGKE/iaBjDrlG7OAf6M89xdYYIEFBb4XtPF7n/sL1v2CWYoespSY56ysFw698uilS6995gADwwwpR7MpFwAAAABJRU5ErkJggg==</icon>
|
<icon>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAElBMVEUAAABXV1dVVVVJsPhIsPdVVVWcEer3AAAABHRSTlMASeP9eof+WwAAAHJJREFUeAHtlzEKxTAMQ239r/tfuaHtFEpxIkog6C1e7AchixQXJsET5OQ2eIMo8LDNOQE7wegTOkEMspsAJGKE/iaBjDrlG7OAf6M89xdYYIEFBb4XtPF7n/sL1v2CWYoespSY56ysFw698uilS6995gADwwwpR7MpFwAAAABJRU5ErkJggg==</icon>
|
||||||
<properties>
|
<properties>
|
||||||
<propertyGroup caption="General">
|
<propertyGroup caption="General">
|
||||||
<propertyGroup caption="Data source">
|
<propertyGroup caption="Data source">
|
||||||
<property key="barcode" type="attribute">
|
<property key="barcode" type="attribute">
|
||||||
<caption>Barcode</caption>
|
<caption>Barcode</caption>
|
||||||
<description>The attribute that will receive the scanned barcode value.</description>
|
<description>The attribute that will receive the scanned barcode value.</description>
|
||||||
<attributeTypes>
|
<attributeTypes>
|
||||||
<attributeType name="String"/>
|
<attributeType name="String"/>
|
||||||
</attributeTypes>
|
</attributeTypes>
|
||||||
</property>
|
</property>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
<propertyGroup caption="Events">
|
<propertyGroup caption="Events">
|
||||||
<property key="onDetect" type="action" required="false">
|
<property key="onDetect" type="action" required="false">
|
||||||
<caption>On detect</caption>
|
<caption>On detect</caption>
|
||||||
<description/>
|
<description/>
|
||||||
</property>
|
</property>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
<propertyGroup caption="Common">
|
<propertyGroup caption="Common">
|
||||||
<systemProperty key="Name"/>
|
<systemProperty key="Name"/>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -332,10 +332,10 @@ class BarcodeScanTorch extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|||||||
return (Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["View"], { style: this.styles.container },
|
return (Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["View"], { style: this.styles.container },
|
||||||
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native_camera__WEBPACK_IMPORTED_MODULE_2__["RNCamera"], { style: this.styles.preview, captureAudio: false, onBarCodeRead: this.onBarCodeReadHandler, flashMode: this.state.torchON ? react_native_camera__WEBPACK_IMPORTED_MODULE_2__["RNCamera"].Constants.FlashMode.torch : react_native_camera__WEBPACK_IMPORTED_MODULE_2__["RNCamera"].Constants.FlashMode.off }),
|
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native_camera__WEBPACK_IMPORTED_MODULE_2__["RNCamera"], { style: this.styles.preview, captureAudio: false, onBarCodeRead: this.onBarCodeReadHandler, flashMode: this.state.torchON ? react_native_camera__WEBPACK_IMPORTED_MODULE_2__["RNCamera"].Constants.FlashMode.torch : react_native_camera__WEBPACK_IMPORTED_MODULE_2__["RNCamera"].Constants.FlashMode.off }),
|
||||||
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["View"], { style: this.styles.bottom },
|
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["View"], { style: this.styles.bottom },
|
||||||
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["TouchableOpacity"], { onPress: this.toggleTorch, style: this.state.torchON ? this.styles.switchOn : this.styles.switchOff },
|
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["TouchableOpacity"], { onPress: this.toggleTorch, style: this.state.torchON ? this.styles.switchOff : this.styles.switchOn },
|
||||||
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["Text"], { style: this.state.torchON ? this.styles.textOn : this.styles.textOff },
|
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["Text"], { style: this.state.torchON ? this.styles.textOff : this.styles.textOn },
|
||||||
"\u21AF Lamp ",
|
"\u21AF Lamp ",
|
||||||
this.state.torchON ? "aan" : "uit")),
|
this.state.torchON ? "uit" : "aan")),
|
||||||
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["TouchableOpacity"], { onPress: this.toggleAutoDetect, style: this.state.autoDetect ? this.styles.switchOn : this.styles.switchOff },
|
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["TouchableOpacity"], { onPress: this.toggleAutoDetect, style: this.state.autoDetect ? this.styles.switchOn : this.styles.switchOff },
|
||||||
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["Text"], { style: this.state.autoDetect ? this.styles.textOn : this.styles.textOff },
|
Object(react__WEBPACK_IMPORTED_MODULE_0__["createElement"])(react_native__WEBPACK_IMPORTED_MODULE_1__["Text"], { style: this.state.autoDetect ? this.styles.textOn : this.styles.textOff },
|
||||||
"\u2551\u2588\u2551 Detectie ",
|
"\u2551\u2588\u2551 Detectie ",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
22
dist/tmp/widgets/package.xml
vendored
22
dist/tmp/widgets/package.xml
vendored
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<package xmlns="http://www.mendix.com/package/1.0/">
|
<package xmlns="http://www.mendix.com/package/1.0/">
|
||||||
<clientModule name="BarcodeScanTorch" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
|
<clientModule name="BarcodeScanTorch" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
|
||||||
<widgetFiles>
|
<widgetFiles>
|
||||||
<widgetFile path="BarcodeScanTorch.xml"/>
|
<widgetFile path="BarcodeScanTorch.xml"/>
|
||||||
</widgetFiles>
|
</widgetFiles>
|
||||||
<files>
|
<files>
|
||||||
<file path="incentro/barcodescantorch"/>
|
<file path="incentro/barcodescantorch"/>
|
||||||
</files>
|
</files>
|
||||||
</clientModule>
|
</clientModule>
|
||||||
</package>
|
</package>
|
||||||
|
|||||||
41112
package-lock.json
generated
41112
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
66
package.json
66
package.json
@@ -1,33 +1,33 @@
|
|||||||
{
|
{
|
||||||
"name": "barcodescantorch",
|
"name": "barcodescantorch",
|
||||||
"widgetName": "BarcodeScanTorch",
|
"widgetName": "BarcodeScanTorch",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Barcode scanner with torch functionality",
|
"description": "Barcode scanner with torch functionality",
|
||||||
"copyright": "2020 Incentro Business Acceleration B.V.",
|
"copyright": "2020 Incentro Business Acceleration B.V.",
|
||||||
"author": "Bart Onstee",
|
"author": "Bart Onstee",
|
||||||
"config": {
|
"config": {
|
||||||
"projectPath": "../..//"
|
"projectPath": "../..//"
|
||||||
},
|
},
|
||||||
"packagePath": "incentro",
|
"packagePath": "incentro",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run dev",
|
"start": "npm run dev",
|
||||||
"build": "pluggable-widgets-tools build:native",
|
"build": "pluggable-widgets-tools build:native",
|
||||||
"dev": "pluggable-widgets-tools start:native",
|
"dev": "pluggable-widgets-tools start:native",
|
||||||
"lint": "pluggable-widgets-tools lint",
|
"lint": "pluggable-widgets-tools lint",
|
||||||
"lint:fix": "pluggable-widgets-tools lint:fix",
|
"lint:fix": "pluggable-widgets-tools lint:fix",
|
||||||
"prerelease": "npm run lint",
|
"prerelease": "npm run lint",
|
||||||
"release": "pluggable-widgets-tools release:native"
|
"release": "pluggable-widgets-tools release:native"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/Bart Onstee/barcodescantorch/issues"
|
"url": "https://github.com/Bart Onstee/barcodescantorch/issues"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mendix/pluggable-widgets-tools": "^8.12.0",
|
"@mendix/pluggable-widgets-tools": "^8.12.0",
|
||||||
"@types/big.js": "^4.0.5",
|
"@types/big.js": "^4.0.5",
|
||||||
"@types/react": "~16.9.0",
|
"@types/react": "~16.9.0",
|
||||||
"@types/react-native": "~0.61.23",
|
"@types/react-native": "~0.61.23",
|
||||||
"react-native-camera": "^3.40.0"
|
"react-native-camera": "^3.40.0"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const base = require("@mendix/pluggable-widgets-tools/configs/prettier.base.json");
|
const base = require("@mendix/pluggable-widgets-tools/configs/prettier.base.json");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...base
|
...base
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,183 +1,184 @@
|
|||||||
import { Component, createElement } from "react";
|
import { Component, createElement } from "react";
|
||||||
import { View, TouchableOpacity, Text, TextInput, Vibration, ViewStyle, TextStyle } from "react-native";
|
import { View, TouchableOpacity, Text, TextInput, Vibration, ViewStyle, TextStyle } from "react-native";
|
||||||
import { RNCamera } from "react-native-camera";
|
import { RNCamera } from "react-native-camera";
|
||||||
import { ValueStatus } from "mendix";
|
import { ValueStatus } from "mendix";
|
||||||
import { Style, mergeNativeStyles } from '@mendix/pluggable-widgets-tools';
|
import { Style, mergeNativeStyles } from '@mendix/pluggable-widgets-tools';
|
||||||
|
import { } from 'mendix';
|
||||||
export interface BarcodeScanTorchStyle extends Style {
|
|
||||||
container: ViewStyle;
|
export interface BarcodeScanTorchStyle extends Style {
|
||||||
preview: ViewStyle;
|
container: ViewStyle;
|
||||||
bottom: ViewStyle;
|
preview: ViewStyle;
|
||||||
textBox: ViewStyle;
|
bottom: ViewStyle;
|
||||||
textInput: TextStyle;
|
textBox: ViewStyle;
|
||||||
switchOn: ViewStyle;
|
textInput: TextStyle;
|
||||||
switchOff: ViewStyle;
|
switchOn: ViewStyle;
|
||||||
textOn: TextStyle;
|
switchOff: ViewStyle;
|
||||||
textOff: TextStyle;
|
textOn: TextStyle;
|
||||||
textBarcode: TextStyle;
|
textOff: TextStyle;
|
||||||
|
textBarcode: TextStyle;
|
||||||
};
|
|
||||||
|
};
|
||||||
const defaultStyle: BarcodeScanTorchStyle = {
|
|
||||||
container: {
|
const defaultStyle: BarcodeScanTorchStyle = {
|
||||||
flex: 1,
|
container: {
|
||||||
backgroundColor: 'black'
|
flex: 1,
|
||||||
},
|
backgroundColor: 'black'
|
||||||
preview: {
|
},
|
||||||
flex: 1,
|
preview: {
|
||||||
alignItems: 'center',
|
flex: 1,
|
||||||
},
|
alignItems: 'center',
|
||||||
bottom: {
|
},
|
||||||
justifyContent: 'flex-end',
|
bottom: {
|
||||||
backgroundColor: 'white',
|
justifyContent: 'flex-end',
|
||||||
alignItems: 'center',
|
backgroundColor: 'white',
|
||||||
},
|
alignItems: 'center',
|
||||||
textBox: {
|
},
|
||||||
backgroundColor: 'white',
|
textBox: {
|
||||||
alignItems: 'center',
|
backgroundColor: 'white',
|
||||||
},
|
alignItems: 'center',
|
||||||
textInput: {
|
},
|
||||||
height: 45,
|
textInput: {
|
||||||
margin: 5,
|
height: 45,
|
||||||
width: 300,
|
margin: 5,
|
||||||
borderBottomWidth: 1,
|
width: 300,
|
||||||
borderBottomColor: '#de712b',
|
borderBottomWidth: 1,
|
||||||
},
|
borderBottomColor: '#de712b',
|
||||||
switchOn: {
|
},
|
||||||
height: 45,
|
switchOn: {
|
||||||
margin: 5,
|
height: 45,
|
||||||
borderRadius: 30,
|
margin: 5,
|
||||||
backgroundColor: '#de712b',
|
borderRadius: 30,
|
||||||
alignItems: 'center',
|
backgroundColor: '#de712b',
|
||||||
justifyContent: 'center',
|
alignItems: 'center',
|
||||||
width: '85%',
|
justifyContent: 'center',
|
||||||
},
|
width: '85%',
|
||||||
switchOff: {
|
},
|
||||||
height: 45,
|
switchOff: {
|
||||||
margin: 5,
|
height: 45,
|
||||||
borderRadius: 30,
|
margin: 5,
|
||||||
backgroundColor: 'white',
|
borderRadius: 30,
|
||||||
borderWidth: 1,
|
backgroundColor: 'white',
|
||||||
borderColor: '#de712b',
|
borderWidth: 1,
|
||||||
alignItems: 'center',
|
borderColor: '#de712b',
|
||||||
justifyContent: 'center',
|
alignItems: 'center',
|
||||||
width: '85%',
|
justifyContent: 'center',
|
||||||
},
|
width: '85%',
|
||||||
textOn: {
|
},
|
||||||
color: 'white',
|
textOn: {
|
||||||
fontSize: 16,
|
color: 'white',
|
||||||
margin: 50,
|
fontSize: 16,
|
||||||
fontWeight: 'bold',
|
margin: 50,
|
||||||
},
|
fontWeight: 'bold',
|
||||||
textOff: {
|
},
|
||||||
color: '#de712b',
|
textOff: {
|
||||||
fontSize: 16,
|
color: '#de712b',
|
||||||
margin: 50,
|
fontSize: 16,
|
||||||
fontWeight: 'bold',
|
margin: 50,
|
||||||
},
|
fontWeight: 'bold',
|
||||||
textBarcode: {
|
},
|
||||||
color: '#de712b',
|
textBarcode: {
|
||||||
fontSize: 16,
|
color: '#de712b',
|
||||||
fontWeight: 'bold',
|
fontSize: 16,
|
||||||
}
|
fontWeight: 'bold',
|
||||||
};
|
}
|
||||||
|
};
|
||||||
import { BarcodeScanTorchProps } from "../typings/BarcodeScanTorchProps";
|
|
||||||
|
import { BarcodeScanTorchProps } from "../typings/BarcodeScanTorchProps";
|
||||||
export type Props = BarcodeScanTorchProps<BarcodeScanTorchStyle>;
|
|
||||||
|
export type Props = BarcodeScanTorchProps<BarcodeScanTorchStyle>;
|
||||||
interface State {
|
|
||||||
torchON?: boolean;
|
interface State {
|
||||||
autoDetect?: boolean;
|
torchON?: boolean;
|
||||||
textboxValue?: string;
|
autoDetect?: boolean;
|
||||||
}
|
textboxValue?: string;
|
||||||
|
}
|
||||||
export class BarcodeScanTorch extends Component<Props, State> {
|
|
||||||
onBarCodeReadHandler = this.onBarCodeRead.bind(this);
|
export class BarcodeScanTorch extends Component<Props, State> {
|
||||||
manualBarcodeHandler = this.manualBarcode.bind(this);
|
onBarCodeReadHandler = this.onBarCodeRead.bind(this);
|
||||||
constructor(props: Props){
|
manualBarcodeHandler = this.manualBarcode.bind(this);
|
||||||
super(props)
|
constructor(props: Props){
|
||||||
this.toggleTorch = this.toggleTorch.bind(this)
|
super(props)
|
||||||
this.toggleAutoDetect = this.toggleAutoDetect.bind(this)
|
this.toggleTorch = this.toggleTorch.bind(this)
|
||||||
this.state = {
|
this.toggleAutoDetect = this.toggleAutoDetect.bind(this)
|
||||||
torchON: false,
|
this.state = {
|
||||||
autoDetect: true,
|
torchON: false,
|
||||||
textboxValue: '',
|
autoDetect: true,
|
||||||
}
|
textboxValue: '',
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private readonly styles = mergeNativeStyles(defaultStyle, this.props.style);
|
|
||||||
|
private readonly styles = mergeNativeStyles(defaultStyle, this.props.style);
|
||||||
toggleTorch(){
|
|
||||||
this.setState({torchON: !this.state.torchON})
|
toggleTorch(){
|
||||||
}
|
this.setState({torchON: !this.state.torchON})
|
||||||
|
}
|
||||||
toggleAutoDetect(){
|
|
||||||
this.setState({autoDetect: !this.state.autoDetect})
|
toggleAutoDetect(){
|
||||||
}
|
this.setState({autoDetect: !this.state.autoDetect})
|
||||||
|
}
|
||||||
render(){
|
|
||||||
return (
|
render(){
|
||||||
<View style={this.styles.container}>
|
return (
|
||||||
<RNCamera
|
<View style={this.styles.container}>
|
||||||
style={this.styles.preview}
|
<RNCamera
|
||||||
captureAudio={false}
|
style={this.styles.preview}
|
||||||
onBarCodeRead={this.onBarCodeReadHandler}
|
captureAudio={false}
|
||||||
flashMode={this.state.torchON ? RNCamera.Constants.FlashMode.torch: RNCamera.Constants.FlashMode.off}
|
onBarCodeRead={this.onBarCodeReadHandler}
|
||||||
/>
|
flashMode={this.state.torchON ? RNCamera.Constants.FlashMode.torch: RNCamera.Constants.FlashMode.off}
|
||||||
<View style={this.styles.bottom}>
|
/>
|
||||||
<TouchableOpacity onPress={this.toggleTorch} style={this.state.torchON ? this.styles.switchOn : this.styles.switchOff}>
|
<View style={this.styles.bottom}>
|
||||||
<Text style={this.state.torchON ? this.styles.textOn : this.styles.textOff}>↯ Lamp {this.state.torchON ? "aan" : "uit"}</Text>
|
<TouchableOpacity onPress={this.toggleTorch} style={this.state.torchON ? this.styles.switchOff : this.styles.switchOn}>
|
||||||
</TouchableOpacity>
|
<Text style={this.state.torchON ? this.styles.textOff : this.styles.textOn}>↯ Lamp {this.state.torchON ? "uit" : "aan"}</Text>
|
||||||
<TouchableOpacity onPress={this.toggleAutoDetect} style={this.state.autoDetect ? this.styles.switchOn : this.styles.switchOff}>
|
</TouchableOpacity>
|
||||||
<Text style={this.state.autoDetect ? this.styles.textOn : this.styles.textOff}>║█║ Detectie {this.state.autoDetect ? "aan" : "uit"}</Text>
|
<TouchableOpacity onPress={this.toggleAutoDetect} style={this.state.autoDetect ? this.styles.switchOn : this.styles.switchOff}>
|
||||||
</TouchableOpacity>
|
<Text style={this.state.autoDetect ? this.styles.textOn : this.styles.textOff}>║█║ Detectie {this.state.autoDetect ? "aan" : "uit"}</Text>
|
||||||
{this.state.autoDetect ? <View></View> :
|
</TouchableOpacity>
|
||||||
<View style={this.styles.textBox}>
|
{this.state.autoDetect ? <View></View> :
|
||||||
<Text style={this.styles.textBarcode}>Barcode: </Text>
|
<View style={this.styles.textBox}>
|
||||||
<TextInput style={this.styles.textInput} placeholder="Scan of vul handmatig" value={this.state.textboxValue} onChangeText={(text) => this.setState({textboxValue: text})}/>
|
<Text style={this.styles.textBarcode}>Barcode: </Text>
|
||||||
<TouchableOpacity onPress={this.manualBarcodeHandler} style={this.styles.switchOn}>
|
<TextInput style={this.styles.textInput} placeholder="Scan of vul handmatig" value={this.state.textboxValue} onChangeText={(text) => this.setState({textboxValue: text})}/>
|
||||||
<Text style={this.styles.textOn}>Naar machine</Text>
|
<TouchableOpacity onPress={this.manualBarcodeHandler} style={this.styles.switchOn}>
|
||||||
</TouchableOpacity>
|
<Text style={this.styles.textOn}>Naar machine</Text>
|
||||||
</View>
|
</TouchableOpacity>
|
||||||
}
|
</View>
|
||||||
</View>
|
}
|
||||||
</View>
|
</View>
|
||||||
);
|
</View>
|
||||||
}
|
);
|
||||||
// Internal button for testing
|
}
|
||||||
//<View style={this.styles.bottom}>
|
// Internal button for testing
|
||||||
//<TouchableOpacity onPress={this.toggleTorch} style={this.styles.switch}>
|
//<View style={this.styles.bottom}>
|
||||||
//<Text style={{ color: 'white', fontSize: 16 }}>Zaklamp {this.state.torchON ? "uit" : "aan"}</Text>
|
//<TouchableOpacity onPress={this.toggleTorch} style={this.styles.switch}>
|
||||||
//</TouchableOpacity>
|
//<Text style={{ color: 'white', fontSize: 16 }}>Zaklamp {this.state.torchON ? "uit" : "aan"}</Text>
|
||||||
//</View>
|
//</TouchableOpacity>
|
||||||
//<Image style={this.styles.Image} source={this.state.torchOn ? flashon : flashoff} />
|
//</View>
|
||||||
|
//<Image style={this.styles.Image} source={this.state.torchOn ? flashon : flashoff} />
|
||||||
|
|
||||||
private onBarCodeRead(event: { data: string }): void {
|
|
||||||
if (this.state.autoDetect) {
|
private onBarCodeRead(event: { data: string }): void {
|
||||||
if (this.props.barcode.status !== ValueStatus.Available || event.data === this.props.barcode.value) {
|
if (this.state.autoDetect) {
|
||||||
return;
|
if (this.props.barcode.status !== ValueStatus.Available || event.data === this.props.barcode.value) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
this.props.barcode.setValue(event.data);
|
|
||||||
|
this.props.barcode.setValue(event.data);
|
||||||
if (this.props.onDetect && this.props.onDetect.canExecute) {
|
|
||||||
Vibration.vibrate(400);
|
if (this.props.onDetect && this.props.onDetect.canExecute) {
|
||||||
this.props.onDetect.execute();
|
Vibration.vibrate(400);
|
||||||
}
|
this.props.onDetect.execute();
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
if (this.state.textboxValue !== event.data) {
|
else {
|
||||||
Vibration.vibrate(400);
|
if (this.state.textboxValue !== event.data) {
|
||||||
this.setState({textboxValue: event.data})
|
Vibration.vibrate(400);
|
||||||
return;
|
this.setState({textboxValue: event.data})
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private manualBarcode() {
|
|
||||||
this.props.barcode.setValue(this.state.textboxValue);
|
private manualBarcode() {
|
||||||
this.props.onDetect?.execute();
|
this.props.barcode.setValue(this.state.textboxValue);
|
||||||
}
|
this.props.onDetect?.execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<widget id="incentro.barcodescantorch.BarcodeScanTorch" supportedPlatform="Native" needsEntityContext="true" offlineCapable="true" pluginWidget="true" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
|
<widget id="incentro.barcodescantorch.BarcodeScanTorch" supportedPlatform="Native" needsEntityContext="true" offlineCapable="true" pluginWidget="true" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
|
||||||
<name>Barcode scanner w/Torch</name>
|
<name>Barcode scanner w/Torch</name>
|
||||||
<description>Scan barcode and QR code values with added torch functionality.</description>
|
<description>Scan barcode and QR code values with added torch functionality.</description>
|
||||||
<icon>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAElBMVEUAAABXV1dVVVVJsPhIsPdVVVWcEer3AAAABHRSTlMASeP9eof+WwAAAHJJREFUeAHtlzEKxTAMQ239r/tfuaHtFEpxIkog6C1e7AchixQXJsET5OQ2eIMo8LDNOQE7wegTOkEMspsAJGKE/iaBjDrlG7OAf6M89xdYYIEFBb4XtPF7n/sL1v2CWYoespSY56ysFw698uilS6995gADwwwpR7MpFwAAAABJRU5ErkJggg==</icon>
|
<icon>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAElBMVEUAAABXV1dVVVVJsPhIsPdVVVWcEer3AAAABHRSTlMASeP9eof+WwAAAHJJREFUeAHtlzEKxTAMQ239r/tfuaHtFEpxIkog6C1e7AchixQXJsET5OQ2eIMo8LDNOQE7wegTOkEMspsAJGKE/iaBjDrlG7OAf6M89xdYYIEFBb4XtPF7n/sL1v2CWYoespSY56ysFw698uilS6995gADwwwpR7MpFwAAAABJRU5ErkJggg==</icon>
|
||||||
<properties>
|
<properties>
|
||||||
<propertyGroup caption="General">
|
<propertyGroup caption="General">
|
||||||
<propertyGroup caption="Data source">
|
<propertyGroup caption="Data source">
|
||||||
<property key="barcode" type="attribute">
|
<property key="barcode" type="attribute">
|
||||||
<caption>Barcode</caption>
|
<caption>Barcode</caption>
|
||||||
<description>The attribute that will receive the scanned barcode value.</description>
|
<description>The attribute that will receive the scanned barcode value.</description>
|
||||||
<attributeTypes>
|
<attributeTypes>
|
||||||
<attributeType name="String"/>
|
<attributeType name="String"/>
|
||||||
</attributeTypes>
|
</attributeTypes>
|
||||||
</property>
|
</property>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
<propertyGroup caption="Events">
|
<propertyGroup caption="Events">
|
||||||
<property key="onDetect" type="action" required="false">
|
<property key="onDetect" type="action" required="false">
|
||||||
<caption>On detect</caption>
|
<caption>On detect</caption>
|
||||||
<description/>
|
<description/>
|
||||||
</property>
|
</property>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
<propertyGroup caption="Common">
|
<propertyGroup caption="Common">
|
||||||
<systemProperty key="Name"/>
|
<systemProperty key="Name"/>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
</propertyGroup>
|
</propertyGroup>
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<package xmlns="http://www.mendix.com/package/1.0/">
|
<package xmlns="http://www.mendix.com/package/1.0/">
|
||||||
<clientModule name="BarcodeScanTorch" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
|
<clientModule name="BarcodeScanTorch" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
|
||||||
<widgetFiles>
|
<widgetFiles>
|
||||||
<widgetFile path="BarcodeScanTorch.xml"/>
|
<widgetFile path="BarcodeScanTorch.xml"/>
|
||||||
</widgetFiles>
|
</widgetFiles>
|
||||||
<files>
|
<files>
|
||||||
<file path="incentro/barcodescantorch"/>
|
<file path="incentro/barcodescantorch"/>
|
||||||
</files>
|
</files>
|
||||||
</clientModule>
|
</clientModule>
|
||||||
</package>
|
</package>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"extends": "./node_modules/@mendix/pluggable-widgets-tools/configs/tsconfig.base.json"
|
"extends": "./node_modules/@mendix/pluggable-widgets-tools/configs/tsconfig.base.json"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user