diff --git a/app/components/Views/NetworkSelector/NetworkSelector.styles.ts b/app/components/Views/NetworkSelector/NetworkSelector.styles.ts index f04457d2b89..9aece45fafb 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.styles.ts +++ b/app/components/Views/NetworkSelector/NetworkSelector.styles.ts @@ -154,6 +154,28 @@ const createStyles = (colors: Colors) => fontSize: 10, marginTop: 4, }, + screen: { justifyContent: 'flex-end' }, + scrollableDescription: { + maxHeight: Device.getDeviceHeight() * 0.7, + }, + sheet: { + backgroundColor: colors.background.default, + borderTopLeftRadius: 20, + borderTopRightRadius: 20, + }, + title: { + textAlign: 'center', + marginTop: 8, + marginBottom: 8, + }, + notch: { + width: 48, + height: 5, + borderRadius: 4, + backgroundColor: colors.border.default, + marginTop: 8, + alignSelf: 'center', + }, searchContainer: { marginLeft: 16, marginRight: 16, diff --git a/app/components/Views/NetworkSelector/NetworkSelector.test.tsx b/app/components/Views/NetworkSelector/NetworkSelector.test.tsx index 3866801562d..9dc67fcc978 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.test.tsx +++ b/app/components/Views/NetworkSelector/NetworkSelector.test.tsx @@ -540,7 +540,7 @@ describe('Network Selector', () => { it('renders the linea mainnet cell correctly', () => { (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true); const { getByText } = renderComponent(initialState); - const lineaRpcUrl = getByText('https://linea-rpc.publicnode.com'); + const lineaRpcUrl = getByText('linea-rpc.publicnode.com'); const lineaCell = getByText('Linea'); expect(lineaCell).toBeTruthy(); expect(lineaRpcUrl).toBeTruthy(); @@ -572,7 +572,7 @@ describe('Network Selector', () => { it('renders the mainnet cell correctly', () => { (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true); const { getByText } = renderComponent(initialState); - const mainnetRpcUrl = getByText('https://mainnet-rpc.publicnode.com'); + const mainnetRpcUrl = getByText('mainnet-rpc.publicnode.com'); const mainnetCell = getByText('Ethereum Mainnet'); expect(mainnetCell).toBeTruthy(); expect(mainnetRpcUrl).toBeTruthy(); diff --git a/app/components/Views/NetworkSelector/NetworkSelector.tsx b/app/components/Views/NetworkSelector/NetworkSelector.tsx index a0db393144f..6c92a44ca2c 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.tsx +++ b/app/components/Views/NetworkSelector/NetworkSelector.tsx @@ -1,6 +1,7 @@ // Third party dependencies. import { ImageSourcePropType, + KeyboardAvoidingView, Linking, Switch, TouchableOpacity, @@ -12,7 +13,6 @@ import images from 'images/image-icons'; import { useNavigation, useRoute, RouteProp } from '@react-navigation/native'; // External dependencies. -import SheetHeader from '../../../component-library/components/Sheet/SheetHeader'; import Cell, { CellVariant, } from '../../../component-library/components/Cells/Cell'; @@ -93,6 +93,9 @@ import { } from '../../../util/trace'; import { getTraceTags } from '../../../util/sentry/tags'; import { store } from '../../../store'; +import ReusableModal, { ReusableModalRef } from '../../UI/ReusableModal'; +import { useSafeAreaInsets } from 'react-native-safe-area-context'; +import Device from '../../../util/device'; interface infuraNetwork { name: string; @@ -124,9 +127,11 @@ const NetworkSelector = () => { const { trackEvent, createEventBuilder } = useMetrics(); const { colors } = theme; const styles = createStyles(colors); - const sheetRef = useRef(null); + // const sheetRef = useRef(null); + const sheetRef = useRef(null); const showTestNetworks = useSelector(selectShowTestNetworks); const isAllNetworks = useSelector(selectIsAllNetworks); + const safeAreaInsets = useSafeAreaInsets(); const networkConfigurations = useSelector(selectNetworkConfigurations); @@ -147,6 +152,7 @@ const NetworkSelector = () => { networkName: selectedNetworkName, } = useNetworkInfo(origin); + const KEYBOARD_OFFSET = 120; const avatarSize = isNetworkUiRedesignEnabled() ? AvatarSize.Sm : undefined; const modalTitle = isNetworkUiRedesignEnabled() ? 'networks.additional_network_information_title' @@ -279,7 +285,7 @@ const NetworkSelector = () => { } setTokenNetworkFilter(chainId); - sheetRef.current?.onCloseBottomSheet(); + sheetRef.current?.dismissModal(); endTrace({ name: TraceName.SwitchCustomNetwork }); endTrace({ name: TraceName.NetworkSwitch }); trackEvent( @@ -403,7 +409,7 @@ const NetworkSelector = () => { }, 1000); } - sheetRef.current?.onCloseBottomSheet(); + sheetRef.current?.dismissModal(); endTrace({ name: TraceName.SwitchBuiltInNetwork }); endTrace({ name: TraceName.NetworkSwitch }); trackEvent( @@ -463,7 +469,9 @@ const NetworkSelector = () => { variant={CellVariant.SelectWithMenu} title={name} secondaryText={ - rpcEndpoints?.length > 1 ? hideKeyFromUrl(rpcUrl) : undefined + rpcEndpoints?.length > 1 + ? hideProtocolFromUrl(hideKeyFromUrl(rpcUrl)) + : undefined } avatarProps={{ variant: AvatarVariant.Network, @@ -539,7 +547,9 @@ const NetworkSelector = () => { style={styles.networkCell} buttonIcon={IconName.MoreVertical} secondaryText={ - rpcEndpoints?.length > 1 ? hideKeyFromUrl(rpcUrl) : undefined + rpcEndpoints?.length > 1 + ? hideProtocolFromUrl(hideKeyFromUrl(rpcUrl)) + : undefined } buttonProps={{ onButtonClick: () => { @@ -678,10 +688,10 @@ const NetworkSelector = () => { const networkConfiguration = networkConfigurations[chainId]; + const rpcEndpoints = networkConfiguration?.rpcEndpoints; + const rpcUrl = - networkConfiguration?.rpcEndpoints?.[ - networkConfiguration?.defaultRpcEndpointIndex - ].url; + rpcEndpoints?.[networkConfiguration?.defaultRpcEndpointIndex].url; if (isNetworkUiRedesignEnabled() && isNoSearchResults(name)) return null; @@ -690,7 +700,11 @@ const NetworkSelector = () => { 1 + ? hideProtocolFromUrl(hideKeyFromUrl(rpcUrl)) + : undefined + } title={name} avatarProps={{ variant: AvatarVariant.Network, @@ -740,7 +754,7 @@ const NetworkSelector = () => { }; const goToNetworkSettings = () => { - sheetRef.current?.onCloseBottomSheet(() => { + sheetRef.current?.dismissModal(() => { navigate(Routes.ADD_NETWORK, { shouldNetworkSwitchPopToWallet: false, shouldShowPopularNetworks: false, @@ -882,140 +896,146 @@ const NetworkSelector = () => { const renderBottomSheetContent = () => ( <> - - - {isNetworkUiRedesignEnabled() && ( - - - - )} - {isNetworkUiRedesignEnabled() && - searchString.length === 0 && - renderEnabledNetworksTitle()} - {renderMainnet()} - {renderLineaMainnet()} - {renderRpcNetworks()} - {isNetworkUiRedesignEnabled() && - searchString.length === 0 && - renderPopularNetworksTitle()} - {isNetworkUiRedesignEnabled() && renderAdditonalNetworks()} - {searchString.length === 0 && renderTestNetworksSwitch()} - {showTestNetworks && renderOtherNetworks()} - - -