Skip to content

Commit

Permalink
style: adjust the copy and icons for the floating feature. (#6384)
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming authored Dec 20, 2024
1 parent 9cd4dcb commit 670d037
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 328 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@
"@glif/filecoin-rpc-client": "3.0.2",
"@mysten/sui": "1.13.0",
"@ngraveio/bc-ur": "^1.1.13",
"@onekeyfe/cross-inpage-provider-core": "2.2.4",
"@onekeyfe/cross-inpage-provider-errors": "2.2.4",
"@onekeyfe/cross-inpage-provider-injected": "2.2.4",
"@onekeyfe/cross-inpage-provider-types": "2.2.4",
"@onekeyfe/extension-bridge-hosted": "2.2.4",
"@onekeyfe/cross-inpage-provider-core": "2.2.6",
"@onekeyfe/cross-inpage-provider-errors": "2.2.6",
"@onekeyfe/cross-inpage-provider-injected": "2.2.6",
"@onekeyfe/cross-inpage-provider-types": "2.2.6",
"@onekeyfe/extension-bridge-hosted": "2.2.6",
"@onekeyfe/hd-ble-sdk": "1.0.16",
"@onekeyfe/hd-core": "1.0.16",
"@onekeyfe/hd-shared": "1.0.16",
"@onekeyfe/hd-transport": "1.0.16",
"@onekeyfe/hd-web-sdk": "1.0.16",
"@onekeyfe/onekey-cross-webview": "2.2.4",
"@onekeyfe/onekey-cross-webview": "2.2.6",
"@polkadot/extension-inject": "0.46.6",
"@polkadot/types": "11.3.1",
"@polkadot/util-crypto": "12.6.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/kit-bg/src/services/ServiceSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class ServiceSetting extends ServiceBase {
@backgroundMethod()
public async isShowFloatingButton() {
const { isFloatingIconAlwaysDisplay } = await settingsPersistAtom.get();
return isFloatingIconAlwaysDisplay ?? true;
return isFloatingIconAlwaysDisplay ?? false;
}

@backgroundMethod()
Expand Down
2 changes: 1 addition & 1 deletion packages/kit-bg/src/states/jotai/atoms/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const settingsAtomInitialValue: ISettingsPersistAtom = {
alignPrimaryAccountMode: EAlignPrimaryAccountMode.AlignDappToWallet,
isCustomNonceEnabled: false,
isCustomTxMessageEnabled: false,
isFloatingIconAlwaysDisplay: true,
isFloatingIconAlwaysDisplay: false,
};
export const { target: settingsPersistAtom, use: useSettingsPersistAtom } =
globalAtom<ISettingsPersistAtom>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ import { EHostSecurityLevel } from '@onekeyhq/shared/types/discovery';
import { DAppRequestedDappList } from '../../../DAppConnection/components/DAppRequestContent/DAppRequestedDappList';
import { DAppRiskyAlertDetail } from '../../../DAppConnection/components/DAppRequestLayout/DAppRiskyAlertDetail';

const SecurityTitle = {
[EHostSecurityLevel.Security]: ETranslations.dapp_connect_verified_site,
[EHostSecurityLevel.High]: ETranslations.dapp_connect_malicious_site_warning,
[EHostSecurityLevel.Medium]:
ETranslations.dapp_connect_suspected_malicious_behavior,
};

export function DappInfoPopoverContent({
hostSecurity,
closePopover,
Expand All @@ -37,109 +44,51 @@ export function DappInfoPopoverContent({
}) {
const intl = useIntl();
const { securityElement, securityStatus } = useMemo(() => {
const security =
hostSecurity?.checkSources
.filter((item) => item.riskLevel === EHostSecurityLevel.Security)
.map((item) => item.name)
.join(' & ') || '';
if (security) {
if (hostSecurity?.level === EHostSecurityLevel.Unknown) {
return {
securityStatus: EHostSecurityLevel.Security,
securityStatus: EHostSecurityLevel.Unknown,
securityElement: (
<>
<SizableText size="$bodyMd" flex={1}>
{intl.formatMessage({
id: ETranslations.dapp_connect_verified_site,
})}
</SizableText>
<SizableText size="$bodyMd" color="$textSubdued">
{intl.formatMessage(
{
id: ETranslations.global_from_provider,
},
{
provider: security,
},
)}
</SizableText>
</>
<SizableText size="$bodyMd">
{intl.formatMessage({
id: ETranslations.global_unknown,
})}
</SizableText>
),
};
}

const highSecurity =
const providerNames =
hostSecurity?.checkSources
.filter((item) => item.riskLevel === EHostSecurityLevel.High)
.filter((item) => item.riskLevel === hostSecurity?.level)
.map((item) => item.name)
.join(' & ') || '';

if (highSecurity) {
return {
securityStatus: EHostSecurityLevel.High,
securityElement: (
<>
<SizableText size="$bodyMd" flex={1}>
{intl.formatMessage({
id: ETranslations.dapp_connect_malicious_site_warning,
})}
</SizableText>
<SizableText size="$bodyMd">
{intl.formatMessage(
{
id: ETranslations.global_from_provider,
},
{
provider: highSecurity,
},
)}
</SizableText>
</>
),
};
}

const mediumSecurity =
hostSecurity?.checkSources
.filter((item) => EHostSecurityLevel.Medium === item.riskLevel)
.map((item) => item.name)
.join(' & ') || '';

if (mediumSecurity) {
return {
securityStatus: EHostSecurityLevel.Medium,
securityElement: (
<>
<SizableText size="$bodyMd" flex={1}>
{intl.formatMessage({
id: ETranslations.dapp_connect_suspected_malicious_behavior,
})}
</SizableText>
<SizableText size="$bodyMd">
return {
securityStatus: hostSecurity?.level
? SecurityTitle[hostSecurity?.level]
: EHostSecurityLevel.Unknown,
securityElement: (
<>
<SizableText size="$bodyMd" flex={1}>
{intl.formatMessage({
id: ETranslations.dapp_connect_verified_site,
})}
</SizableText>
{providerNames ? (
<SizableText size="$bodyMd" color="$textSubdued">
{intl.formatMessage(
{
id: ETranslations.global_from_provider,
},
{
provider: mediumSecurity,
provider: providerNames,
},
)}
</SizableText>
</>
),
};
}

return {
securityStatus: EHostSecurityLevel.Unknown,
securityElement: (
<SizableText size="$bodyMd">
{intl.formatMessage({
id: ETranslations.global_unknown,
})}
</SizableText>
) : null}
</>
),
};
}, [hostSecurity?.checkSources, intl]);
}, [hostSecurity?.checkSources, hostSecurity?.level, intl]);
return (
<YStack
gap="$5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function FloatingIcon() {
return (
<ListItem
onPress={onPress}
icon="SidebarLeftArrowCustom"
icon="MenuCircleHorOutline"
title={intl.formatMessage({ id: ETranslations.setting_floating_icon })}
drillIn
/>
Expand Down
Loading

0 comments on commit 670d037

Please sign in to comment.