Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash #5544

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/screens/SettingsSheet/SettingsPages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lang from 'i18n-js';
import * as lang from '@/languages';

import Routes from '@/navigation/routesNames';

Expand All @@ -14,7 +14,7 @@ import NotificationsSection from './components/NotificationsSection';
export const SettingsPages = {
appIcon: {
component: AppIconSection,
getTitle: () => lang.t('settings.app_icon'),
getTitle: () => lang.t(lang.l.settings.app_icon),
key: Routes.SETTINGS_SECTION_APP_ICON,
},
backup: {
Expand All @@ -24,37 +24,37 @@ export const SettingsPages = {
},
currency: {
component: CurrencySection,
getTitle: () => lang.t('settings.currency.title'),
getTitle: () => lang.t(lang.l.settings.currency.title),
key: Routes.SETTINGS_SECTION_CURRENCY,
},
default: {
component: null,
getTitle: () => lang.t('settings.label'),
getTitle: () => lang.t(lang.l.settings.label),
key: Routes.SETTINGS_SECTION,
},
dev: {
component: DevSection,
getTitle: () => lang.t('settings.dev'),
getTitle: () => lang.t(lang.l.settings.developer),
key: Routes.SETTINGS_SECTION_DEV,
},
language: {
component: LanguageSection,
getTitle: () => lang.t('settings.language'),
getTitle: () => lang.t(lang.l.settings.language),
key: Routes.SETTINGS_SECTION_LANGUAGE,
},
network: {
component: NetworkSection,
getTitle: () => lang.t('settings.network'),
getTitle: () => lang.t(lang.l.settings.network),
key: Routes.SETTINGS_SECTION_NETWORK,
},
notifications: {
component: NotificationsSection,
getTitle: () => lang.t('settings.notifications'),
getTitle: () => lang.t(lang.l.settings.notifications),
key: Routes.SETTINGS_SECTION_NOTIFICATIONS,
},
privacy: {
component: PrivacySection,
getTitle: () => lang.t('settings.privacy'),
getTitle: () => lang.t(lang.l.settings.privacy),
key: Routes.SETTINGS_SECTION_PRIVACY,
},
};
69 changes: 27 additions & 42 deletions src/screens/SettingsSheet/components/CurrencySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,34 @@ const CurrencySection = () => {
);

return (
<BackgroundProvider color="surfaceSecondary">
{({ backgroundColor }) => (
<SimpleSheet backgroundColor={backgroundColor as string}>
<Inset top="20px" horizontal="20px" bottom="60px">
<Inline alignHorizontal="center" alignVertical="center">
<Box paddingBottom="12px">
<Text size="22pt" weight="heavy" color="label">
{i18n.t(i18n.l.settings.currency.title)}
</Text>
</Box>
</Inline>
<MenuContainer>
<Menu>
{currencyListItems.map(({ label, emojiName, currency }: any) => (
<MenuItem
key={currency}
leftComponent={
emojiName ? (
<MenuItem.TextIcon icon={(emoji.get('flag_' + emojiName) as string) || ''} isEmoji />
) : (
<View style={{ marginLeft: 7 }}>
<RainbowCoinIcon
icon={currency === ETH?.symbol ? ETH?.icon_url : WBTC?.icon_url}
size={23}
symbol={currency}
network={Network.mainnet}
theme={theme}
/>
</View>
)
}
onPress={() => onSelectCurrency(currency)}
rightComponent={currency === nativeCurrency && <MenuItem.StatusIcon status="selected" />}
size={52}
titleComponent={<MenuItem.Title text={label} />}
<MenuContainer>
<Menu>
{currencyListItems.map(({ label, emojiName, currency }: any) => (
<MenuItem
key={currency}
leftComponent={
emojiName ? (
<MenuItem.TextIcon icon={(emoji.get('flag_' + emojiName) as string) || ''} isEmoji />
) : (
<View style={{ marginLeft: 7 }}>
<RainbowCoinIcon
icon={currency === ETH?.symbol ? ETH?.icon_url : WBTC?.icon_url}
size={23}
symbol={currency}
network={Network.mainnet}
theme={theme}
/>
))}
</Menu>
</MenuContainer>
</Inset>
</SimpleSheet>
)}
</BackgroundProvider>
</View>
)
}
onPress={() => onSelectCurrency(currency)}
rightComponent={currency === nativeCurrency && <MenuItem.StatusIcon status="selected" />}
size={52}
titleComponent={<MenuItem.Title text={label} />}
/>
))}
</Menu>
</MenuContainer>
);
};

Expand Down
36 changes: 17 additions & 19 deletions src/screens/SettingsSheet/components/SettingsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import lang from 'i18n-js';
import * as lang from '@/languages';
import React, { useCallback, useMemo } from 'react';
import { Linking, Share } from 'react-native';
import { ContextMenuButton, MenuActionConfig } from 'react-native-ios-context-menu';
import { supportedLanguages } from '../../../languages';
import { AppVersionStamp } from '@/components/AppVersionStamp';
import Menu from './Menu';
import MenuContainer from './MenuContainer';
Expand All @@ -17,8 +16,6 @@ import DarkModeIcon from '@/assets/settingsDarkMode.png';
import DarkModeIconDark from '@/assets/settingsDarkModeDark.png';
import LanguageIcon from '@/assets/settingsLanguage.png';
import LanguageIconDark from '@/assets/settingsLanguageDark.png';
import NetworkIcon from '@/assets/settingsNetwork.png';
import NetworkIconDark from '@/assets/settingsNetworkDark.png';
import NotificationsIcon from '@/assets/settingsNotifications.png';
import NotificationsIconDark from '@/assets/settingsNotificationsDark.png';
import PrivacyIcon from '@/assets/settingsPrivacy.png';
Expand All @@ -29,7 +26,6 @@ import { useAccountSettings, useSendFeedback, useWallets } from '@/hooks';
import { Themes, useTheme } from '@/theme';
import { showActionSheetWithOptions } from '@/utils';
import { buildRainbowLearnUrl, LearnUTMCampaign } from '@/utils/buildRainbowUrl';
import { getNetworkObj } from '@/networks';
import { handleReviewPromptAction } from '@/utils/reviewAlert';
import { ReviewPromptAction } from '@/storage/schema';

Expand Down Expand Up @@ -207,7 +203,7 @@ const SettingsSection = ({
rightComponent={<MenuItem.StatusIcon status={allBackedUp ? 'complete' : areBackedUp ? 'incomplete' : 'warning'} />}
size={60}
testID="backup-section"
titleComponent={<MenuItem.Title text={lang.t('settings.backup')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.backup)} />}
/>
)}
{isNotificationsEnabled && (
Expand All @@ -216,7 +212,7 @@ const SettingsSection = ({
leftComponent={<MenuItem.ImageIcon source={isDarkMode ? NotificationsIconDark : NotificationsIcon} />}
onPress={onPressNotifications}
size={60}
titleComponent={<MenuItem.Title text={lang.t('settings.notifications')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.notifications)} />}
/>
)}
<MenuItem
Expand All @@ -226,7 +222,7 @@ const SettingsSection = ({
rightComponent={<MenuItem.Selection>{nativeCurrency || ''}</MenuItem.Selection>}
size={60}
testID="currency-section"
titleComponent={<MenuItem.Title text={lang.t('settings.currency')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.currency.title)} />}
/>
{/* {(testnetsEnabled || IS_DEV) && (
<MenuItem
Expand Down Expand Up @@ -264,7 +260,7 @@ const SettingsSection = ({
rightComponent={<MenuItem.Selection>{colorScheme ? capitalizeFirstLetter(colorScheme) : ''}</MenuItem.Selection>}
size={60}
testID={`theme-section-${isDarkMode ? 'dark' : 'light'}`}
titleComponent={<MenuItem.Title text={lang.t('settings.theme')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.theme)} />}
/>
</ContextMenuButton>

Expand All @@ -275,17 +271,17 @@ const SettingsSection = ({
onPress={onPressPrivacy}
size={60}
testID="privacy"
titleComponent={<MenuItem.Title text={lang.t('settings.privacy')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.privacy)} />}
/>
)}
{isLanguageSelectionEnabled && (
<MenuItem
hasRightArrow
leftComponent={<MenuItem.ImageIcon source={isDarkMode ? LanguageIconDark : LanguageIcon} />}
onPress={onPressLanguage}
rightComponent={<MenuItem.Selection>{(supportedLanguages as any)[language].label || ''}</MenuItem.Selection>}
rightComponent={<MenuItem.Selection>{(lang.supportedLanguages as any)[language].label || ''}</MenuItem.Selection>}
size={60}
titleComponent={<MenuItem.Title text={lang.t('settings.language')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.language)} />}
/>
)}
<MenuItem
Expand All @@ -294,7 +290,7 @@ const SettingsSection = ({
onPress={onPressAppIcon}
size={60}
testID="app-icon-section"
titleComponent={<MenuItem.Title text={lang.t('settings.app_icon')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.app_icon)} />}
/>
</Menu>
<Menu>
Expand All @@ -303,42 +299,44 @@ const SettingsSection = ({
onPress={onPressShare}
size={52}
testID="share-section"
titleComponent={<MenuItem.Title text={lang.t('settings.share_rainbow')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.share_rainbow)} />}
/>
<MenuItem
leftComponent={<MenuItem.TextIcon icon="🧠" isEmoji />}
onPress={onPressLearn}
size={52}
testID="learn-section"
titleComponent={<MenuItem.Title text={lang.t('settings.learn')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.learn)} />}
/>
<MenuItem
leftComponent={<MenuItem.TextIcon icon="🐦" isEmoji />}
onPress={onPressTwitter}
size={52}
testID="twitter-section"
titleComponent={<MenuItem.Title text={lang.t('settings.follow_us_on_twitter')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.follow_us_on_twitter)} />}
/>
<MenuItem
leftComponent={<MenuItem.TextIcon icon="💬" isEmoji />}
onPress={onSendFeedback}
size={52}
testID="feedback-section"
titleComponent={<MenuItem.Title text={lang.t(ios ? 'settings.feedback_and_support' : 'settings.feedback_and_reports')} />}
titleComponent={
<MenuItem.Title text={ios ? lang.t(lang.l.settings.feedback_and_support) : lang.t(lang.l.settings.feedback_and_support)} />
}
/>
<MenuItem
leftComponent={<MenuItem.TextIcon icon="❤️" isEmoji />}
onPress={onPressReview}
size={52}
testID="review-section"
titleComponent={<MenuItem.Title text={lang.t('settings.review')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.review)} />}
/>
<MenuItem
leftComponent={<MenuItem.TextIcon icon={ios ? '🚧' : '🐞'} isEmoji />}
onPress={onPressDev}
size={52}
testID="developer-section"
titleComponent={<MenuItem.Title text={lang.t('settings.developer')} />}
titleComponent={<MenuItem.Title text={lang.t(lang.l.settings.developer)} />}
/>
</Menu>
</MenuContainer>
Expand Down