Skip to content

Commit

Permalink
Merge pull request #41 from maslick/beep-toggle
Browse files Browse the repository at this point in the history
beep toggle button
  • Loading branch information
maslick authored Jan 12, 2022
2 parents 614328d + cd9681f commit bb701dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "koder-react",
"version": "1.4.0",
"version": "1.4.1",
"homepage": "./",
"private": true,
"devDependencies": {
Expand Down
17 changes: 14 additions & 3 deletions src/components/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class Scan extends React.Component {
worker: this.props.worker,
transformToggle: true,
rawCode: "",
codeType: CODE_TYPE.RAW
codeType: CODE_TYPE.RAW,
beep: this.props.beep
};

this.decodeQR = this.props.decode;
this.allowBeep = this.props.beep;
this.scanRate = this.props.scanRate;
this.upnqr = this.props.upnqr;
this.covid19 = this.props.covid19;
Expand Down Expand Up @@ -94,7 +94,7 @@ class Scan extends React.Component {
}

this.setState({barcode: res, resultOpen: true, rawCode, codeType});
if (this.allowBeep) beep();
if (this.state.beep) beep();
}
};
};
Expand Down Expand Up @@ -218,6 +218,11 @@ class Scan extends React.Component {
this.setState({bw: !this.state.bw});
};

onBeepClickHandler = (e) => {
e.preventDefault();
this.setState({beep: !this.state.beep});
};

startStyle = () => {
const style = {width: 64, textAlign: "center"};
if (this.state.scanning) return { backgroundColor: "red", ...style };
Expand All @@ -239,6 +244,11 @@ class Scan extends React.Component {
else return { backgroundColor: "" };
};

beepStyle = () => {
if (this.state.beep) return { backgroundColor: "green" };
else return { backgroundColor: "" };
};

transformToggleStyle = () => {
if (this.state.transformToggle) return { backgroundColor: "green", padding: 12 };
else return {backgroundColor: "", padding: 12};
Expand Down Expand Up @@ -314,6 +324,7 @@ class Scan extends React.Component {
<a href="!#" className="myHref" onClick={this.onCrossHairClickHandler} style={this.xHairStyle()}>X-hair</a>
<a href="!#" className="myHref" onClick={this.onFPSClickHandler} style={this.fpsStyle()}>FPS</a>
<a href="!#" className="myHref" onClick={this.onBWClickHandler} style={this.bwStyle()}>B/W</a>
<a href="!#" className="myHref" onClick={this.onBeepClickHandler} style={this.beepStyle()}>Beep</a>
</div>;
};

Expand Down

0 comments on commit bb701dc

Please sign in to comment.