Commit 69210286 by G

a good enough implementation using the device security system.

- ask for password when hidden (on click) - insta hide when visible (on click)
parent d18e9f36
...@@ -23,6 +23,14 @@ ...@@ -23,6 +23,14 @@
}, },
"web": { "web": {
"favicon": "./assets/favicon.png" "favicon": "./assets/favicon.png"
} },
"plugins": [
[
"expo-local-authentication",
{
"faceIDPermission": "Allow B-Easy to use Face ID."
}
]
]
} }
} }
import Box from "@components/bases/Box"; import Box from "@components/bases/Box";
import Text from "@components/bases/Text"; import Text from "@components/bases/Text";
import { images } from "@styles/Commons"; import { images } from "@styles/Commons";
import * as LocalAuthentication from "expo-local-authentication";
import { useState } from "react"; import { useState } from "react";
import { Image, TouchableOpacity } from "react-native"; import { Image, TouchableOpacity } from "react-native";
...@@ -9,6 +10,18 @@ type Props = { balance: number; label: string }; ...@@ -9,6 +10,18 @@ type Props = { balance: number; label: string };
const BalanceContainer = ({ label, balance }: Props) => { const BalanceContainer = ({ label, balance }: Props) => {
const [showBalance, setShowBalance] = useState(false); const [showBalance, setShowBalance] = useState(false);
const handleLocalAuthentication = async () => {
console.log("handleLocalAuthentication :: start");
if (showBalance) {
return setShowBalance(false);
}
const result = await LocalAuthentication.authenticateAsync();
if (result.success) {
setShowBalance(true);
}
console.log("handleLocalAuthentication :: end", result);
};
return ( return (
<Box <Box
position={"relative"} position={"relative"}
...@@ -31,7 +44,7 @@ const BalanceContainer = ({ label, balance }: Props) => { ...@@ -31,7 +44,7 @@ const BalanceContainer = ({ label, balance }: Props) => {
</Box> </Box>
<Box alignItems={"center"} gap={"s"}> <Box alignItems={"center"} gap={"s"}>
<TouchableOpacity onPress={() => setShowBalance(!showBalance)}> <TouchableOpacity onPress={handleLocalAuthentication}>
<Box height={50} alignItems={"center"} justifyContent={"center"}> <Box height={50} alignItems={"center"} justifyContent={"center"}>
{showBalance ? ( {showBalance ? (
<Text fontSize={30} variant={"black"}> <Text fontSize={30} variant={"black"}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment