Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Whirlpool
whirlpool-gui
Commits
8d71849a
Unverified
Commit
8d71849a
authored
Dec 29, 2019
by
Pavel Ševčík
Browse files
created WebcamPayloadModal
parent
3fc78d78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
app/components/Modals/WebcamPayloadModal.js
app/components/Modals/WebcamPayloadModal.js
+80
-0
No files found.
app/components/Modals/WebcamPayloadModal.js
0 → 100644
View file @
8d71849a
// @flow
import
React
from
'
react
'
;
import
AbstractModal
from
'
./AbstractModal
'
;
import
Webcam
from
'
react-webcam
'
;
import
QrcodeDecoder
from
'
qrcode-decoder
'
;
const
qr
=
new
QrcodeDecoder
();
type
Props
=
{};
export
default
class
WebcamPayloadModal
extends
AbstractModal
{
webcamRef
=
React
.
createRef
<
Webcam
>
();
captureInterval
:
IntervalID
|
null
=
null
;
constructor
(
props
:
Props
)
{
const
initialState
=
{};
super
(
props
,
'
modal-webcam-payload
'
,
initialState
);
}
componentDidMount
()
{
this
.
captureInterval
=
setInterval
(
this
.
captureImage
,
2000
);
}
componentWillUnmount
()
{
if
(
this
.
captureInterval
)
{
clearInterval
(
this
.
captureInterval
);
}
}
captureImage
=
async
()
=>
{
if
(
this
.
webcamRef
.
current
)
{
const
imageData
=
this
.
webcamRef
.
current
.
getScreenshot
();
if
(
imageData
)
{
const
result
=
await
qr
.
decodeFromImage
(
imageData
).
catch
(
err
=>
{
console
.
log
(
'
QR code not readable:
'
,
err
);
});
if
(
result
)
{
this
.
props
.
onScan
(
result
.
data
);
this
.
props
.
onClose
();
}
}
}
};
renderTitle
()
{
return
<
span
>
Pairing
Payload
<
/span>
;
}
renderButtons
()
{
return
<
div
/>
;
}
renderBody
()
{
return
(
<
div
className
=
"
row
"
>
<
div
className
=
"
col-sm-12
"
>
Scan
your
<
strong
>
pairing
payload
<
/strong> from Samourai Wallet, go to{' '
}
<
strong
>
Settings
/
Transactions
/
Experimental
<
/strong
>
<
div
className
=
"
text-center pt-4
"
>
<
Webcam
ref
=
{
this
.
webcamRef
}
audio
=
{
false
}
width
=
{
300
}
height
=
{
300
}
screenshotQuality
=
{
1
}
screenshotFormat
=
{
'
image/png
'
}
videoConstraints
=
{{
width
:
300
,
height
:
300
,
facingMode
:
'
user
'
}}
/
>
<
/div
>
<
/div
>
<
/div
>
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment