UNPKG

2.03 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var helper_1 = require("../helper");
17var types_1 = require("../types");
18var types_2 = require("./types");
19/**
20 * A set of Actions for displaying a Camera or NFC Scanner component
21 * @public
22 */
23var Scanner = /** @class */ (function (_super) {
24 __extends(Scanner, _super);
25 function Scanner(app, options) {
26 return _super.call(this, app, types_1.Group.Scanner, types_1.Group.Scanner, options ? options.id : undefined) || this;
27 }
28 /**
29 * @public
30 */
31 Scanner.prototype.dispatch = function (action) {
32 switch (action) {
33 case types_2.Action.OPEN_CAMERA:
34 this.dispatchScannerAction(types_2.ActionType.OPEN_CAMERA);
35 break;
36 case types_2.Action.OPEN_NFC:
37 this.dispatchScannerAction(types_2.ActionType.OPEN_NFC);
38 break;
39 }
40 return this;
41 };
42 /**
43 * @internal
44 */
45 Scanner.prototype.dispatchScannerAction = function (type) {
46 this.app.dispatch(helper_1.actionWrapper({
47 type: type,
48 group: types_1.Group.Scanner,
49 payload: {
50 id: this.id,
51 },
52 }));
53 };
54 return Scanner;
55}(helper_1.ActionSet));
56exports.Scanner = Scanner;
57/**
58 * @public
59 */
60function create(app, options) {
61 return new Scanner(app, options);
62}
63exports.create = create;