diff --git a/package-lock.json b/package-lock.json index b2a6bf4..cb54175 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@metrological/sdk", - "version": "1.0.1", + "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@metrological/sdk", - "version": "1.0.1", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { "@babel/polyfill": "^7.11.5", diff --git a/src/LightningSdkPlugins/index.js b/src/LightningSdkPlugins/index.js index 2d91ce1..f15fb2d 100644 --- a/src/LightningSdkPlugins/index.js +++ b/src/LightningSdkPlugins/index.js @@ -38,5 +38,5 @@ export const initLightningSdkPlugin = { }, set appInstance(v) { ApplicationInstance = v - } + }, } diff --git a/src/Pin/dialog.js b/src/Pin/dialog.js index be4aeb2..00fed13 100644 --- a/src/Pin/dialog.js +++ b/src/Pin/dialog.js @@ -72,7 +72,6 @@ const PinInput = () => { } } } - } export default () => { @@ -87,7 +86,7 @@ export default () => { alpha: 0.000001, Dialog: { w: 648, - h: 320, + h: 360, y: h => (h - 320) / 2, x: w => (w - 648) / 2, rect: true, @@ -99,14 +98,43 @@ export default () => { text: { text: 'Please enter your PIN', fontSize: 32 }, }, Msg: { - y: 260, - x: 48, - text: { text: '', fontSize: 28, textColor: 0xffffffff }, + y: 300, + x: w => w / 2, + mount: 0.5, + text: { + text: '', + fontSize: 28, + textColor: 0xffffffff, + textAlign: 'center', + verticalAlign: 'middle', + }, }, Code: { x: 48, y: 96, }, + OkButton: { + w: 260, + h: 75, + y: 266, + x: w => w / 2, + mountX: 0.5, + rect: true, + color: 0xffffffff, + shader: { type: Lightning.shaders.RoundedRectangle, radius: 10 }, + Label: { + x: 130, + y: 40, + mount: 0.5, + text: { + text: 'OK', + textColor: 0xff333333, + fontSize: 40, + textAlign: 'center', + verticalAlign: 'middle', + }, + }, + }, }, } } @@ -152,13 +180,16 @@ export default () => { this.tag('Msg').text = this._msg this.tag('Info').setSmooth('alpha', 0.5) this.tag('Code').setSmooth('alpha', 0.5) + this.tag('OkButton').setSmooth('alpha', 0) } else { this.tag('Msg').text = '' this.tag('Info').setSmooth('alpha', 1) this.tag('Code').setSmooth('alpha', 1) + this.tag('OkButton').setSmooth('alpha', 1) } this._timeout = setTimeout(() => { this.msg = '' + this.tag('OkButton').setSmooth('alpha', 1) }, 2000) } @@ -166,18 +197,41 @@ export default () => { this.setSmooth('alpha', 1) } + _getDigit(event) { + const keyCodes = { + '48': 0, + '49': 1, + '50': 2, + '51': 3, + '52': 4, + '53': 5, + '54': 6, + '55': 7, + '56': 8, + '57': 9, + } + if (event && event.key) { + return parseInt(event.key) + } else { + let keyCode = event.which ? event.which : event.keyCode + return keyCodes[keyCode] || keyCodes[keyCode] === 0 ? keyCodes[keyCode] : -1 + } + } + _handleKey(event) { + const digit = this._getDigit(event) if (this.msg) { this.msg = false } else { - const val = parseInt(event.key) - if (val > -1) { - this.pin += val + if (digit > -1) { + this.pin += digit } } } - _handleBack() { + _handleBack(event) { + event.preventDefault() + event.stopPropagation() if (this.msg) { this.msg = false } else { @@ -204,6 +258,7 @@ export default () => { }) .catch(e => { this.msg = e + this.pin = '' this.reject(e) }) } diff --git a/src/Pin/index.js b/src/Pin/index.js index 5e3c6a9..417007b 100644 --- a/src/Pin/index.js +++ b/src/Pin/index.js @@ -30,6 +30,7 @@ let submit = (pin, context) => { unlocked = true resolve(unlocked) } else { + unlocked = false reject('Incorrect pin') } }) @@ -79,7 +80,9 @@ export default { }, hide() { ApplicationInstance.focus = null - ApplicationInstance.children = ApplicationInstance.children.map(child => child !== pinDialog && child) + ApplicationInstance.children = ApplicationInstance.children.map( + child => child !== pinDialog && child + ) pinDialog = null }, submit(pin, context) { diff --git a/src/VideoPlayer/index.js b/src/VideoPlayer/index.js index ee6a807..b357dbf 100644 --- a/src/VideoPlayer/index.js +++ b/src/VideoPlayer/index.js @@ -442,7 +442,10 @@ const videoPlayerPlugin = { export default autoSetupMixin(videoPlayerPlugin, () => { precision = - (ApplicationInstance && ApplicationInstance.stage && ApplicationInstance.stage.getRenderPrecision()) || precision + (ApplicationInstance && + ApplicationInstance.stage && + ApplicationInstance.stage.getRenderPrecision()) || + precision videoEl = setupVideoTag()