From c8978266e74fe218fde5ab0fa5b6b4c49add7509 Mon Sep 17 00:00:00 2001 From: heisenberg Date: Mon, 20 May 2024 16:23:41 +0800 Subject: [PATCH] feat: send nft --- _raw/locales/en/messages.json | 3 +- _raw/locales/zh-CN/messages.json | 3 +- .../Approval/components/Actions/Send.tsx | 8 + .../Approval/components/Actions/SendNFT.tsx | 203 ++++++++++-------- .../Actions/components/LogoWithText.tsx | 1 + .../Actions/components/NFTWithName.tsx | 16 +- .../Actions/components/SecurityListItem.tsx | 4 +- .../components/Actions/components/Table.tsx | 12 +- .../components/Actions/components/Values.tsx | 4 +- .../Dashboard/components/NFT/NFTAvatar.tsx | 2 +- 10 files changed, 153 insertions(+), 103 deletions(-) diff --git a/_raw/locales/en/messages.json b/_raw/locales/en/messages.json index f23282f5c77..f127a1fc136 100644 --- a/_raw/locales/en/messages.json +++ b/_raw/locales/en/messages.json @@ -299,7 +299,8 @@ "no": "No", "hasInteraction": "Interacted before", "address": "Address", - "advancedSettings": "Advanced Settings" + "advancedSettings": "Advanced Settings", + "amount": "Amount" }, "signFooterBar": { "requestFrom": "Request from", diff --git a/_raw/locales/zh-CN/messages.json b/_raw/locales/zh-CN/messages.json index b09d490c3e3..f8243d5bea2 100644 --- a/_raw/locales/zh-CN/messages.json +++ b/_raw/locales/zh-CN/messages.json @@ -1373,7 +1373,8 @@ "no": "否", "yes": "是", "address": "地址", - "advancedSettings": "高级设置" + "advancedSettings": "高级设置", + "amount": "数量" }, "signTypedData": { "buyNFT": { diff --git a/src/ui/views/Approval/components/Actions/Send.tsx b/src/ui/views/Approval/components/Actions/Send.tsx index 42ad1bbafc0..1f61f483108 100644 --- a/src/ui/views/Approval/components/Actions/Send.tsx +++ b/src/ui/views/Approval/components/Actions/Send.tsx @@ -103,6 +103,12 @@ const Send = ({ + + {t('page.signTx.addressNote')} + + + + {!!requireData.name && ( {t('page.signTx.protocol')} @@ -138,11 +144,13 @@ const Send = ({ {t('page.signTx.sendNFT.title')} - - -
    - {actionData?.nft?.amount > 1 && ( -
  • Amount: {actionData?.nft?.amount}
  • - )} -
  • - -
  • -
+ + + + + + {actionData?.nft?.amount > 1 && ( + + {t('page.signTx.amount')} + {actionData?.nft?.amount} + + )} + {t('page.signTx.send.sendTo')} -
- -
    -
  • - -
  • - {requireData.name &&
  • {requireData.name}
  • } - - - {requireData.cex && ( - <> -
  • - -
  • - - - - )} - } - id="1036" - /> - -
  • - -
  • -
-
+ + +
+ + + {t('page.signTx.addressNote')} + + + + + {!!requireData.name && ( + + {t('page.signTx.protocolTitle')} + {requireData.name} + + )} + + + {requireData.cex && ( + <> + + {t('page.signTx.send.cexAddress')} + + {' '} + + + + + + + )} + } + id="1036" + /> + + ); diff --git a/src/ui/views/Approval/components/Actions/components/LogoWithText.tsx b/src/ui/views/Approval/components/Actions/components/LogoWithText.tsx index 4181716989a..823ec90ee08 100644 --- a/src/ui/views/Approval/components/Actions/components/LogoWithText.tsx +++ b/src/ui/views/Approval/components/Actions/components/LogoWithText.tsx @@ -8,6 +8,7 @@ import IconUnknown from 'ui/assets/token-default.svg'; const Wrapper = styled.div` display: flex; align-items: center; + justify-content: flex-end; .logo { width: 16px; height: 16px; diff --git a/src/ui/views/Approval/components/Actions/components/NFTWithName.tsx b/src/ui/views/Approval/components/Actions/components/NFTWithName.tsx index 8728d74cb8f..e8083702eef 100644 --- a/src/ui/views/Approval/components/Actions/components/NFTWithName.tsx +++ b/src/ui/views/Approval/components/Actions/components/NFTWithName.tsx @@ -45,26 +45,35 @@ const NFTWithName = ({ nft, textStyle, showTokenLabel = false, + id, + hasHover, }: { nft: NFTItem; textStyle?: React.CSSProperties; showTokenLabel?: boolean; + id?: string; + hasHover?: boolean; }) => { const [focusingNFT, setFocusingNFT] = React.useState(null); return ( <> setFocusingNFT(nft)} + onPreview={(e) => { + e.stopPropagation(); + setFocusingNFT(nft); + }} className="nft-item-avatar" thumbnail content={nft?.content} type={nft?.content_type} />
@@ -88,7 +97,10 @@ const NFTWithName = ({ {focusingNFT && ( setFocusingNFT(null)} + onCancel={(e) => { + e.stopPropagation(); + setFocusingNFT(null); + }} /> )} diff --git a/src/ui/views/Approval/components/Actions/components/SecurityListItem.tsx b/src/ui/views/Approval/components/Actions/components/SecurityListItem.tsx index 70273761827..457ee52d44a 100644 --- a/src/ui/views/Approval/components/Actions/components/SecurityListItem.tsx +++ b/src/ui/views/Approval/components/Actions/components/SecurityListItem.tsx @@ -13,6 +13,7 @@ export interface Props { defaultText?: string | React.ReactNode; forbiddenText?: string | React.ReactNode; title?: string; + noTitle?: boolean; } export const SecurityListItem: React.FC = ({ @@ -24,6 +25,7 @@ export const SecurityListItem: React.FC = ({ defaultText, forbiddenText, title, + noTitle = false, }) => { if (!engineResult) { if (defaultText) { @@ -40,7 +42,7 @@ export const SecurityListItem: React.FC = ({ return ( - {displayTitle} + {noTitle ? '' : displayTitle}
diff --git a/src/ui/views/Approval/components/Actions/components/Table.tsx b/src/ui/views/Approval/components/Actions/components/Table.tsx index 1dbe2567d65..445edaeec57 100644 --- a/src/ui/views/Approval/components/Actions/components/Table.tsx +++ b/src/ui/views/Approval/components/Actions/components/Table.tsx @@ -43,7 +43,7 @@ const RowWrapper = styled.div` color: var(--r-neutral-body, #3e495e); white-space: nowrap; display: flex; - align-items: center; + align-items: flex-start; &:not(.title) { text-align: right; @@ -64,14 +64,14 @@ const RowWrapper = styled.div` } .desc-list { font-size: 13px; - line-height: 15px; - color: var(--r-neutral-body, #3e495e); + line-height: 16px; + color: var(--r-neutral-foot, #6a7587); margin: 0; font-weight: 400; li { padding-left: 10px; margin-bottom: 8px; - padding-right: 10px; + padding-right: 0; position: relative; &::before { content: ''; @@ -79,12 +79,12 @@ const RowWrapper = styled.div` left: 3px; width: 3px; height: 3px; - background-color: var(--r-neutral-body); + background-color: var(--r-neutral-foot, #6a7587); border-radius: 100%; top: 6px; } &:nth-child(1) { - margin-top: 8px; + margin-top: 4px; } &:nth-last-child(1) { margin-bottom: 0; diff --git a/src/ui/views/Approval/components/Actions/components/Values.tsx b/src/ui/views/Approval/components/Actions/components/Values.tsx index 37a3dab3af9..ab21b3f7e81 100644 --- a/src/ui/views/Approval/components/Actions/components/Values.tsx +++ b/src/ui/views/Approval/components/Actions/components/Values.tsx @@ -390,12 +390,12 @@ const Transacted = ({ value }: { value: boolean }) => { {value ? ( <> {' '} - {t('page.signTx.transacted')} + {t('page.signTx.yes')} ) : ( <> {' '} - {t('page.signTx.neverTransacted')} + {t('page.signTx.no')} )} diff --git a/src/ui/views/Dashboard/components/NFT/NFTAvatar.tsx b/src/ui/views/Dashboard/components/NFT/NFTAvatar.tsx index f33db9ee3f0..5f65069c182 100644 --- a/src/ui/views/Dashboard/components/NFT/NFTAvatar.tsx +++ b/src/ui/views/Dashboard/components/NFT/NFTAvatar.tsx @@ -17,7 +17,7 @@ type AvatarProps = { type?: NFTItem['content_type']; className?: string; style?: React.CSSProperties; - onPreview?: () => void; + onPreview?: (e) => void; amount?: number; unknown?: string; };