first commit in repo
This commit is contained in:
34
components/Feed.js
Normal file
34
components/Feed.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Text, View, ScrollView, Button } from 'react-native';
|
||||
import API from './../API.js';
|
||||
|
||||
|
||||
let Feed = () => {
|
||||
let [Me, setMeProfile] = useState({});
|
||||
let [Posts, setPosts] = useState([]);
|
||||
useEffect(async () => {
|
||||
let r = await API.getMe();
|
||||
setMeProfile(r);
|
||||
let posts = await API.getPosts();
|
||||
setPosts(posts)
|
||||
//console.log(posts)
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View>
|
||||
<ScrollView>
|
||||
<Text>Hello: {Me.profile && Me.profile.firstName} {Me.profile && Me.profile.lastName}</Text>
|
||||
{
|
||||
Posts.map((post, i) => {
|
||||
return (
|
||||
<Text key={i}>{post.content}</Text>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default Feed;
|
||||
49
components/Login.js
Normal file
49
components/Login.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import React, { useState } from 'react';
|
||||
import { Text, View, TextInput, Button } from 'react-native';
|
||||
import API from './../API.js';
|
||||
|
||||
|
||||
let LoginForm = ()=>{
|
||||
let [email, setEmail] = useState('');
|
||||
let [password, setPassword] = useState('');
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text>Log in</Text>
|
||||
<TextInput
|
||||
style={{
|
||||
height: 40,
|
||||
width: 200,
|
||||
borderColor: 'gray',
|
||||
borderWidth: 1
|
||||
}}
|
||||
onChangeText={text => setEmail(text)}
|
||||
defaultValue={email}
|
||||
placeholder=" email"
|
||||
/>
|
||||
<TextInput
|
||||
style={{
|
||||
height: 40,
|
||||
width: 200,
|
||||
borderColor: 'gray',
|
||||
borderWidth: 1
|
||||
}}
|
||||
onChangeText={text => setPassword(text)}
|
||||
defaultValue={password}
|
||||
placeholder=" password"
|
||||
textContentType="password"
|
||||
secureTextEntry={true}
|
||||
/>
|
||||
<Button
|
||||
onPress={async () => {
|
||||
let r = await API.logIn(email, password);
|
||||
console.log(r);
|
||||
}}
|
||||
title={"login"}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default LoginForm;
|
||||
Reference in New Issue
Block a user