mirror of
https://github.com/status-im/keycard-exit.git
synced 2025-01-21 00:00:43 +00:00
add scan window
This commit is contained in:
parent
3853cf27e6
commit
349b817fb9
@ -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<HomeScreenProps> = 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<HomeScreenProps> = props => {
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<View>
|
||||
<View>
|
||||
<Text style={styles.heading}> Success</Text>
|
||||
<Text style={styles.prompt}>{walletAddress()}</Text>
|
||||
<Button label="Home" disabled={false} btnColor="#199515" btnBorderColor="#199515" btnFontSize={17} btnBorderWidth={1} btnWidth="100%" onChangeFunc={onCancelFunc} btnJustifyContent='center'></Button>
|
||||
</View>
|
||||
</View>
|
||||
)};
|
||||
if (step == HomeSteps.Home) {
|
||||
return <SafeAreaView>
|
||||
<Text style={styles.prompt}>{walletAddress()}</Text>
|
||||
<Button label="Scan" disabled={false} btnColor="#199515" btnBorderColor="#199515" btnFontSize={17} btnBorderWidth={1} btnWidth="100%" onChangeFunc={() => setStep(HomeSteps.ScanCode)} btnJustifyContent='center'></Button>
|
||||
<Button label="Receive" disabled={false} btnColor="#199515" btnBorderColor="#199515" btnFontSize={17} btnBorderWidth={1} btnWidth="100%" onChangeFunc={() => setStep(HomeSteps.ShowAddress)} btnJustifyContent='center'></Button>
|
||||
<Button label="Cancel" disabled={false} btnColor="#199515" btnBorderColor="#199515" btnFontSize={17} btnBorderWidth={1} btnWidth="100%" onChangeFunc={onCancelFunc} btnJustifyContent='center'></Button>
|
||||
</SafeAreaView>
|
||||
} else if (step == HomeSteps.ScanCode) {
|
||||
return <Camera style={StyleSheet.absoluteFill} device={cameraDevice!} isActive={true} codeScanner={codeScanner}/>
|
||||
} else {
|
||||
return <SafeAreaView></SafeAreaView>
|
||||
}
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
heading: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user