From 9e97ea627e21eae81fee8569bb5fa868e1aff5a0 Mon Sep 17 00:00:00 2001 From: caiquecruz Date: Tue, 21 May 2024 18:36:20 -0300 Subject: [PATCH] feat: set up options on QR hardware sign request --- .../qr-hardware-sign-request/player.js | 104 +++++++++++++++++- 1 file changed, 98 insertions(+), 6 deletions(-) diff --git a/ui/components/app/qr-hardware-popover/qr-hardware-sign-request/player.js b/ui/components/app/qr-hardware-popover/qr-hardware-sign-request/player.js index f19d2e2c5982..5877b1df3019 100644 --- a/ui/components/app/qr-hardware-popover/qr-hardware-sign-request/player.js +++ b/ui/components/app/qr-hardware-popover/qr-hardware-sign-request/player.js @@ -14,20 +14,30 @@ import { Text, Box } from '../../../component-library'; const Player = ({ type, cbor, cancelQRHardwareSignRequest, toRead }) => { const t = useI18nContext(); + const [interval, setIntervalValue] = useState(100); + const [maxFragmentLength, setMaxFragmentLength] = useState(200); + const [qrSize, setQRSize] = useState(250); + const [level, setLevel] = useState('L'); + const urEncoder = useMemo( - // For NGRAVE ZERO support please keep to a maximum fragment size of 200 - () => new UREncoder(new UR(Buffer.from(cbor, 'hex'), type), 200), - [cbor, type], + () => + new UREncoder(new UR(Buffer.from(cbor, 'hex'), type), maxFragmentLength), + [cbor, type, maxFragmentLength], ); const [currentQRCode, setCurrentQRCode] = useState(urEncoder.nextPart()); + + const handleLevelChange = (event) => { + setLevel(event.target.value); + }; + useEffect(() => { const id = setInterval(() => { setCurrentQRCode(urEncoder.nextPart()); - }, 100); + }, interval); return () => { clearInterval(id); }; - }, [urEncoder]); + }, [urEncoder, interval, level]); return ( <> @@ -49,7 +59,7 @@ const Player = ({ type, cbor, cancelQRHardwareSignRequest, toRead }) => { backgroundColor: 'var(--qr-code-white-background)', }} > - + @@ -57,6 +67,88 @@ const Player = ({ type, cbor, cancelQRHardwareSignRequest, toRead }) => { {t('QRHardwareSignRequestDescription')} + + QR Code Interval ({interval} ms) + setIntervalValue(Number(e.target.value))} + /> + + Max Fragment Length {maxFragmentLength} + + setMaxFragmentLength(Number(e.target.value))} + /> + QR Code Size {qrSize} + setQRSize(Number(e.target.value))} + /> + + Error Correction Level + <> + + +
+ + +
+ + +
+ + + +
+