Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OK-17844: update market top header (#2656)
* chore: tweak styles * OK-17844: update market top header * fix: swap actual received token
- Loading branch information
Showing
14 changed files
with
286 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
packages/kit/src/views/Swap/components/Transaction/MoreMenus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import type { FC } from 'react'; | ||
import { useCallback, useMemo } from 'react'; | ||
|
||
import backgroundApiProxy from '../../../../background/instance/backgroundApiProxy'; | ||
import { useAccount, useNavigationActions } from '../../../../hooks'; | ||
import { useClipboard } from '../../../../hooks/useClipboard'; | ||
import { useNetwork } from '../../../../hooks/useNetwork'; | ||
import useOpenBlockBrowser from '../../../../hooks/useOpenBlockBrowser'; | ||
import BaseMenu from '../../../Overlay/BaseMenu'; | ||
|
||
import type { IBaseMenuOptions, IMenu } from '../../../Overlay/BaseMenu'; | ||
|
||
type ReceiptProps = { | ||
accountId?: string; | ||
networkId?: string; | ||
address?: string; | ||
}; | ||
|
||
type AccountMoreMenusProps = { | ||
accountId?: string; | ||
networkId?: string; | ||
}; | ||
|
||
export const AccountMoreMenus: FC<IMenu & AccountMoreMenusProps> = ({ | ||
accountId, | ||
networkId, | ||
...rest | ||
}) => { | ||
const { copyText } = useClipboard(); | ||
const { network } = useNetwork({ networkId }); | ||
const { account } = useAccount({ | ||
accountId: accountId ?? '', | ||
networkId: networkId ?? '', | ||
}); | ||
const openBlockBrowser = useOpenBlockBrowser(network); | ||
const { openRootHome } = useNavigationActions(); | ||
|
||
const onOpenAccount = useCallback(() => { | ||
if (account && networkId) { | ||
backgroundApiProxy.serviceAccount.changeCurrrentAccount({ | ||
accountId: account.id, | ||
networkId, | ||
}); | ||
openRootHome(); | ||
} | ||
}, [openRootHome, account, networkId]); | ||
|
||
const options = useMemo(() => { | ||
const baseOptions: IBaseMenuOptions = [ | ||
Boolean(account) && { | ||
id: 'action__view_account', | ||
onPress: () => onOpenAccount(), | ||
icon: 'UserOutline', | ||
}, | ||
{ | ||
id: 'action__copy_address', | ||
onPress: () => copyText(account?.address ?? ''), | ||
icon: 'Square2StackOutline', | ||
}, | ||
openBlockBrowser.hasAvailable && { | ||
id: 'action__view_in_browser', | ||
onPress: () => openBlockBrowser.openAddressDetails(account?.address), | ||
icon: 'ArrowTopRightOnSquareOutline', | ||
}, | ||
]; | ||
return baseOptions; | ||
}, [copyText, openBlockBrowser, onOpenAccount, account]); | ||
|
||
return <BaseMenu options={options} {...rest} />; | ||
}; | ||
|
||
export const ReceiptMoreMenus: FC<IMenu & ReceiptProps> = ({ | ||
accountId, | ||
address, | ||
networkId, | ||
...rest | ||
}) => { | ||
const { copyText } = useClipboard(); | ||
const { network } = useNetwork({ networkId }); | ||
const { account } = useAccount({ | ||
accountId: accountId ?? '', | ||
networkId: networkId ?? '', | ||
}); | ||
const openBlockBrowser = useOpenBlockBrowser(network); | ||
const { openRootHome } = useNavigationActions(); | ||
|
||
const onOpenAccount = useCallback(() => { | ||
if (account && networkId) { | ||
backgroundApiProxy.serviceAccount.changeCurrrentAccount({ | ||
accountId: account.id, | ||
networkId, | ||
}); | ||
openRootHome(); | ||
} | ||
}, [openRootHome, account, networkId]); | ||
|
||
const options = useMemo(() => { | ||
const baseOptions: IBaseMenuOptions = [ | ||
Boolean(account) && { | ||
id: 'action__view_account', | ||
onPress: () => onOpenAccount(), | ||
icon: 'UserOutline', | ||
}, | ||
{ | ||
id: 'action__copy_address', | ||
onPress: () => copyText(address ?? ''), | ||
icon: 'Square2StackOutline', | ||
}, | ||
openBlockBrowser.hasAvailable && { | ||
id: 'action__view_in_browser', | ||
onPress: () => openBlockBrowser.openAddressDetails(address), | ||
icon: 'ArrowTopRightOnSquareOutline', | ||
}, | ||
]; | ||
return baseOptions; | ||
}, [copyText, openBlockBrowser, onOpenAccount, address, account]); | ||
|
||
return <BaseMenu options={options} {...rest} />; | ||
}; |
59 changes: 0 additions & 59 deletions
59
packages/kit/src/views/Swap/components/Transaction/ReceiptMoreMenus.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.