Created
June 19, 2020 20:09
-
-
Save erickzanardo/c94026ad1c62f713dacabfa1d90bee18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react'; | |
import { | |
SafeAreaView, | |
StyleSheet, | |
View, | |
TouchableOpacity, | |
StatusBar, | |
Image, | |
} from 'react-native'; | |
import ReactNativeBiometrics from 'react-native-biometrics'; | |
import verifyImg from './citizen-identify-yourself.jpg'; | |
import verifiedImg from './cooperation.gif'; | |
const App = () => { | |
const [verified, setVerfied] = useState(false); | |
const onVerify = () => { | |
ReactNativeBiometrics.isSensorAvailable().then(({biometryType}) => { | |
let message = ''; | |
if (biometryType === ReactNativeBiometrics.TouchID) { | |
message = 'Confirm fingerprint'; | |
} else if (biometryType === ReactNativeBiometrics.FaceID) { | |
message = 'Face ID Message'; | |
} else if (biometryType === ReactNativeBiometrics.Biometrics) { | |
message = 'Identify'; | |
} | |
ReactNativeBiometrics.simplePrompt({ | |
promptMessage: message, | |
}).then(({success}) => { | |
setVerfied(success); | |
}); | |
}); | |
}; | |
return ( | |
<> | |
<StatusBar barStyle="dark-content" /> | |
<SafeAreaView> | |
<View style={styles.view}> | |
<TouchableOpacity onPress={onVerify}> | |
{verified ? ( | |
<Image source={verifiedImg} style={styles.img} /> | |
) : ( | |
<Image source={verifyImg} style={styles.img} /> | |
)} | |
</TouchableOpacity> | |
</View> | |
</SafeAreaView> | |
</> | |
); | |
}; | |
const styles = StyleSheet.create({ | |
view: { | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
img: { | |
width: 300, | |
resizeMode: 'contain', | |
}, | |
}); | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment