Skip to content

Commit

Permalink
Merge branch 'main' into ci/bitrise-message-check
Browse files Browse the repository at this point in the history
  • Loading branch information
Cal-L authored Feb 27, 2024
2 parents 6b46801 + b536b96 commit ab8385f
Show file tree
Hide file tree
Showing 43 changed files with 836 additions and 176 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Third party dependencies.
import { StyleSheet, TextStyle, ViewStyle } from 'react-native';
import { StyleSheet, ViewStyle } from 'react-native';

// External dependencies.
import { colors } from '../../../../../../styles/common';
Expand All @@ -24,10 +24,7 @@ const styleSheet = (params: { vars: ButtonLinkStyleSheetVars }) => {
{ backgroundColor: colors.transparent },
style,
) as ViewStyle,
pressedText: Object.assign(
{ textDecorationLine: 'underline' } as TextStyle,
style,
) as TextStyle,
pressedText: { textDecorationLine: 'underline' },
});
};

Expand Down
14 changes: 14 additions & 0 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import URL from 'url-parse';
import Logger from '../../../util/Logger';
import { getDecimalChainId } from '../../../util/networks';
import { useMetrics } from '../../../components/hooks/useMetrics';
import DeprecatedNetworkDetails from '../../UI/DeprecatedNetworkModal';

const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
Expand Down Expand Up @@ -624,6 +625,19 @@ const MainNavigator = () => (
}),
}}
/>
<Stack.Screen
name={Routes.DEPRECATED_NETWORK_DETAILS}
component={DeprecatedNetworkDetails}
options={{
//Refer to - https://reactnavigation.org/docs/stack-navigator/#animations
cardStyle: { backgroundColor: importedColors.transparent },
cardStyleInterpolator: () => ({
overlayStyle: {
opacity: 0,
},
}),
}}
/>
<Stack.Screen name="Home" component={HomeTabs} />
<Stack.Screen name="Asset" component={AssetModalFlow} />
<Stack.Screen name="Webview" component={Webview} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Device from '../../../util/device';
import { StyleSheet, TextStyle } from 'react-native';
import { Theme } from '../../../util/theme/models';

const styleSheet = (params: { theme: Theme }) => {
const { theme } = params;
const { typography } = theme;

return StyleSheet.create({
centeredTitle: {
marginTop: 16,
marginBottom: 8,
fontSize: 18,
textAlign: 'center',
},
centeredDescription: {
fontSize: 14,
textAlign: 'center',
paddingRight: 16,
paddingLeft: 16,
},
footer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
button: {
flex: 1,
marginLeft: 16,
marginRight: 16,
marginTop: 24,
marginBottom: Device.isAndroid() ? 21 : 0,
},
buttonLabel: {
...typography.lBodySMMedium,
} as TextStyle,
});
};

export default styleSheet;
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { useNavigation } from '@react-navigation/native';
import React, { useRef } from 'react';
import { Linking, View } from 'react-native';
import { useStyles } from '../../../component-library/hooks';
import { strings } from '../../../../locales/i18n';
import styleSheet from './DeprecatedNetworkModal.styles';
import Text, {
TextColor,
TextVariant,
} from '../../../component-library/components/Texts/Text';
import Button, {
ButtonSize,
ButtonVariants,
} from '../../../component-library/components/Buttons/Button';
import { CONNECTING_TO_DEPRECATED_NETWORK } from '../../../constants/urls';
import BottomSheet from '../../../component-library/components/BottomSheets/BottomSheet';
import { useMetrics } from '../../../components/hooks/useMetrics';
import { MetaMetricsEvents } from '../../../core/Analytics';

const DeprecatedNetworkModal = () => {
const { styles } = useStyles(styleSheet, {});
const { trackEvent } = useMetrics();
const navigation = useNavigation();

const dismissModal = (): void => {
navigation.goBack();
};

const goToLearnMore = () => {
Linking.openURL(CONNECTING_TO_DEPRECATED_NETWORK);
trackEvent(MetaMetricsEvents.EXTERNAL_LINK_CLICKED, {
location: 'dapp_connection_request',
text: 'Learn More',
url_domain: CONNECTING_TO_DEPRECATED_NETWORK,
});
};

const sheetRef = useRef(null);

return (
<BottomSheet ref={sheetRef}>
<Text variant={TextVariant.HeadingMD} style={styles.centeredTitle}>
{strings('networks.network_deprecated_title')}
</Text>
<Text variant={TextVariant.BodyMD} style={styles.centeredDescription}>
{strings('networks.network_deprecated_description')}{' '}
<Text color={TextColor.Info} onPress={goToLearnMore}>
{strings('accounts.learn_more')}
</Text>
</Text>
<View style={{ ...styles.footer }}>
<Button
variant={ButtonVariants.Primary}
size={ButtonSize.Lg}
onPress={dismissModal}
style={styles.button}
label={
<Text
variant={TextVariant.BodyMD}
color={TextColor.Default}
style={styles.buttonLabel}
>
{strings('network_information.got_it')}
</Text>
}
/>
</View>
</BottomSheet>
);
};

export default DeprecatedNetworkModal;
1 change: 1 addition & 0 deletions app/components/UI/DeprecatedNetworkModal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './DeprecatedNetworkModal';
27 changes: 16 additions & 11 deletions app/components/UI/NetworkModal/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,32 @@ exports[`NetworkDetails renders correctly 1`] = `
<View
style={
Object {
"backgroundColor": "#FFFFFF",
"alignItems": "center",
"backgroundColor": "#F2F4F6",
"borderRadius": 8,
"borderWidth": 1,
"height": 16,
"justifyContent": "center",
"overflow": "hidden",
"width": 16,
}
}
>
<Image
onError={[Function]}
resizeMode="contain"
source="image"
<Text
accessibilityRole="text"
style={
Object {
"flex": 1,
"height": undefined,
"width": undefined,
"color": "#24272A",
"fontFamily": "Euclid Circular B",
"fontSize": 10,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": undefined,
}
}
testID="network-avatar-image"
/>
>
T
</Text>
</View>
<Text
accessibilityRole="text"
Expand Down Expand Up @@ -420,7 +425,7 @@ exports[`NetworkDetails renders correctly 1`] = `
}
}
>
https://localhost:8545
https:/
</Text>
<TouchableOpacity
activeOpacity={0.5}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react/prop-types */
import React, { useCallback, useEffect, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { View, Linking } from 'react-native';
import { strings } from '../../../../locales/i18n';
import { CommonSelectorsIDs } from '../../../../e2e/selectors/Common.selectors';
Expand Down Expand Up @@ -28,8 +28,12 @@ import BottomSheetFooter, {
ButtonsAlignment,
} from '../../../component-library/components/BottomSheets/BottomSheetFooter';
import BottomSheetHeader from '../../../component-library/components/BottomSheets/BottomSheetHeader';
import { toggleUseSafeChainsListValidation } from '../../../util/networks';
import {
getNetworkImageSource,
toggleUseSafeChainsListValidation,
} from '../../../util/networks';
import { NetworkApprovalModalSelectorsIDs } from '../../../../e2e/selectors/Modals/NetworkApprovalModal.selectors';
import hideKeyFromUrl from '../../../util/hideKeyFromUrl';

interface Alert {
alertError: string;
Expand Down Expand Up @@ -67,6 +71,15 @@ const NetworkVerificationInfo = ({

useEffect(() => setAlerts(alertsFromProps), [alertsFromProps]);

const networkImageSource = useMemo(
() =>
//@ts-expect-error - The utils/network file is still JS and this function expects a networkType, and should be optional
getNetworkImageSource({
chainId: customNetworkInformation.chainId,
}),
[customNetworkInformation],
);

const renderNetworkInfo = () => (
<ScrollView
nestedScrollEnabled
Expand Down Expand Up @@ -98,7 +111,9 @@ const NetworkVerificationInfo = ({
<Text variant={TextVariant.BodyMDBold}>
{strings('add_custom_network.network_url')}
</Text>
<Text style={styles.textSection}>{customNetworkInformation.rpcUrl}</Text>
<Text style={styles.textSection}>
{hideKeyFromUrl(customNetworkInformation.rpcUrl)}
</Text>

<Accordion
title={strings('spend_limit_edition.view_details')}
Expand Down Expand Up @@ -149,6 +164,7 @@ const NetworkVerificationInfo = ({
const renderAlerts = useCallback(() => {
if (!safeChainsListValidationEnabled) return null;
if (!alerts.length) return null;

return alerts.map(
(
networkAlert: {
Expand Down Expand Up @@ -229,7 +245,7 @@ const NetworkVerificationInfo = ({
</BottomSheetHeader>
<ScrollView style={styles.root}>
<PickerNetwork
imageSource={customNetworkInformation.icon}
imageSource={networkImageSource}
label={customNetworkInformation.chainName}
style={styles.networkSection}
disabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,32 @@ exports[`NetworkVerificationInfo renders correctly 1`] = `
<View
style={
Object {
"backgroundColor": "#FFFFFF",
"alignItems": "center",
"backgroundColor": "#F2F4F6",
"borderRadius": 8,
"borderWidth": 1,
"height": 16,
"justifyContent": "center",
"overflow": "hidden",
"width": 16,
}
}
>
<Image
onError={[Function]}
resizeMode="contain"
source="test-icon"
<Text
accessibilityRole="text"
style={
Object {
"flex": 1,
"height": undefined,
"width": undefined,
"color": "#24272A",
"fontFamily": "Euclid Circular B",
"fontSize": 10,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": undefined,
}
}
testID="network-avatar-image"
/>
>
T
</Text>
</View>
<Text
accessibilityRole="text"
Expand Down Expand Up @@ -379,7 +384,7 @@ exports[`NetworkVerificationInfo renders correctly 1`] = `
}
}
>
http://test.com
http:/
</Text>
<TouchableOpacity
activeOpacity={0.5}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1062,27 +1062,32 @@ exports[`NetworkSwitcher View renders and dismisses network modal when pressing
<View
style={
Object {
"backgroundColor": "#FFFFFF",
"alignItems": "center",
"backgroundColor": "#F2F4F6",
"borderRadius": 8,
"borderWidth": 1,
"height": 16,
"justifyContent": "center",
"overflow": "hidden",
"width": 16,
}
}
>
<Image
onError={[Function]}
resizeMode="contain"
source="https://static.metafi.codefi.network/api/v1/tokenIcons/42220/0x471ece3750da237f93b8e339c536989b8978a438.png"
<Text
accessibilityRole="text"
style={
Object {
"flex": 1,
"height": undefined,
"width": undefined,
"color": "#24272A",
"fontFamily": "Euclid Circular B",
"fontSize": 10,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": undefined,
}
}
testID="network-avatar-image"
/>
>
C
</Text>
</View>
<Text
accessibilityRole="text"
Expand Down Expand Up @@ -1248,7 +1253,7 @@ exports[`NetworkSwitcher View renders and dismisses network modal when pressing
}
}
>
https://evm.cronos.org
https:/
</Text>
<TouchableOpacity
activeOpacity={0.5}
Expand Down
Loading

0 comments on commit ab8385f

Please sign in to comment.