Skip to content

Commit

Permalink
only copy deposit address (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xBigBoss authored Jul 24, 2024
1 parent e1744fc commit 0275f6e
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions packages/app/components/DepositAddress.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import {
AnimatePresence,
Button,
Dialog,
Paragraph,
XStack,
YStack,
AnimatePresence,
Sheet,
Theme,
useToastController,
XStack,
YStack,
type ButtonProps,
Dialog,
Sheet,
} from '@my/ui'
import type { Address } from 'viem'
import { CheckCheck } from '@tamagui/lucide-icons'
import { shorten } from 'app/utils/strings'
import { useEffect, useState } from 'react'
import * as Sharing from 'expo-sharing'
import * as Clipboard from 'expo-clipboard'
import { CheckCheck } from '@tamagui/lucide-icons'
import { useState } from 'react'
import type { Address } from 'viem'
import { IconCopy } from './icons'

function CopyAddressDialog({ isOpen, onClose, onConfirm }) {
Expand Down Expand Up @@ -66,24 +65,11 @@ function CopyAddressDialog({ isOpen, onClose, onConfirm }) {
export function DepositAddress({ address, ...props }: { address?: Address } & ButtonProps) {
const toast = useToastController()
const [hasCopied, setHasCopied] = useState(false)
const [canShare, setCanShare] = useState(false)
const [copyAddressDialogIsOpen, setCopyAddressDialogIsOpen] = useState(false)

useEffect(() => {
const canShare = async () => {
const canShare = await Sharing.isAvailableAsync()
setCanShare(canShare)
}
canShare()
}, [])

if (!address) return null

const shareOrCopyOnPress = async () => {
if (canShare) {
return await Sharing.shareAsync(address)
}

const copyOnPress = async () => {
await Clipboard.setStringAsync(address).catch(() =>
toast.show('Something went wrong', {
message: 'We were unable to copy your referral link to the clipboard',
Expand Down Expand Up @@ -158,7 +144,7 @@ export function DepositAddress({ address, ...props }: { address?: Address } & Bu
setCopyAddressDialogIsOpen(false)
}}
onConfirm={() => {
shareOrCopyOnPress()
copyOnPress()
setCopyAddressDialogIsOpen(false)
setHasCopied(true)
}}
Expand Down

0 comments on commit 0275f6e

Please sign in to comment.