Move in ui-qr as react-qr (from apps) (#164)

This commit is contained in:
Jaco Greeff
2019-07-29 10:55:02 +02:00
committed by GitHub
parent 1de68ac029
commit 9664b72253
16 changed files with 778 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
// Copyright 2017-2019 @polkadot/react-qr authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BaseProps } from './types';
import React from 'react';
import QrScan from './Scan';
import { encodeString } from './util';
interface Props extends BaseProps {
onError?: (error: Error) => void;
onScan?: (data: Uint8Array) => void;
}
export default class ScanSignature extends React.PureComponent<Props> {
public render (): React.ReactNode {
const { className, onError, style } = this.props;
return (
<QrScan
className={className}
onError={onError}
onScan={this.onScan}
style={style}
/>
);
}
private onScan = (data: string | null): void => {
const { onScan } = this.props;
if (!data || !onScan) {
return;
}
onScan(encodeString(data));
}
}