Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save calendee/39e3908940be9964e873b3dec0106ced to your computer and use it in GitHub Desktop.
Save calendee/39e3908940be9964e873b3dec0106ced to your computer and use it in GitHub Desktop.
// Be sure to import the Keyboard
import { Keyboard } from 'react-native'
// Tell the view what to do with taps
const shouldSetResponse = () => true;
const onRelease = () => (
Keyboard.dismiss()
);
// Your view
<SafeAreaView>
<View
onResponderRelease={ onRelease }
onStartShouldSetResponder={ shouldSetResponse }
style={ { height: '100%' } }
>
<TextInput
autoCapitalize="none"
keyboardType="email-address"
onChangeText={ this.changeEmailText }
placeholder="Email Address"
style={ [styles.textInput, emailInvalid ? styles.textInputError : null] }
testID="email"
value={ email }
/>
<TextInput
onChangeText={ this.changePasswordText }
placeholder="Password"
secureTextEntry
style={ [styles.textInput, passwordInvalid ? styles.textInputError : null] }
testID="password"
value={ password }
/>
<Text>
{ failureMessage }
</Text>
{ !loggingIn
&& (
<Button
onPress={ this.login }
testID="button-login"
title="Login"
color="#841584"
accessibilityLabel="Login"
/>
)
}
<Button
onPress={ this.closeModal }
testID="button-close-modal"
title="Close"
color="#841584"
accessibilityLabel="Close"
/>
</View>
</SafeAreaView>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment