From e11ecf458870196a21bd09965a8ed52818afd1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikolai=20R=C3=B8ed=20Kristiansen?= Date: Mon, 22 Jul 2024 13:25:49 +0200 Subject: [PATCH] replace native-base usage in FormInput --- src/components/FormInput.tsx | 41 +++++++++++++++++++++++++----------- src/modules/login/Login.tsx | 2 +- src/theme.ts | 1 + 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/components/FormInput.tsx b/src/components/FormInput.tsx index be81110..d40eca5 100644 --- a/src/components/FormInput.tsx +++ b/src/components/FormInput.tsx @@ -1,7 +1,9 @@ -import { Input, Text, WarningOutlineIcon, FormControl, IInputProps } from 'native-base'; import React from 'react'; import { Controller, UseControllerProps } from 'react-hook-form'; -import { ReturnKeyTypeOptions } from 'react-native'; +import { ReturnKeyTypeOptions, Text, StyleSheet } from 'react-native'; +import { TextField, TextFieldProps } from 'react-native-ui-lib'; + +import theme from 'src/theme'; type FormInputProps = { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -12,7 +14,7 @@ type FormInputProps = { label: string; rules?: UseControllerProps['rules']; returnKeyType?: ReturnKeyTypeOptions; -} & IInputProps; +} & TextFieldProps; const FormInput = ({ errors, @@ -31,26 +33,41 @@ const FormInput = ({ control={control} rules={rules} render={({ field: { onChange, onBlur, value, ref } }) => ( - - {label} - + - {fieldError && ( - }> - {fieldError.message?.toString()} - - )} - + {fieldError && {fieldError.message?.toString()}} + )} name={name} defaultValue="" /> ); }; + +const styles = StyleSheet.create({ + field: { + borderColor: theme.colors.gray1, + borderWidth: 1, + borderRadius: 4, + padding: 4, + marginVertical: 4, + }, + fieldWithError: { + borderColor: theme.colors.danger, + }, + errorMessage: { + color: theme.colors.danger, + marginBottom: 4, + }, +}); + export default FormInput; diff --git a/src/modules/login/Login.tsx b/src/modules/login/Login.tsx index ca3fcfe..530c60c 100644 --- a/src/modules/login/Login.tsx +++ b/src/modules/login/Login.tsx @@ -19,9 +19,9 @@ const Login = () => {