11import React , { useState , useContext } from 'react' ;
2- import { TextInput , Text , StyleSheet } from 'react-native' ;
2+ import { TextInput , Text , StyleSheet , Modal , Alert , Pressable , View } from 'react-native' ;
33import { Context as AuthContext } from 'src/components/context/AuthContext' ;
44import tw from 'twrnc' ;
55
@@ -9,7 +9,7 @@ import CheckBox from './CheckBox';
99interface LoginFieldProps {
1010 errorMessage : string ;
1111 submitButtonText : string ;
12- onSubmit : ( { email, password, staySignedin } ) => void ;
12+ onSubmit : ( { email, password} ) => void ;
1313 style ?: StyleSheet . NamedStyles < any > ;
1414}
1515
@@ -22,6 +22,7 @@ const AuthForm: React.FC<LoginFieldProps> = ({
2222 const [ email , setEmail ] = useState < string > ( '' ) ;
2323 const [ password , setPassword ] = useState < string > ( '' ) ;
2424 const [ staySignedIn , setStaySignedIn ] = useState < boolean > ( false )
25+ const [ modalVisible , setModalVisible ] = useState ( false ) ;
2526
2627 const { signin } = useContext ( AuthContext ) ;
2728
@@ -33,6 +34,14 @@ const AuthForm: React.FC<LoginFieldProps> = ({
3334 }
3435 } ;
3536
37+ const handleStaySignInToggle = ( ) => {
38+ if ( staySignedIn ) {
39+ setStaySignedIn ( false )
40+ } else {
41+ setStaySignedIn ( true )
42+ setModalVisible ( true )
43+ }
44+ }
3645 return (
3746 < >
3847 < TextInput
@@ -53,7 +62,7 @@ const AuthForm: React.FC<LoginFieldProps> = ({
5362 onChangeText = { setPassword }
5463 />
5564 < CheckBox
56- onPress = { ( ) => setStaySignedIn ( ! staySignedIn ) }
65+ onPress = { handleStaySignInToggle }
5766 title = "Stay Logged In"
5867 isChecked = { staySignedIn }
5968 />
@@ -64,6 +73,24 @@ const AuthForm: React.FC<LoginFieldProps> = ({
6473 title = "Sign In"
6574 onPress = { handleSignIn }
6675 />
76+ < Modal
77+ animationType = "slide"
78+ transparent = { true }
79+ visible = { modalVisible }
80+ onRequestClose = { ( ) => {
81+ setModalVisible ( ! modalVisible ) ;
82+ } } >
83+ < View style = { tw `flex-1 justify-center items-center` } >
84+ < View style = { tw `m-5 bg-white rounded-2xl p-9 items-center shadow-lg` } >
85+ < Text style = { tw `mb-4 text-center` } > Your session will stay active until you sign out.</ Text >
86+ < Pressable
87+ style = { tw `rounded-2xl px-4 py-2 bg-[#345073]` }
88+ onPress = { ( ) => setModalVisible ( ! modalVisible ) } >
89+ < Text style = { tw `text-white font-bold text-center` } > OK</ Text >
90+ </ Pressable >
91+ </ View >
92+ </ View >
93+ </ Modal >
6794 </ >
6895 ) ;
6996} ;
0 commit comments