From cee2d9265008f858c9370597ab32bd07ff0e939f Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 8 Aug 2024 09:51:05 +0530 Subject: [PATCH] Implement functionality to copy mnemonic --- package.json | 1 + src/components/Dialog.tsx | 62 +++++++++++++++++++++++++-------------- yarn.lock | 5 ++++ 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index d8120f4..00e5eb5 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@hookform/resolvers": "^3.3.4", "@json-rpc-tools/utils": "^1.7.6", "@react-native-async-storage/async-storage": "^1.22.3", + "@react-native-clipboard/clipboard": "^1.14.1", "@react-native-community/netinfo": "^11.3.1", "@react-navigation/elements": "^1.3.30", "@react-navigation/native": "^6.1.10", diff --git a/src/components/Dialog.tsx b/src/components/Dialog.tsx index 05fed95..91f55b9 100644 --- a/src/components/Dialog.tsx +++ b/src/components/Dialog.tsx @@ -1,6 +1,8 @@ -import React from 'react'; +import React, { useState } from 'react'; import { View } from 'react-native'; -import { Button, Dialog, Portal, Text } from 'react-native-paper'; +import { Button, Dialog, Portal, Snackbar, Text } from 'react-native-paper'; + +import Clipboard from '@react-native-clipboard/clipboard'; import styles from '../styles/stylesheet'; import GridView from './Grid'; @@ -11,29 +13,45 @@ const DialogComponent = ({ hideDialog, contentText, }: CustomDialogProps) => { + const [toastVisible, setToastVisible] = useState(false); + const words = contentText.split(' '); + const handleCopy = () => { + Clipboard.setString(contentText); + setToastVisible(true); + }; + return ( - - - - Mnemonic - - - Your mnemonic provides full access to your wallet and funds. Make - sure to note it down.{' '} - - - Do not share your mnemonic with anyone - - - - - - - - - + <> + + + + Mnemonic + + + Your mnemonic provides full access to your wallet and funds. + Make sure to note it down.{' '} + + + Do not share your mnemonic with anyone + + + + + + + + + + + setToastVisible(false)} + duration={1000}> + Mnemonic copied to clipboard + + ); }; diff --git a/yarn.lock b/yarn.lock index b3fdd16..a96362d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2071,6 +2071,11 @@ dependencies: merge-options "^3.0.4" +"@react-native-clipboard/clipboard@^1.14.1": + version "1.14.1" + resolved "https://registry.yarnpkg.com/@react-native-clipboard/clipboard/-/clipboard-1.14.1.tgz#835f82fc86881a0808a8405f2576617bb5383554" + integrity sha512-SM3el0A28SwoeJljVNhF217o0nI4E7RfalLmuRQcT1/7tGcxUjgFa3jyrEndYUct8/uxxK5EUNGUu1YEDqzxqw== + "@react-native-community/cli-clean@12.3.2": version "12.3.2" resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.2.tgz#d4f1730c3d22d816b4d513d330d5f3896a3f5921"