Skip to content

Commit

Permalink
fix copy meta mask in desktop and add vercel deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
shawwal committed Nov 21, 2023
1 parent b938f57 commit 79a91cd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 15 deletions.
45 changes: 30 additions & 15 deletions app/(tabs)/donates.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { StyleSheet, TouchableOpacity, Alert, Image, Linking, Clipboard } from 'react-native';
import { StyleSheet, TouchableOpacity, Alert, Image, Linking, Clipboard, Platform } from 'react-native';
import { Text, View } from '../../components/Themed';

export default function TabDonatesScreen() {
Expand All @@ -10,21 +10,36 @@ export default function TabDonatesScreen() {

const showMetaMaskAddress = () => {
const walletAddress = '0x2785b6206ADe4B688ADFD6ECB206f56997eAd85D';

Alert.alert(
'MetaMask Wallet Address',
`Your MetaMask wallet address: ${walletAddress}`,
[
{
text: 'Copy Address',
onPress: async () => {
await Clipboard.setString(walletAddress);
Alert.alert('Address Copied', 'Your MetaMask wallet address has been copied to the clipboard.');
},
const handleCopyAddress = async () => {
await Clipboard.setString(walletAddress);
Alert.alert('Address Copied', 'Your MetaMask wallet address has been copied to the clipboard.');
};

if (Platform.OS === 'web') {
// For web platform, use navigator.clipboard.writeText
navigator.clipboard.writeText(walletAddress).then(
function () {
window.alert('Address Copied, Your MetaMask wallet address has been copied to the clipboard.');
},
{ text: 'OK', onPress: () => { } },
]
);
function (err) {
window.alert('Unable to copy to clipboard' + err);
}
);
} else {
// For mobile platforms, use Alert.alert and Clipboard.setString
Alert.alert(
'MetaMask Wallet Address',
`Your MetaMask wallet address: ${walletAddress}`,
[
{
text: 'Copy Address',
onPress: handleCopyAddress,
},
{ text: 'OK', onPress: () => {} },
]
);
}
};

return (
Expand Down
14 changes: 14 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"buildCommand": "expo export -p web",
"outputDirectory": "dist",
"devCommand": "expo",
"cleanUrls": true,
"framework": null,
"rewrites": [
{
"source": "/:path*",
"destination": "/"
}
]
}

0 comments on commit 79a91cd

Please sign in to comment.