import React from 'react';
import { View, TextInput, Button, KeyboardAvoidingView, Platform, StyleSheet } from 'react-native';
export default function LoginScreen() {
return (
<KeyboardAvoidingView
style={styles.container}
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
>
<View style={styles.inner}>
<TextInput
placeholder="Email"
keyboardType="email-address"
style={styles.input}
autoCapitalize="none"
/>
<TextInput
placeholder="Password"
secureTextEntry
style={styles.input}
/>
<Button title="Login" onPress={() => {}} />
</View>
</KeyboardAvoidingView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1
},
inner: {
flex: 1,
justifyContent: 'center',
padding: 24
},
input: {
height: 40,
borderColor: '#ccc',
borderWidth: 1,
marginBottom: 12,
paddingHorizontal: 10,
borderRadius: 4
}
});This login screen uses KeyboardAvoidingView to move the content up when the keyboard appears, so the input fields are not hidden. The behavior prop changes based on the platform: padding for iOS and height for Android, which are the recommended settings.
The inputs have placeholders and appropriate keyboard types. The password input hides the text for privacy. The button is placed below the inputs. The content is centered vertically with padding for nice spacing.