1- import React , { FC , FormEvent , useRef } from 'react' ;
1+ import React , { FC , FormEvent } from 'react' ;
22import {
33 GestureResponderEvent ,
44 KeyboardAvoidingView ,
55 NativeSyntheticEvent ,
66 Platform ,
7- StyleSheet ,
87 Text ,
98 TextInput ,
109 TextInputSubmitEditingEventData
@@ -27,27 +26,16 @@ const loginSchema = Yup.object().shape({
2726 password : Yup . string ( ) . required ( 'Password is required' )
2827} ) ;
2928
30- const styles = StyleSheet . create ( {
31- errorInput : {
32- color : 'red' ,
33- fontSize : 12 ,
34- marginLeft : 16
35- } ,
36- fbLoginButton : {
37- height : 45 ,
38- marginTop : 10 ,
39- backgroundColor : 'transparent'
40- } ,
41- loginButton : {
42- borderRadius : 5 ,
29+ const FBLoginButton = styled ( Button ) . attrs ( {
30+ buttonStyle : {
31+ backgroundColor : 'transparent' ,
4332 height : 45 ,
44- marginTop : 10 ,
45- backgroundColor : colors . lightBlue
33+ marginTop : 10
4634 } ,
47- signUp : {
48- textAlign : 'center'
35+ titleStyle : {
36+ color : colors . lightBlue
4937 }
50- } ) ;
38+ } ) `` ;
5139
5240const KeyboardAvoidingViewStyled = styled ( ( { ...rest } ) => (
5341 < KeyboardAvoidingView { ...rest } />
@@ -57,6 +45,14 @@ const KeyboardAvoidingViewStyled = styled(({ ...rest }) => (
5745 width: ${ Platform . OS == 'web' ? '100%' : '75%' } ;
5846` ;
5947
48+ const LoginButton = styled ( Button ) . attrs ( {
49+ buttonStyle : {
50+ borderRadius : 5 ,
51+ height : 45 ,
52+ marginTop : 10
53+ }
54+ } ) `` ;
55+
6056const LoginFormView = styled . View `
6157 flex: 1;
6258 height: 2000px;
@@ -71,7 +67,11 @@ const LogoText = styled.Text`
7167 text-align: center;
7268` ;
7369
74- const SignUpText = styled (
70+ const SignUpText = styled . Text `
71+ text-align: center;
72+ ` ;
73+
74+ const SignUpTextNav = styled (
7575 ( { navigation, ...rest } : SignUpButtonProps ) : JSX . Element => {
7676 const router = useRouter ( ) ;
7777 return (
@@ -93,29 +93,32 @@ const SignUpText = styled(
9393 color: ${ colors . lightBlue } ;
9494` ;
9595
96+ const StyledErrorText = styled . Text `
97+ color: red;
98+ font-size: 12px;
99+ margin-left: 16px;
100+ ` ;
101+
96102const TextLoginInputField = styled (
97103 ( {
98104 touched,
99105 error,
100106 ...rest
101- } : TextInputProps & TouchedProps & ErrorProps ) : JSX . Element => {
102- const passwordInput = useRef < TextInput > ( null ) ;
103-
104- return (
105- < >
106- < TextInput
107- accessible
108- accessibilityLabel = "textinput"
109- autoCapitalize = "none"
110- ref = { passwordInput }
111- { ...rest }
112- />
113- { touched && error ? (
114- < Text style = { styles . errorInput } > { error } </ Text >
115- ) : null }
116- </ >
117- ) ;
118- }
107+ } : TextInputProps & TouchedProps & ErrorProps ) : JSX . Element => (
108+ < >
109+ < TextInput
110+ accessible
111+ accessibilityLabel = "textinput"
112+ autoCapitalize = "none"
113+ { ...rest }
114+ />
115+ { touched && error ? (
116+ < >
117+ < StyledErrorText > { error } </ StyledErrorText >
118+ </ >
119+ ) : null }
120+ </ >
121+ )
119122) `
120123 font-size: 14px;
121124 border-radius: 5px;
@@ -232,8 +235,8 @@ const Login: FC<LoginProps> = ({ navigation }): JSX.Element => (
232235 touched = { touched . password }
233236 value = { values . password }
234237 />
235- < Button
236- buttonStyle = { [ styles . loginButton ] }
238+ < LoginButton
239+ // buttonStyle={[styles.loginButton]}
237240 onPress = { ( event : GestureResponderEvent ) : void => {
238241 handleSubmit (
239242 ( event as unknown ) as FormEvent < HTMLFormElement >
@@ -244,15 +247,18 @@ const Login: FC<LoginProps> = ({ navigation }): JSX.Element => (
244247 </ >
245248 ) }
246249 </ Formik >
247- < Button
248- buttonStyle = { [ styles . fbLoginButton ] }
249- titleStyle = { { color : colors . lightBlue } }
250+ < FBLoginButton
251+ // buttonStyle={[styles.fbLoginButton]}
252+ // titleStyle={{ color: colors.lightBlue }}
253+ onPress = { ( event : GestureResponderEvent ) : void => {
254+ console . log ( event ) ;
255+ } }
250256 title = "Login with Facebook"
251257 />
252- < Text style = { styles . signUp } >
258+ < SignUpText >
253259 Don't have an account?{ ' ' }
254- < SignUpText navigation = { navigation } > Sign up here</ SignUpText > .
255- </ Text >
260+ < SignUpTextNav navigation = { navigation } > Sign up here</ SignUpTextNav > .
261+ </ SignUpText >
256262 </ LoginFormView >
257263 </ KeyboardAvoidingViewStyled >
258264 </ >
0 commit comments