Compare commits
	
		
			3 commits
		
	
	
		
			68b0b16221
			...
			a1c8cd95d3
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						a1c8cd95d3 | ||
| 
							 | 
						ce7888667d | ||
| 
							 | 
						f97c22f6e0 | 
					 4 changed files with 38 additions and 18 deletions
				
			
		
							
								
								
									
										20
									
								
								App.tsx
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								App.tsx
									
										
									
									
									
								
							| 
						 | 
					@ -1,23 +1,15 @@
 | 
				
			||||||
import { StatusBar } from 'expo-status-bar';
 | 
					import { StatusBar } from "expo-status-bar";
 | 
				
			||||||
import { StyleSheet, Text, View } from 'react-native';
 | 
					import { Text, View } from "react-native";
 | 
				
			||||||
 | 
					import { style } from "./src/util/style";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { PostsContainer } from './src/components/PostsContainer';
 | 
					import { PostsContainer } from "./src/components/PostsContainer";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function App() {
 | 
					export default function App(): JSX.Element {
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <View style={styles.container}>
 | 
					    <View style={style.app}>
 | 
				
			||||||
      <Text>Open up App.tsx to start working on your app!</Text>
 | 
					      <Text>Open up App.tsx to start working on your app!</Text>
 | 
				
			||||||
      <StatusBar style="auto" />
 | 
					      <StatusBar style="auto" />
 | 
				
			||||||
      <PostsContainer />
 | 
					      <PostsContainer />
 | 
				
			||||||
    </View>
 | 
					    </View>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
const styles = StyleSheet.create({
 | 
					 | 
				
			||||||
  container: {
 | 
					 | 
				
			||||||
    flex: 1,
 | 
					 | 
				
			||||||
    backgroundColor: '#fff',
 | 
					 | 
				
			||||||
    alignItems: 'center',
 | 
					 | 
				
			||||||
    justifyContent: 'center',
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
import React from "react";
 | 
					import React from "react";
 | 
				
			||||||
import { View, Text } from "react-native";
 | 
					import { View, Text } from "react-native";
 | 
				
			||||||
import { Post } from "../util/api";
 | 
					import { Post } from "../util/api";
 | 
				
			||||||
 | 
					import { style } from "../util/style";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * This is the component that holds a single Post
 | 
					 * This is the component that holds a single Post
 | 
				
			||||||
| 
						 | 
					@ -14,8 +15,8 @@ export function PostView({ post }: { post: Post }): JSX.Element {
 | 
				
			||||||
  const [thisPost, setThisPost] = React.useState<Post>(post);
 | 
					  const [thisPost, setThisPost] = React.useState<Post>(post);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <View style={{ flexDirection: "row", height: 100, padding: 20 }}>
 | 
					    <View style={style.postView}>
 | 
				
			||||||
      <Text>{thisPost.content}</Text>
 | 
					      <Text style={style.postFont} >{thisPost.content}</Text>
 | 
				
			||||||
    </View>
 | 
					    </View>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@ import React from "react";
 | 
				
			||||||
import { View, Text } from "react-native";
 | 
					import { View, Text } from "react-native";
 | 
				
			||||||
import { getPosts, Post } from "../util/api";
 | 
					import { getPosts, Post } from "../util/api";
 | 
				
			||||||
import { PostView } from "./PostView";
 | 
					import { PostView } from "./PostView";
 | 
				
			||||||
 | 
					import { style } from "../util/style";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function PostsContainer(): JSX.Element {
 | 
					export function PostsContainer(): JSX.Element {
 | 
				
			||||||
  const [posts, setPosts] = React.useState<Post[]>([]);
 | 
					  const [posts, setPosts] = React.useState<Post[]>([]);
 | 
				
			||||||
| 
						 | 
					@ -15,11 +16,11 @@ export function PostsContainer(): JSX.Element {
 | 
				
			||||||
  }, []);
 | 
					  }, []);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <View style={{ height: 100, padding: 20 }}>
 | 
					    <View style={style.postsContainer}>
 | 
				
			||||||
      <Text>Hello World!</Text>
 | 
					      <Text>Hello World!</Text>
 | 
				
			||||||
      {posts.map((post) => (
 | 
					      {posts.map((post) => (
 | 
				
			||||||
        <PostView key={post.id} post={post} />
 | 
					        <PostView key={post.id} post={post} />
 | 
				
			||||||
      ))}
 | 
					      ))}
 | 
				
			||||||
    </View>
 | 
					    </View>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										26
									
								
								src/util/style.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/util/style.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					import { StyleSheet } from 'react-native';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const style = StyleSheet.create({
 | 
				
			||||||
 | 
					  app: { // Outermost container
 | 
				
			||||||
 | 
					    flex: 1,
 | 
				
			||||||
 | 
					    backgroundColor: '#fff', // For the "entire" app
 | 
				
			||||||
 | 
					    alignItems: 'center',
 | 
				
			||||||
 | 
					    justifyContent: 'center',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  postsContainer: {
 | 
				
			||||||
 | 
					    height: '100%',
 | 
				
			||||||
 | 
					    padding: 5,
 | 
				
			||||||
 | 
					    flex: 1,
 | 
				
			||||||
 | 
					    alignItems: 'center',
 | 
				
			||||||
 | 
					    justifyContent: 'flex-start',
 | 
				
			||||||
 | 
					    backgroundColor: '#fff', // For the container holding the posts
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  postView: {
 | 
				
			||||||
 | 
					    flexDirection: "row",
 | 
				
			||||||
 | 
					    backgroundColor: '#fff',
 | 
				
			||||||
 | 
					    paddingVertical: 5,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  postFont: {
 | 
				
			||||||
 | 
					    color: "#000",
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue