Skip to content

Commit

Permalink
fix: hide the shortcuts entry outside of the desktop scenario & add s…
Browse files Browse the repository at this point in the history
…howPaginationButton props on banner & fix dismiss i18n text (OK-33947) (#6221)
  • Loading branch information
huhuanming authored Nov 19, 2024
1 parent 670b65a commit e93ce6b
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 30 deletions.
7 changes: 6 additions & 1 deletion packages/components/src/actions/Alert/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { cloneElement, useCallback, useContext, useState } from 'react';

import { useIntl } from 'react-intl';
import { StyleSheet } from 'react-native';
import { createStyledContext, styled } from 'tamagui';

import { ETranslations } from '@onekeyhq/shared/src/locale';

import {
Button,
Icon,
Expand Down Expand Up @@ -130,6 +133,8 @@ export const Alert = AlertFrame.styleable<IAlertProps>((props, ref) => {
onCloseProp?.();
}, [onCloseProp]);

const intl = useIntl();

if (!show) return null;

return (
Expand Down Expand Up @@ -172,7 +177,7 @@ export const Alert = AlertFrame.styleable<IAlertProps>((props, ref) => {
) : null}
{closable ? (
<IconButton
title="Dismiss"
title={intl.formatMessage({ id: ETranslations.explore_dismiss })}
icon="CrossedSmallSolid"
size="small"
variant="tertiary"
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/composite/Banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export function Banner<T extends IBannerData>({
indicatorContainerStyle,
leftIconButtonStyle,
rightIconButtonStyle,
showPaginationButton = false,
...props
}: {
data: T[];
Expand All @@ -108,6 +109,7 @@ export function Banner<T extends IBannerData>({
rightIconButtonStyle?: Omit<IIconButtonProps, 'icon'>;
indicatorContainerStyle?: IStackStyle;
itemTitleContainerStyle?: IStackStyle;
showPaginationButton?: boolean;
size?: 'small' | 'large';
onItemPress: (item: T) => void;
isLoading?: boolean;
Expand All @@ -134,7 +136,7 @@ export function Banner<T extends IBannerData>({
gotToPrevIndex,
}: IRenderPaginationParams) => (
<>
{media.gtMd ? (
{showPaginationButton || media.gtMd ? (
<>
{currentIndex !== 0 ? (
<IconButton
Expand Down Expand Up @@ -202,6 +204,7 @@ export function Banner<T extends IBannerData>({
</>
),
[
showPaginationButton,
media.gtMd,
data,
leftIconButtonStyle,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';

import { AuthenticationType } from 'expo-local-authentication';
import { useIntl } from 'react-intl';
Expand Down
18 changes: 14 additions & 4 deletions packages/kit/src/views/Earn/EarnHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ import {
import { ETranslations } from '@onekeyhq/shared/src/locale';
import { defaultLogger } from '@onekeyhq/shared/src/logger/logger';
import { getPrimaryColor } from '@onekeyhq/shared/src/modules3rdParty/react-native-image-colors';
import platformEnv from '@onekeyhq/shared/src/platformEnv';
import { EModalRoutes, EModalStakingRoutes } from '@onekeyhq/shared/src/routes';
import { openUrlInApp } from '@onekeyhq/shared/src/utils/openUrlUtils';
import {
openUrlExternal,
openUrlInApp,
} from '@onekeyhq/shared/src/utils/openUrlUtils';
import timerUtils from '@onekeyhq/shared/src/utils/timerUtils';
import { EAccountSelectorSceneName } from '@onekeyhq/shared/types';
import type {
Expand Down Expand Up @@ -716,6 +720,7 @@ function BasicEarnHome() {

const onBannerPress = useCallback(
async ({
hrefType,
href,
}: {
imgUrl: string;
Expand Down Expand Up @@ -747,7 +752,11 @@ function BasicEarnHome() {
}
return;
}
openUrlInApp(href);
if (hrefType === 'external') {
openUrlExternal(href);
} else {
openUrlInApp(href);
}
}
},
[account, indexedAccount?.id, navigation],
Expand All @@ -757,6 +766,7 @@ function BasicEarnHome() {
if (earnBanners) {
return earnBanners.length ? (
<Banner
showPaginationButton={!platformEnv.isNative}
height="$36"
$md={{
height: '$28',
Expand All @@ -779,8 +789,8 @@ function BasicEarnHome() {
itemTitleContainerStyle={{
top: 0,
bottom: 0,
right: 0,
left: 20,
right: '$10',
left: '$10',
justifyContent: 'center',
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,17 @@ export const AdvancedSection = () => {

return (
<Section title={intl.formatMessage({ id: ETranslations.global_advanced })}>
<ListItem
onPress={onAlignPrimaryAccount}
icon="RefreshCcwOutline"
title={intl.formatMessage({
id: ETranslations.settings_account_sync_modal_title,
})}
drillIn
/>
{platformEnv.isWeb ? null : (
<ListItem
onPress={onAlignPrimaryAccount}
icon="RefreshCcwOutline"
title={intl.formatMessage({
id: ETranslations.settings_account_sync_modal_title,
})}
drillIn
/>
)}

<ListItem
onPress={onAddCustomNetwork}
icon="GlobusOutline"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ function ListShortcutsItem() {
screen: EModalShortcutsRoutes.ShortcutsPreview,
});
}, [navigation]);
return platformEnv.isNative ? null : (
return platformEnv.isDesktop ? (
<ListItem
onPress={toShortcutsPage}
icon="ShortcutsCustom"
title={intl.formatMessage({ id: ETranslations.settings_shortcuts })}
drillIn
/>
);
) : null;
}

export const ResourceSection = () => {
Expand Down
7 changes: 4 additions & 3 deletions packages/kit/src/views/Setting/pages/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,17 @@ const SocialButtonGroup = () => {
</XStack>
<YStack
jc="center"
py="$4"
p="$4"
ai="center"
userSelect="none"
testID="setting-version"
>
<SizableText color="$textSubdued" onPress={handlePress}>
{versionString}
</SizableText>
{appUpdateInfo.status === EAppUpdateStatus.done ? (
<SizableText color="$textSubdued">
{!appUpdateInfo.latestVersion ||
appUpdateInfo.latestVersion === platformEnv.version ? (
<SizableText color="$textSubdued" textAlign="center">
{intl.formatMessage({ id: ETranslations.update_app_up_to_date })}
</SizableText>
) : null}
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locale/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
"explore.default_wallet_set": "OneKey is your default wallet now.",
"explore.default_wallet_settings": "Default Wallet Settings",
"explore.disconnect": "Disconnect",
"explore.dismiss": "dismiss",
"explore.dismiss": "Dismiss",
"explore.enter_bookmark_name": "Please enter the bookmark name",
"explore.excluded_dapps": "Excluded dApps",
"explore.excluded_dapps_description": "Right-click blank space, select the option below to exclude.",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locale/json/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
"explore.default_wallet_set": "OneKey is your default wallet now.",
"explore.default_wallet_settings": "Default Wallet Settings",
"explore.disconnect": "Disconnect",
"explore.dismiss": "dismiss",
"explore.dismiss": "Dismiss",
"explore.enter_bookmark_name": "Please enter the bookmark name",
"explore.excluded_dapps": "Excluded dApps",
"explore.excluded_dapps_description": "Right-click blank space, select the option below to exclude.",
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/locale/json/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@
"swap_page.alert.no_provider_supports_trade": "没有提供商支持此交易",
"swap_page.alert.not_best_rate": "当前的渠道商未为此交易提供最佳报价。",
"swap_page.alert.require_native_token_content": "部分跨链桥接会收取额外的源链原生代币作为桥接费用",
"swap_page.alert.require_native_token_title": "需要{n} {token}",
"swap_page.alert.require_native_token_title": "需要 {n} {token}",
"swap_page.alert.tax_detected": "代币税由代币项目方收取,而非 OneKey。",
"swap_page.alert.tax_detected_buy": "购买",
"swap_page.alert.tax_detected_sell": "卖出",
Expand Down Expand Up @@ -1854,7 +1854,7 @@
"swap_page.toast.approve_failed_detail": "{token}",
"swap_page.toast.approve_successful": "授权成功",
"swap_page.toast.approve_successful_detail": "{token}",
"swap_page.toast.insufficient_balance_content": "您应至少保留{number} {token} 来支付网络费用。",
"swap_page.toast.insufficient_balance_content": "您应至少保留 {number} {token} 来支付网络费用。",
"swap_page.toast.insufficient_balance_title": "{token} 余额不足",
"swap_page.toast.insufficient_input_amount": "输入金额不足",
"swap_page.toast.swap_failed": "交易失败",
Expand Down
8 changes: 4 additions & 4 deletions packages/shared/src/locale/json/zh_HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -1410,8 +1410,8 @@
"onboarding.enable_bluetooth_help_text": "要繼續進行,需要開啟藍牙。",
"onboarding.finalize_creating_wallet": "建立您的錢包",
"onboarding.finalize_encrypting_data": "加密您的數據",
"onboarding.finalize_generating_accounts": "正在建立您的帳戶",
"onboarding.finalize_ready": "您的錢包現已準備就緒",
"onboarding.finalize_generating_accounts": "正在建立您的帳戶",
"onboarding.finalize_ready": "您的錢包現已準備就緒",
"onboarding.finalize_wallet_setup": "完成錢包設置",
"onboarding.import_recovery_phrase_warning": "安全警告",
"onboarding.import_recovery_phrase_warning_help_text": "為了您的資產安全,避免導入硬件錢包的助記詞,而是使用「連接硬件錢包」以獲得最佳的安全性。",
Expand Down Expand Up @@ -1777,7 +1777,7 @@
"swap_page.alert.no_provider_supports_trade": "沒有渠道商支持該交易。",
"swap_page.alert.not_best_rate": "當前的渠道商未為此交易提供最佳報價。",
"swap_page.alert.require_native_token_content": "部分跨鏈橋會收取額外的來源鏈原生代幣作為橋樑費用",
"swap_page.alert.require_native_token_title": "需要{n} {token}",
"swap_page.alert.require_native_token_title": "需要 {n} {token}",
"swap_page.alert.tax_detected": "代幣稅由代幣項目方收取,而非 OneKey。",
"swap_page.alert.tax_detected_buy": "購買",
"swap_page.alert.tax_detected_sell": "賣出",
Expand Down Expand Up @@ -1854,7 +1854,7 @@
"swap_page.toast.approve_failed_detail": "{token}",
"swap_page.toast.approve_successful": "授權成功",
"swap_page.toast.approve_successful_detail": "{token}",
"swap_page.toast.insufficient_balance_content": "你應該至少保留{number} {token} 來支付網絡費用。",
"swap_page.toast.insufficient_balance_content": "你應該至少保留 {number} {token} 來支付網絡費用。",
"swap_page.toast.insufficient_balance_title": "{token} 餘額不足",
"swap_page.toast.insufficient_input_amount": "輸入金額不足",
"swap_page.toast.swap_failed": "交易失敗",
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/locale/json/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@
"swap_page.alert.no_provider_supports_trade": "沒有供應商支援這此交易",
"swap_page.alert.not_best_rate": "目前的渠道商並未提供這筆交易最佳的報價。",
"swap_page.alert.require_native_token_content": "部分跨鏈橋會收取額外的源鏈原生代幣作為橋樑費用",
"swap_page.alert.require_native_token_title": "需要{n} {token}",
"swap_page.alert.require_native_token_title": "需要 {n} {token}",
"swap_page.alert.tax_detected": "代幣稅由代幣項目方收取,而非 OneKey。",
"swap_page.alert.tax_detected_buy": "購買",
"swap_page.alert.tax_detected_sell": "賣出",
Expand Down Expand Up @@ -1854,7 +1854,7 @@
"swap_page.toast.approve_failed_detail": "{token}",
"swap_page.toast.approve_successful": "授權成功",
"swap_page.toast.approve_successful_detail": "{token}",
"swap_page.toast.insufficient_balance_content": "您應該至少保留{number} {token} 來支付網絡費用。",
"swap_page.toast.insufficient_balance_content": "您應該至少保留 {number} {token} 來支付網絡費用。",
"swap_page.toast.insufficient_balance_title": "{token} 餘額不足",
"swap_page.toast.insufficient_input_amount": "輸入金額不足",
"swap_page.toast.swap_failed": "交換失敗",
Expand Down

0 comments on commit e93ce6b

Please sign in to comment.