Skip to content

Commit

Permalink
chore: pkgs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain committed Nov 28, 2024
1 parent 36e3fa5 commit 113a555
Show file tree
Hide file tree
Showing 5 changed files with 281 additions and 28 deletions.
2 changes: 2 additions & 0 deletions apps/wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"react-native-gesture-handler": "~2.16.1",
"react-native-keychain": "7.0.0",
"react-native-localize": "^3.3.0",
"react-native-markdown-display": "^7.0.2",
"react-native-mmkv": "3.0.1",
"react-native-paper": "^5.12.5",
"react-native-qrcode-svg": "^6.3.12",
Expand All @@ -99,6 +100,7 @@
"react-native-share": "^12.0.3",
"react-native-skeleton-placeholder": "^5.2.4",
"react-native-svg": "^15.9.0",
"react-native-svg-charts": "^5.4.0",
"react-native-url-polyfill": "^2.0.0",
"react-native-webview": "^13.12.4",
"reselect": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ import {AsyncStorageProvider} from '@yoroi/common'
import {LinksProvider} from '@yoroi/links'
import {NotificationProvider} from '@yoroi/notifications'
import {SetupWalletProvider} from '@yoroi/setup-wallet'
import {catalystApiMaker, catalystManagerMaker, CatalystProvider} from '@yoroi/staking'
import {
catalystApiMaker,
catalystManagerMaker,
CatalystProvider,
} from '@yoroi/staking'
import {ThemeProvider} from '@yoroi/theme'
import {TransferProvider} from '@yoroi/transfer'
import React from 'react'
import {LogBox, StyleSheet} from 'react-native'
import * as RNP from 'react-native-paper'
import {initialWindowMetrics, SafeAreaProvider} from 'react-native-safe-area-context'
import {
initialWindowMetrics,
SafeAreaProvider,
} from 'react-native-safe-area-context'
import {enableScreens} from 'react-native-screens'

import {LoadingBoundary} from './components/Boundary/Boundary'
Expand All @@ -27,7 +34,10 @@ import {InitApp} from './InitApp'
import {disableLogbox, loggerFilter} from './kernel/env'
import {LanguageProvider} from './kernel/i18n'
import {useSetupLogger} from './kernel/logger/hooks/useSetupLogger'
import {makeMetricsManager, MetricsProvider} from './kernel/metrics/metricsManager'
import {
makeMetricsManager,
MetricsProvider,
} from './kernel/metrics/metricsManager'
import {queryInfo} from './kernel/query-client'
import {useMigrations} from './kernel/storage/migrations/useMigrations'
import {rootStorage} from './kernel/storage/rootStorage'
Expand Down Expand Up @@ -72,9 +82,13 @@ const Yoroi = () => {
<PoolTransitionProvider>
<BrowserProvider>
<AutomaticWalletOpenerProvider>
<CatalystProvider manager={catalystManager}>
<CatalystProvider
manager={catalystManager}
>
<ReviewTxProvider>
<NotificationProvider manager={notificationManager}>
<NotificationProvider
manager={notificationManager}
>
<InitApp />
</NotificationProvider>
</ReviewTxProvider>
Expand Down
36 changes: 28 additions & 8 deletions apps/wallet/src/components/Clipboard/ClipboardProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import Clipboard from '@react-native-community/clipboard'
import Clipboard from '@react-native-clipboard/clipboard'
import {useTheme} from '@yoroi/theme'
import React from 'react'
import {GestureResponderEvent, StyleSheet, useWindowDimensions} from 'react-native'
import Animated, {FadeInDown, FadeOutDown, Layout} from 'react-native-reanimated'
import {
GestureResponderEvent,
StyleSheet,
useWindowDimensions,
} from 'react-native'
import Animated, {
FadeInDown,
FadeOutDown,
Layout,
} from 'react-native-reanimated'

import {Text} from '../Text'

const ClipboardContext = React.createContext<undefined | ClipboardContext>(undefined)
const ClipboardContext = React.createContext<undefined | ClipboardContext>(
undefined,
)

type Props = {
children: React.ReactNode
Expand All @@ -24,12 +34,17 @@ export const ClipboardProvider = ({children}: Props) => {
const styles = useStyles()
const [copied, setCopied] = React.useState<CopiedState | null>(null)
const {height, width} = useWindowDimensions()
const copy: ClipboardContext['copy'] = ({text, feedback = 'Copied', event}) => {
const copy: ClipboardContext['copy'] = ({
text,
feedback = 'Copied',
event,
}) => {
Clipboard.setString(text)
setCopied({
feedback,
locationY: event ? event.nativeEvent.pageY - 50 : height * 0.85,
locationX: (event?.nativeEvent.pageX ?? width * 0.5) - feedback.length * 4,
locationX:
(event?.nativeEvent.pageX ?? width * 0.5) - feedback.length * 4,
})
setTimeout(() => setCopied(null), FEEDBACK_TIMEOUT)
}
Expand All @@ -44,7 +59,10 @@ export const ClipboardProvider = ({children}: Props) => {
layout={Layout}
entering={FadeInDown}
exiting={FadeOutDown}
style={[styles.isCopying, {top: copied.locationY, left: copied.locationX}]}
style={[
styles.isCopying,
{top: copied.locationY, left: copied.locationX},
]}
>
<Text style={styles.textCopy}>{copied.feedback}</Text>
</Animated.View>
Expand All @@ -55,7 +73,9 @@ export const ClipboardProvider = ({children}: Props) => {
}

export const useCopy = () => {
const {copy: globalCopy} = React.useContext(ClipboardContext) ?? {copy: () => null}
const {copy: globalCopy} = React.useContext(ClipboardContext) ?? {
copy: () => null,
}
const [isCopying, setIsCopying] = React.useState(false)
const copy = (props: CopyProps) => {
globalCopy(props)
Expand Down
89 changes: 75 additions & 14 deletions apps/wallet/src/features/Links/common/useLinksRequestAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {useTransfer} from '@yoroi/transfer'
import {Links} from '@yoroi/types'
import * as React from 'react'
import {InteractionManager} from 'react-native'
import uuid from 'uuid'
import * as uuid from 'uuid'

import {useModal} from '../../../components/Modal/ModalContext'
import {logger} from '../../../kernel/logger/logger'
Expand All @@ -28,11 +28,20 @@ export const useLinksRequestAction = () => {
const navigateTo = useNavigateTo()

const {addTab, setTabActive, tabs} = useBrowser()
const {memoChanged, receiverResolveChanged, amountChanged, reset, linkActionChanged} = useTransfer()
const {
memoChanged,
receiverResolveChanged,
amountChanged,
reset,
linkActionChanged,
} = useTransfer()

const startTransferWithLink = React.useCallback(
(action: Links.YoroiAction, decimals: number) => {
logger.debug('useLinksRequestAction: startTransferWithLink', {action, decimals})
logger.debug('useLinksRequestAction: startTransferWithLink', {
action,
decimals,
})
if (action.info.useCase === 'request/ada-with-link') {
reset()
try {
Expand Down Expand Up @@ -78,8 +87,16 @@ export const useLinksRequestAction = () => {
)

const openRequestedPaymentAdaWithLink = React.useCallback(
({params, isTrusted}: {params: Links.TransferRequestAdaWithLinkParams; isTrusted: boolean}, decimals: number) => {
const title = isTrusted ? strings.trustedPaymentRequestedTitle : strings.untrustedPaymentRequestedTitle
(
{
params,
isTrusted,
}: {params: Links.TransferRequestAdaWithLinkParams; isTrusted: boolean},
decimals: number,
) => {
const title = isTrusted
? strings.trustedPaymentRequestedTitle
: strings.untrustedPaymentRequestedTitle
const handleOnContinue = () =>
startTransferWithLink(
{
Expand All @@ -95,12 +112,21 @@ export const useLinksRequestAction = () => {
)

const content = (
<RequestedAdaPaymentWithLinkScreen onContinue={handleOnContinue} params={params} isTrusted={isTrusted} />
<RequestedAdaPaymentWithLinkScreen
onContinue={handleOnContinue}
params={params}
isTrusted={isTrusted}
/>
)

openModal(title, content, heightBreakpoint)
},
[strings.trustedPaymentRequestedTitle, strings.untrustedPaymentRequestedTitle, startTransferWithLink, openModal],
[
strings.trustedPaymentRequestedTitle,
strings.untrustedPaymentRequestedTitle,
startTransferWithLink,
openModal,
],
)

const launchDappUrl = React.useCallback(
Expand Down Expand Up @@ -130,12 +156,29 @@ export const useLinksRequestAction = () => {
}
}
},
[actionFinished, addTab, closeModal, linkActionChanged, navigateTo, setTabActive, tabs, track],
[
actionFinished,
addTab,
closeModal,
linkActionChanged,
navigateTo,
setTabActive,
tabs,
track,
],
)

const openRequestedBrowserLaunchDappUrl = React.useCallback(
({params, isTrusted}: {params: Links.BrowserLaunchDappUrlParams; isTrusted: boolean}) => {
const title = isTrusted ? strings.trustedBrowserLaunchDappUrlTitle : strings.untrustedBrowserLaunchDappUrlTitle
({
params,
isTrusted,
}: {
params: Links.BrowserLaunchDappUrlParams
isTrusted: boolean
}) => {
const title = isTrusted
? strings.trustedBrowserLaunchDappUrlTitle
: strings.untrustedBrowserLaunchDappUrlTitle
const handleOnContinue = () =>
launchDappUrl({
info: {
Expand All @@ -148,12 +191,21 @@ export const useLinksRequestAction = () => {
})

const content = (
<RequestedBrowserLaunchDappUrlScreen onContinue={handleOnContinue} params={params} isTrusted={isTrusted} />
<RequestedBrowserLaunchDappUrlScreen
onContinue={handleOnContinue}
params={params}
isTrusted={isTrusted}
/>
)

openModal(title, content, heightBreakpoint)
},
[launchDappUrl, openModal, strings.trustedBrowserLaunchDappUrlTitle, strings.untrustedBrowserLaunchDappUrlTitle],
[
launchDappUrl,
openModal,
strings.trustedBrowserLaunchDappUrlTitle,
strings.untrustedBrowserLaunchDappUrlTitle,
],
)

React.useEffect(() => {
Expand All @@ -173,10 +225,19 @@ export const useLinksRequestAction = () => {
})
break
default:
logger.error(new Error(`useLinksRequestAction: unknown useCase: ${action?.info.useCase}`))
logger.error(
new Error(
`useLinksRequestAction: unknown useCase: ${action?.info.useCase}`,
),
)
break
}
}
})
}, [action, openRequestedBrowserLaunchDappUrl, openRequestedPaymentAdaWithLink, wallet])
}, [
action,
openRequestedBrowserLaunchDappUrl,
openRequestedPaymentAdaWithLink,
wallet,
])
}
Loading

0 comments on commit 113a555

Please sign in to comment.