From 4078c6ba3448a8a054c31aa292a0346e2d0a8803 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 1 Sep 2021 17:07:51 -0300 Subject: [PATCH] First complete working prototype scanning from search bar --- src/Title.tsx | 118 +++++++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/src/Title.tsx b/src/Title.tsx index 0a017f7..6e39795 100644 --- a/src/Title.tsx +++ b/src/Title.tsx @@ -6,6 +6,7 @@ import { OnResultFunction } from "@blackbox-vision/react-qr-reader/dist-types/ty import { BarcodeFormat } from "@zxing/library"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faQrcode } from "@fortawesome/free-solid-svg-icons/faQrcode"; +import { Dialog } from "@headlessui/react"; import useKeyboardShortcut from "use-keyboard-shortcut"; import PriceBox from "./PriceBox"; import { RuntimeContext } from "./useRuntime"; @@ -35,9 +36,9 @@ const Title: React.FC = () => { searchRef.current?.focus(); }); - const [isScanning, setScanning] = useState(); + const [isScanning, setScanning] = useState(false); const onScan = () => { - setScanning(!isScanning); + setScanning(true); }; const evaluateScan: OnResultFunction = (result, error, codeReader) => { console.log("scan"); @@ -49,68 +50,79 @@ const Title: React.FC = () => { return; } - if (searchRef.current) { - searchRef.current.value = text; - searchRef.current.dispatchEvent(new Event("input", { bubbles: true })); - } + history.push(`/search?q=${text}`); setScanning(false); } }; return ( -
- -
- An otter scanning - Otterscan -
- -
- {provider?.network.chainId === 1 && } -
- - - {isScanning && ( + <> + setScanning(false)} + > +
+ + + Point an ETH address QR code to camera + +
- )} -
+
+
+ +
+ An otter scanning + Otterscan +
+ +
+ {provider?.network.chainId === 1 && } + - Search - - + + + + +
-
+ ); };