diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx new file mode 100644 index 0000000..d055112 --- /dev/null +++ b/src/components/Layout.tsx @@ -0,0 +1,32 @@ +import { Button, Typography } from "@mui/material"; +import React, { PropsWithChildren } from "react"; +import { Container } from "./Container"; +import { ArrowBack } from "@mui/icons-material"; +import { NativeStackNavigationProp } from "@react-navigation/native-stack"; +import { useNavigation } from "@react-navigation/native"; +import { StackParamsList } from "../types"; + +export const Layout: React.FC> = ({ + children, + title, +}) => { + const navigation = + useNavigation>(); + + return ( + + + + {title} + + {children} + + ); +}; diff --git a/src/screens/AddNetwork.tsx b/src/screens/AddNetwork.tsx index e8b1a80..ee0cd68 100644 --- a/src/screens/AddNetwork.tsx +++ b/src/screens/AddNetwork.tsx @@ -29,10 +29,9 @@ import { getInternetCredentials, setInternetCredentials, } from "../utils/key-store"; -import { Button, Divider, Grid, Typography } from "@mui/material"; -import { Container } from "../components/Container"; -import { ArrowBack } from "@mui/icons-material"; +import { Divider, Grid } from "@mui/material"; import { LoadingButton } from "@mui/lab"; +import { Layout } from "../components/Layout"; const ethNetworkDataSchema = z.object({ chainId: z.string().nonempty({ message: EMPTY_FIELD_ERROR }), @@ -214,141 +213,154 @@ const AddNetwork = () => { }, [namespace, reset]); return ( - - - - Add Network - - - - + + + - - + + + ( + <> + onChange(textValue)} + /> + {errors.chainId?.message} + + )} + /> + + + + ( + <> + onChange(textValue)} + /> + + {errors.networkName?.message} + + + )} + /> + + + + ( + <> + onChange(textValue)} + /> + {errors.rpcUrl?.message} + + )} + /> + + + + ( + <> + onChange(textValue)} + /> + + {errors.blockExplorerUrl?.message} + + + )} + /> + + + ( + <> + + {errors.coinType?.message} + + )} + /> + + {namespace === EIP155 ? ( + ( <> onChange(textValue)} /> - {errors.chainId?.message} + { + ( + errors as FieldErrors< + z.infer + > + ).currencySymbol?.message + } )} /> - - - ( - <> - onChange(textValue)} - /> - - {errors.networkName?.message} - - - )} - /> - - - - ( - <> - onChange(textValue)} - /> - {errors.rpcUrl?.message} - - )} - /> - - - - ( - <> - onChange(textValue)} - /> - - {errors.blockExplorerUrl?.message} - - - )} - /> - - - ( - <> - - - {errors.coinType?.message} - - - )} - /> - - {namespace === EIP155 ? ( - + ) : ( + <> + ( <> onChange(textValue)} /> @@ -356,112 +368,82 @@ const AddNetwork = () => { { ( errors as FieldErrors< - z.infer + z.infer > - ).currencySymbol?.message + ).nativeDenom?.message } )} /> - ) : ( - <> - - ( - <> - onChange(textValue)} - /> - - { - ( - errors as FieldErrors< - z.infer - > - ).nativeDenom?.message - } - - - )} - /> - - - ( - <> - onChange(textValue)} - /> - - { - ( - errors as FieldErrors< - z.infer - > - ).addressPrefix?.message - } - - - )} - /> - - - ( - <> - - - { - ( - errors as FieldErrors< - z.infer - > - ).gasPrice?.message - } - - - )} - /> - - - )} - - - {isSubmitting ? "Adding" : "Submit"} - - - + + ( + <> + onChange(textValue)} + /> + + { + ( + errors as FieldErrors< + z.infer + > + ).addressPrefix?.message + } + + + )} + /> + + + ( + <> + + + { + ( + errors as FieldErrors< + z.infer + > + ).gasPrice?.message + } + + + )} + /> + + + )} + + + {isSubmitting ? "Adding" : "Submit"} + + ); }; diff --git a/src/screens/EditNetwork.tsx b/src/screens/EditNetwork.tsx index 2cf11bd..e82482a 100644 --- a/src/screens/EditNetwork.tsx +++ b/src/screens/EditNetwork.tsx @@ -20,10 +20,9 @@ import { EMPTY_FIELD_ERROR, INVALID_URL_ERROR, } from "../utils/constants"; -import { Container } from "../components/Container"; -import { Button, Divider, Grid, Typography } from "@mui/material"; +import { Divider, Grid, Typography } from "@mui/material"; import { LoadingButton } from "@mui/lab"; -import { ArrowBack } from "@mui/icons-material"; +import { Layout } from "../components/Layout"; const ethNetworksFormSchema = z.object({ // Adding type field for resolving typescript error @@ -99,127 +98,114 @@ const EditNetwork = ({ route }: EditNetworkProps) => { const isCosmos = networkData.namespace === COSMOS; return ( - - - - Edit Network + + + Edit {networkData?.networkName} details - - - Edit {networkData?.networkName} details - - - - - ( - <> - onChange(textValue)} - /> - - {errors.networkName?.message} - - - )} - /> - - - ( - <> - onChange(textValue)} - /> - {errors.rpcUrl?.message} - - )} - /> - - - - ( - <> - onChange(textValue)} - /> - - {errors.blockExplorerUrl?.message} - - - )} - /> - - {isCosmos && ( - - ( - <> - - - { - ( - errors as FieldErrors< - z.infer - > - ).gasPrice?.message - } - - - )} - /> - - )} + + + + ( + <> + onChange(textValue)} + /> + + {errors.networkName?.message} + + + )} + /> - - {isSubmitting ? "Adding" : "Submit"} - - - + + ( + <> + onChange(textValue)} + /> + {errors.rpcUrl?.message} + + )} + /> + + + + ( + <> + onChange(textValue)} + /> + + {errors.blockExplorerUrl?.message} + + + )} + /> + + {isCosmos && ( + + ( + <> + + + { + ( + errors as FieldErrors< + z.infer + > + ).gasPrice?.message + } + + + )} + /> + + )} + + + {isSubmitting ? "Adding" : "Submit"} + + ); }; diff --git a/src/screens/SignMessage.tsx b/src/screens/SignMessage.tsx index 267103f..1377128 100644 --- a/src/screens/SignMessage.tsx +++ b/src/screens/SignMessage.tsx @@ -1,22 +1,22 @@ -import React, { useState } from 'react'; -import { View } from 'react-native'; -import { Button, Text, TextInput } from 'react-native-paper'; +import React, { useState } from "react"; +import { Text, TextInput } from "react-native-paper"; +import { Button, Divider, Stack } from "@mui/material"; -import { NativeStackScreenProps } from '@react-navigation/native-stack'; +import { NativeStackScreenProps } from "@react-navigation/native-stack"; -import { StackParamsList } from '../types'; -import styles from '../styles/stylesheet'; -import { signMessage } from '../utils/sign-message'; -import AccountDetails from '../components/AccountDetails'; +import { StackParamsList } from "../types"; +import { signMessage } from "../utils/sign-message"; +import AccountDetails from "../components/AccountDetails"; +import { Layout } from "../components/Layout"; -type SignProps = NativeStackScreenProps; +type SignProps = NativeStackScreenProps; const SignMessage = ({ route }: SignProps) => { const namespace = route.params.selectedNamespace; const chainId = route.params.selectedChainId; const account = route.params.accountInfo; - const [message, setMessage] = useState(''); + const [message, setMessage] = useState(""); const signMessageHandler = async () => { const signedMessage = await signMessage({ @@ -29,31 +29,30 @@ const SignMessage = ({ route }: SignProps) => { }; return ( - - - - - {account && `Account ${account.index + 1}`} - - - - - - + + + {account && `Account ${account.index + 1}`} + + - setMessage(text)} - value={message} - /> + + + setMessage(text)} + value={message} + /> - - - - + + ); };