Skip to content

Instantly share code, notes, and snippets.

@tuliocll
Last active August 14, 2023 02:40
Show Gist options
  • Save tuliocll/cd23c2d3ef23f0faf7074905aa214147 to your computer and use it in GitHub Desktop.
Save tuliocll/cd23c2d3ef23f0faf7074905aa214147 to your computer and use it in GitHub Desktop.
Simple React Native Login UI for native modules tutorial on http://tuliocalil.com/
import React from 'react';
import {
View,
Text,
TextInput,
TouchableOpacity,
ImageBackground,
StyleSheet,
StatusBar,
} from 'react-native';
const LoginScreen = () => {
const handleLogin = () => {
console.log('Login button pressed');
};
return (
<>
<StatusBar barStyle="light-content" />
<ImageBackground
source={{
uri: 'https://images.unsplash.com/photo-1646641312830-98334f2cc5b9?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=687&q=80',
}}
style={styles.backgroundImage}>
<View style={styles.container}>
<Text style={styles.title}>Welcome Back</Text>
<TextInput
style={styles.input}
placeholder="Email"
placeholderTextColor="#b2b2b2"
/>
<TextInput
style={styles.input}
placeholder="Password"
placeholderTextColor="#b2b2b2"
secureTextEntry
/>
<TouchableOpacity style={styles.loginButton} onPress={handleLogin}>
<Text style={styles.buttonText}>Login</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.forgotPasswordButton}>
<Text style={styles.forgotPasswordText}>Forgot Password?</Text>
</TouchableOpacity>
</View>
</ImageBackground>
</>
);
};
const styles = StyleSheet.create({
backgroundImage: {
flex: 1,
resizeMode: 'cover',
justifyContent: 'center',
},
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.7)',
padding: 20,
},
title: {
fontSize: 28,
fontWeight: 'bold',
marginBottom: 30,
color: '#ffffff',
},
input: {
width: '100%',
height: 50,
borderWidth: 1,
borderColor: '#d9d9d9',
borderRadius: 10,
paddingHorizontal: 15,
marginBottom: 15,
color: '#333333',
},
loginButton: {
backgroundColor: '#007bff',
borderRadius: 10,
paddingVertical: 15,
width: '100%',
alignItems: 'center',
},
buttonText: {
color: '#ffffff',
fontSize: 18,
fontWeight: 'bold',
},
forgotPasswordButton: {
marginTop: 15,
},
forgotPasswordText: {
color: '#007bff',
fontSize: 16,
fontWeight: 'bold',
},
});
export default LoginScreen;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment