Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin bugfixes #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/LightningSdkPlugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ export const initLightningSdkPlugin = {
},
set appInstance(v) {
ApplicationInstance = v
}
},
}
73 changes: 64 additions & 9 deletions src/Pin/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ const PinInput = () => {
}
}
}

}

export default () => {
Expand All @@ -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,
Expand All @@ -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',
},
},
},
},
}
}
Expand Down Expand Up @@ -152,32 +180,58 @@ 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)
}

_firstActive() {
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 {
Expand All @@ -204,6 +258,7 @@ export default () => {
})
.catch(e => {
this.msg = e
this.pin = ''
this.reject(e)
})
}
Expand Down
5 changes: 4 additions & 1 deletion src/Pin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ let submit = (pin, context) => {
unlocked = true
resolve(unlocked)
} else {
unlocked = false
reject('Incorrect pin')
}
})
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion src/VideoPlayer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down