diff --git a/app/components/Views/NetworkSelector/NetworkSearchTextInput/NetworkSearchTextInput.styles.ts b/app/components/Views/NetworkSelector/NetworkSearchTextInput/NetworkSearchTextInput.styles.ts new file mode 100644 index 00000000000..584db48d9e0 --- /dev/null +++ b/app/components/Views/NetworkSelector/NetworkSearchTextInput/NetworkSearchTextInput.styles.ts @@ -0,0 +1,26 @@ +import { StyleSheet } from 'react-native'; +import { fontStyles } from '../../../../styles/common'; +import { Colors } from '../../../../util/theme/models'; + +const createStyles = (colors: Colors) => + StyleSheet.create({ + inputWrapper: { + flexDirection: 'row', + alignItems: 'center', + paddingHorizontal: 10, + paddingVertical: 10, + borderRadius: 5, + borderWidth: 1, + borderColor: colors.border.default, + color: colors.text.default, + }, + input: { + flex: 1, + fontSize: 14, + color: colors.text.default, + ...fontStyles.normal, + paddingLeft: 10, + }, + }); + +export default createStyles; diff --git a/app/components/Views/NetworkSelector/NetworkSearchTextInput/NetworkSearchTextInput.tsx b/app/components/Views/NetworkSelector/NetworkSearchTextInput/NetworkSearchTextInput.tsx new file mode 100644 index 00000000000..fca39434c03 --- /dev/null +++ b/app/components/Views/NetworkSelector/NetworkSearchTextInput/NetworkSearchTextInput.tsx @@ -0,0 +1,54 @@ +// Third party dependencies. +import React from 'react'; +import { TextInput, View } from 'react-native'; + +// External dependencies. +import { strings } from '../../../../../locales/i18n'; +import { mockTheme, useTheme } from '../../../../util/theme'; + +// Internal dependencies +import Icon from 'react-native-vector-icons/Ionicons'; +import createStyles from './NetworkSearchTextInput.styles'; +import { NetworksViewSelectorsIDs } from '../../../../../e2e/selectors/Settings/NetworksView.selectors'; + +interface NetworkSearchTextInputProps { + searchString: string; + handleSearchTextChange: (text: string) => void; + clearSearchInput: () => void; + testIdSearchInput: string; + testIdCloseIcon: string; +} +function NetworkSearchTextInput({ + searchString, + handleSearchTextChange, + clearSearchInput, +}: NetworkSearchTextInputProps) { + const theme = useTheme(); + const { colors } = theme; + const styles = createStyles(colors || mockTheme.colors); + + return ( + + + + {searchString.length > 0 && ( + + )} + + ); +} + +export default NetworkSearchTextInput; diff --git a/app/components/Views/NetworkSelector/NetworkSearchTextInput/index.tsx b/app/components/Views/NetworkSelector/NetworkSearchTextInput/index.tsx new file mode 100644 index 00000000000..ea682ef3709 --- /dev/null +++ b/app/components/Views/NetworkSelector/NetworkSearchTextInput/index.tsx @@ -0,0 +1 @@ +export { default } from './NetworkSearchTextInput'; diff --git a/app/components/Views/NetworkSelector/NetworkSelector.styles.ts b/app/components/Views/NetworkSelector/NetworkSelector.styles.ts index 0203932530d..d50923576c1 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.styles.ts +++ b/app/components/Views/NetworkSelector/NetworkSelector.styles.ts @@ -3,13 +3,13 @@ import Device from '../../../util/device'; import { StyleSheet } from 'react-native'; import { fontStyles } from '../../../styles/common'; import { isNetworkUiRedesignEnabled } from '../../../util/networks'; +import { Colors } from '../../../util/theme/models'; + /** * Style sheet function for NetworkSelector screen. * @returns StyleSheet object. */ -// TODO: Replace "any" with type -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const createStyles = (colors: any) => +const createStyles = (colors: Colors) => StyleSheet.create({ addNetworkButton: { marginHorizontal: 16, @@ -97,6 +97,11 @@ const createStyles = (colors: any) => fontSize: 10, marginTop: 4, }, + searchContainer: { + marginLeft: 16, + marginRight: 16, + marginBottom: 8, + }, }); export default createStyles; diff --git a/app/components/Views/NetworkSelector/NetworkSelector.tsx b/app/components/Views/NetworkSelector/NetworkSelector.tsx index d0a6bc36d98..d508c671c2c 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.tsx +++ b/app/components/Views/NetworkSelector/NetworkSelector.tsx @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ // Third party dependencies. import React, { useRef, useState } from 'react'; -import { Linking, Switch, TextInput, View } from 'react-native'; +import { Linking, Switch, View } from 'react-native'; import { ScrollView } from 'react-native-gesture-handler'; import images from 'images/image-icons'; import { useNavigation } from '@react-navigation/native'; @@ -65,9 +65,9 @@ import { TESTNET_TICKER_SYMBOLS } from '@metamask/controller-utils'; import InfoModal from '../../../../app/components/UI/Swaps/components/InfoModal'; import hideKeyFromUrl from '../../../util/hideKeyFromUrl'; import CustomNetwork from '../Settings/NetworksSettings/NetworkSettings/CustomNetworkView/CustomNetwork'; -import { NetworksViewSelectorsIDs } from '../../../../e2e/selectors/Settings/NetworksView.selectors'; +import { NetworksSelectorSelectorsIDs } from '../../../../e2e/selectors/Settings/NetworksView.selectors'; import { PopularList } from '../../../util/networks/customNetworks'; -import Icon from 'react-native-vector-icons/Ionicons'; +import NetworkSearchTextInput from './NetworkSearchTextInput'; const NetworkSelector = () => { const [showPopularNetworkModal, setShowPopularNetworkModal] = useState(false); @@ -86,6 +86,9 @@ const NetworkSelector = () => { const networkConfigurations = useSelector(selectNetworkConfigurations); const avatarSize = isNetworkUiRedesignEnabled ? AvatarSize.Sm : undefined; + const buttonLabelAddNetwork = isNetworkUiRedesignEnabled + ? 'app_settings.network_add_custom_network' + : 'app_settings.network_add_network'; // The only possible value types are mainnet, linea-mainnet, sepolia and linea-sepolia const onNetworkChange = (type: string) => { @@ -147,7 +150,6 @@ const NetworkSelector = () => { } }; - // TODO: type the any below to import { Network } from './CustomNetwork.types'; // TODO: Replace "any" with type // eslint-disable-next-line @typescript-eslint/no-explicit-any const showNetworkModal = (networkConfiguration: any) => { @@ -306,6 +308,7 @@ const NetworkSelector = () => { sheetRef.current?.onCloseBottomSheet(() => { navigate(Routes.ADD_NETWORK, { shouldNetworkSwitchPopToWallet: false, + shouldShowPopularNetworks: false, }); }); }; @@ -381,25 +384,16 @@ const NetworkSelector = () => { {isNetworkUiRedesignEnabled && ( - - - + - {searchString.length > 0 && ( - - )} )} {isNetworkUiRedesignEnabled && @@ -418,7 +412,7 @@ const NetworkSelector = () => {