diff --git a/AwesomeProject/App.js b/AwesomeProject/App.js index 488fce17964462950efc55a5b3155ab2bd415118..340ff3666fba9068991d1de147fe620066e976d3 100644 --- a/AwesomeProject/App.js +++ b/AwesomeProject/App.js @@ -3,32 +3,59 @@ import React, {useState} from 'react'; import {Text, TextInput, TouchableOpacity, View} from 'react-native'; import {signIn, signUp} from './lib/auth'; import {Alert} from 'react-native'; - +import {createUser} from './lib/user'; +import firestore from '@react-native-firebase/firestore'; +import {firebase} from '@react-native-firebase/auth'; const App = () => { const [email, setEmail] = useState(); const [password, setPass] = useState(); - + const [displayName, setName] = useState(); const onSignUp = async () => { - console.log(email, password); try { const {user} = await signUp({email, password}); - console.log(user); + await createUser({ + id: user.uid, + displayName, + photoURL: null, + }); Alert.alert('회원가입 성공!'); } catch (e) { - console.log(e); Alert.alert('회원가입 실패ㅠㅠ'); } + setEmail(); + setPass(); + setName(); }; const onSignIn = async () => { - console.log(email, password); try { const {user} = await signIn({email, password}); - console.log(user); - Alert.alert('로그인 성공!.'); + const userCollection = firestore().collection('users'); + console.log(await userCollection.doc(user.uid).get()); + await userCollection.doc(user.uid).update({displayName}); + console.log(await userCollection.doc(user.uid).get()); + Alert.alert('로그인 성공!'); } catch (e) { Alert.alert('로그인에 실패ㅠㅠ'); } + setEmail(); + setPass(); + setName(); }; + const onDelete = async () => { + // try { + // const {user} = await signIn({email, password}); + // const userCollection = firestore().collection('users'); + // await userCollection.doc(user.uid).delete(); + // Alert.alert('데이터베이스 삭제 tㅠㅠ'); + // } catch (e) { + // Alert.alert('데이터베이스 삭제 실패ㅠㅠ'); + // } + // const {user} = await signIn({email, password}); + // user.delete().catch(e => { + // console.log(e); + // }); + }; + return ( <View> <Text style={{fontSize: 20, fontWeight: 'bold'}}>회원가입 예시</Text> @@ -45,6 +72,12 @@ const App = () => { placeholderTextColor={'black'} style={{borderColor: 'red', borderBottomWidth: 1}} /> + <TextInput + onChangeText={setName} + placeholder="displayName" + placeholderTextColor={'black'} + style={{borderColor: 'red', borderBottomWidth: 1}} + /> <TouchableOpacity onPress={onSignUp}> <Text>SignUp</Text> </TouchableOpacity> @@ -63,10 +96,34 @@ const App = () => { placeholderTextColor={'black'} style={{borderColor: 'red', borderBottomWidth: 1}} /> + <TextInput + onChangeText={setName} + placeholder="displayName" + placeholderTextColor={'black'} + style={{borderColor: 'red', borderBottomWidth: 1}} + /> <TouchableOpacity onPress={onSignIn}> <Text>Login</Text> </TouchableOpacity> </View> + <Text style={{fontSize: 20, fontWeight: 'bold'}}>삭제 예시</Text> + <View style={{borderWidth: 3}}> + <TextInput + onChangeText={setEmail} + placeholder="email" + placeholderTextColor={'black'} + style={{borderColor: 'red', borderBottomWidth: 1}} + /> + <TextInput + onChangeText={setPass} + placeholder="password" + placeholderTextColor={'black'} + style={{borderColor: 'red', borderBottomWidth: 1}} + /> + <TouchableOpacity onPress={onDelete}> + <Text>delete</Text> + </TouchableOpacity> + </View> </View> ); }; diff --git a/AwesomeProject/android/app/src/main/AndroidManifest.xml b/AwesomeProject/android/app/src/main/AndroidManifest.xml index ab42b21b75af0a9eb5b8f919a1ec74c3d351ea67..23432d5f42867b3b499a47263aaf2c61d5eeef94 100644 --- a/AwesomeProject/android/app/src/main/AndroidManifest.xml +++ b/AwesomeProject/android/app/src/main/AndroidManifest.xml @@ -15,7 +15,7 @@ android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" - android:windowSoftInputMode="adjustResize" + android:windowSoftInputMode="adjustPan" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" />