suxa1 / suxa

none
0 stars 0 forks source link

suxasgram #1

Closed suxa1 closed 2 months ago

suxa1 commented 2 months ago

npm install -g react-native-cli npx react-native init ChatApp cd ChatApp npm install @react-navigation/native @react-navigation/native-stack firebase ChatApp/ ├── App.js ├── components/ │ ├── ChatScreen.js │ ├── LoginScreen.js ├── firebaseConfig.js └── package.json import firebase from 'firebase/app'; import 'firebase/auth'; import 'firebase/firestore';

const firebaseConfig = { apiKey: "YOUR_API_KEY", authDomain: "YOUR_AUTH_DOMAIN", projectId: "YOUR_PROJECT_ID", storageBucket: "YOUR_STORAGE_BUCKET", messagingSenderId: "YOUR_MESSAGING_SENDER_ID", appId: "YOUR_APP_ID" };

if (!firebase.apps.length) { firebase.initializeApp(firebaseConfig); }

export const auth = firebase.auth(); export const firestore = firebase.firestore(); import React from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import LoginScreen from './components/LoginScreen'; import ChatScreen from './components/ChatScreen';

const Stack = createNativeStackNavigator();

const App = () => { return (

); };

export default App; import React, { useState } from 'react'; import { View, TextInput, Button, Alert } from 'react-native'; import { auth } from '../firebaseConfig';

const LoginScreen = ({ navigation }) => { const [email, setEmail] = useState(''); const [password, setPassword] = useState('');

const handleLogin = () => { auth.signInWithEmailAndPassword(email, password) .then(() => navigation.navigate('Chat')) .catch(error => Alert.alert(error.message)); };

return ( <View style={{ padding: 20 }}> <TextInput placeholder="Email" value={email} onChangeText={setEmail} style={{ borderWidth: 1, marginBottom: 10, padding: 10 }} /> <TextInput placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry style={{ borderWidth: 1, marginBottom: 10, padding: 10 }} />

suxa1 commented 2 months ago

@suxa1