Skip to content

Commit

Permalink
feat(#463) Remove share helium address (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChewingGlass authored Sep 15, 2023
1 parent 1e01811 commit 92d567b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 86 deletions.
64 changes: 18 additions & 46 deletions src/features/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import React, { memo, ReactText, useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import Box from '@components/Box'
import CloseButton from '@components/CloseButton'
import SafeAreaBox from '@components/SafeAreaBox'
import Text from '@components/Text'
import useAlert from '@hooks/useAlert'
import { useAppVersion } from '@hooks/useDevice'
import { useNavigation } from '@react-navigation/native'
import { Alert, Linking, Platform, SectionList } from 'react-native'
import { Cluster } from '@solana/web3.js'
import Text from '@components/Text'
import SafeAreaBox from '@components/SafeAreaBox'
import { useHitSlop, useSpacing } from '@theme/themeHooks'
import Box from '@components/Box'
import { useAppVersion } from '@hooks/useDevice'
import useCopyText from '@hooks/useCopyText'
import useAlert from '@hooks/useAlert'
import CloseButton from '@components/CloseButton'
import React, { memo, ReactText, useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { Alert, Linking, Platform, SectionList } from 'react-native'
import deviceInfo from 'react-native-device-info'
import { HomeNavigationProp } from '../home/homeTypes'
import SettingsListItem, { SettingsListItemType } from './SettingsListItem'
import { SUPPORTED_LANGUAGUES } from '../../utils/i18n'
import useAuthIntervals from './useAuthIntervals'
import SUPPORTED_CURRENCIES from '../../utils/supportedCurrencies'
import { PRIVACY_POLICY, TERMS_OF_SERVICE } from '../../constants/urls'
import { RootNavigationProp } from '../../navigation/rootTypes'
import { useSolana } from '../../solana/SolanaProvider'
import { useAccountStorage } from '../../storage/AccountStorageProvider'
import { useAppStorage } from '../../storage/AppStorageProvider'
import { SettingsNavigationProp } from './settingsTypes'
import { useLanguageStorage } from '../../storage/LanguageProvider'
import {
checkSecureAccount,
getSecureAccount,
} from '../../storage/secureStorage'
import { PRIVACY_POLICY, TERMS_OF_SERVICE } from '../../constants/urls'
import { ellipsizeAddress } from '../../utils/accountUtils'
import { RootNavigationProp } from '../../navigation/rootTypes'
import { useSolana } from '../../solana/SolanaProvider'
import { SUPPORTED_LANGUAGUES } from '../../utils/i18n'
import SUPPORTED_CURRENCIES from '../../utils/supportedCurrencies'
import { HomeNavigationProp } from '../home/homeTypes'
import SettingsListItem, { SettingsListItemType } from './SettingsListItem'
import { SettingsNavigationProp } from './settingsTypes'
import useAuthIntervals from './useAuthIntervals'

const Settings = () => {
const { t } = useTranslation()
Expand Down Expand Up @@ -57,7 +55,6 @@ const Settings = () => {
updateCurrency,
updateRequirePinForPayment,
} = useAppStorage()
const copyText = useCopyText()
const { showOKAlert, showOKCancelAlert } = useAlert()
const { updateCluster, cluster } = useSolana()

Expand Down Expand Up @@ -368,30 +365,6 @@ const Settings = () => {
onToggle: handleSetDefaultAccount,
value: isDefaultAccount,
},
{
title: t('settings.sections.account.copyAddress'),
onPress: undefined,
select: {
items: [
{ label: 'Helium', value: 'helium' },
{ label: 'Solana', value: 'solana' },
],
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onValueSelect: (val: any) => {
const address =
val === 'helium'
? currentAccount?.address
: currentAccount?.solanaAddress

if (!address) return

copyText({
message: ellipsizeAddress(address),
copyText: address,
})
},
},
},
{
title: t('settings.sections.account.shareAddress'),
onPress: handleShareAddress,
Expand Down Expand Up @@ -494,7 +467,6 @@ const Settings = () => {
authInterval,
authIntervals,
cluster,
copyText,
currency,
currentAccount,
handleCurrencyTypeChange,
Expand Down
54 changes: 14 additions & 40 deletions src/features/settings/ShareAddressScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import React, { memo, useMemo, useCallback, useRef, useState } from 'react'
import QRCode from 'react-native-qrcode-svg'
import ShareAddress from '@assets/images/shareAddress.svg'
import { useTranslation } from 'react-i18next'
import { Platform } from 'react-native'
import Share, { ShareOptions } from 'react-native-share'
import { Spacing } from '@theme/theme'
import { useAccountStorage } from '@storage/AccountStorageProvider'
import useHaptic from '@hooks/useHaptic'
import { useSpacing } from '@theme/themeHooks'
import Box from '@components/Box'
import TouchableOpacityBox from '@components/TouchableOpacityBox'
import Text from '@components/Text'
import BackScreen from '@components/BackScreen'
import { ellipsizeAddress } from '@utils/accountUtils'
import Box from '@components/Box'
import CopyAddress from '@components/CopyAddress'
import TabBar from '@components/TabBar'
import Text from '@components/Text'
import TouchableOpacityBox from '@components/TouchableOpacityBox'
import useCopyText from '@hooks/useCopyText'
import useHaptic from '@hooks/useHaptic'
import { useAccountStorage } from '@storage/AccountStorageProvider'
import { Spacing } from '@theme/theme'
import { useSpacing } from '@theme/themeHooks'
import { ellipsizeAddress } from '@utils/accountUtils'
import React, { memo, useCallback, useMemo, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { Platform } from 'react-native'
import QRCode from 'react-native-qrcode-svg'
import Share, { ShareOptions } from 'react-native-share'

const QR_CONTAINER_SIZE = 225

Expand All @@ -30,23 +29,9 @@ const ShareAddressScreen = () => {
}>(null)
const copyText = useCopyText()

const tabData = useMemo((): Array<{
value: string
title: string
}> => {
return [
{ title: 'Solana', value: 'solana' },
{ title: 'Helium', value: 'helium' },
]
}, [])

const [selectedOption, setSelectedOption] = useState(tabData[0].value)

const address = useMemo(() => {
if (selectedOption === 'helium') return currentAccount?.address

return currentAccount?.solanaAddress
}, [currentAccount, selectedOption])
}, [currentAccount])

const handleShare = useCallback(async () => {
if (!address) return
Expand Down Expand Up @@ -88,10 +73,6 @@ const ShareAddressScreen = () => {
})
}, [address, triggerNavHaptic])

const handleItemSelected = useCallback((value: string) => {
setSelectedOption(value)
}, [])

if (!currentAccount || !address) return null

return (
Expand All @@ -103,13 +84,6 @@ const ShareAddressScreen = () => {
alignItems="center"
marginBottom="xxxl"
>
<TabBar
tabBarOptions={tabData}
selectedValue={selectedOption}
onItemSelected={handleItemSelected}
marginBottom="xxl"
/>

<Text
variant="h2"
color="primaryText"
Expand Down

0 comments on commit 92d567b

Please sign in to comment.