From 349b817fb9c1b31b1dada7d5175ca7100339f635 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Mon, 30 Sep 2024 13:29:56 +0200 Subject: [PATCH] add scan window --- src/components/steps/HomeScreen.tsx | 41 +++++++++++++++++++---------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/components/steps/HomeScreen.tsx b/src/components/steps/HomeScreen.tsx index 1aa1606..dd12667 100644 --- a/src/components/steps/HomeScreen.tsx +++ b/src/components/steps/HomeScreen.tsx @@ -1,7 +1,13 @@ -import {FC, useEffect } from "react"; -import { StyleSheet, Text, View } from "react-native"; +import {FC, useEffect, useState } from "react"; +import { SafeAreaView, StyleSheet, Text, View } from "react-native"; import Button from "../Button"; -import { useCameraDevice, useCameraPermission, useCodeScanner } from "react-native-vision-camera"; +import { Camera, useCameraDevice, useCameraPermission, useCodeScanner } from "react-native-vision-camera"; + +enum HomeSteps { + Home, + ScanCode, + ShowAddress, +} type HomeScreenProps = { walletKey: string; @@ -11,12 +17,15 @@ type HomeScreenProps = { const HomeScreen: FC = props => { const {walletKey, onPressFunc, onCancelFunc} = props; - const cameraDevice = useCameraDevice('back') - const { hasPermission, requestPermission } = useCameraPermission(); + const [step, setStep] = useState(HomeSteps.Home); + const cameraDevice = useCameraDevice('back'); + const {hasPermission, requestPermission} = useCameraPermission(); const codeScanner = useCodeScanner({ codeTypes: ['qr'], onCodeScanned: (codes) => { console.log(`Scanned ${codes.length} codes!`) + //TODO: implement + setStep(HomeSteps.Home); } }); @@ -32,15 +41,19 @@ const HomeScreen: FC = props => { } }); - return ( - - - Success - {walletAddress()} - - - - )}; + if (step == HomeSteps.Home) { + return + {walletAddress()} + + + + + } else if (step == HomeSteps.ScanCode) { + return + } else { + return + } +}; const styles = StyleSheet.create({ heading: {