diff --git a/App.tsx b/App.tsx index 84c32e2..01ab652 100644 --- a/App.tsx +++ b/App.tsx @@ -1,23 +1,15 @@ -import { StatusBar } from 'expo-status-bar'; -import { StyleSheet, Text, View } from 'react-native'; +import { StatusBar } from "expo-status-bar"; +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(): JSX.Element { return ( - + Open up App.tsx to start working on your app! ); } - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#fff', // For the "entire" app - alignItems: 'center', - justifyContent: 'center', - }, -}); diff --git a/src/components/PostView.tsx b/src/components/PostView.tsx index 924f72f..35957b5 100644 --- a/src/components/PostView.tsx +++ b/src/components/PostView.tsx @@ -1,7 +1,7 @@ import React from "react"; import { View, Text } from "react-native"; import { Post } from "../util/api"; -import { StyleSheet } from "react-native"; +import { style } from "../util/style"; /** * This is the component that holds a single Post @@ -15,19 +15,8 @@ export function PostView({ post }: { post: Post }): JSX.Element { const [thisPost, setThisPost] = React.useState(post); return ( - - {thisPost.content} + + {thisPost.content} ); } - -const style = StyleSheet.create({ - container: { - flexDirection: "row", - backgroundColor: '#fff', - paddingVertical: 5, - }, - font: { - color: "#000", - } -}); diff --git a/src/components/PostsContainer.tsx b/src/components/PostsContainer.tsx index f9df1bb..a67ceb5 100644 --- a/src/components/PostsContainer.tsx +++ b/src/components/PostsContainer.tsx @@ -2,7 +2,7 @@ import React from "react"; import { View, Text } from "react-native"; import { getPosts, Post } from "../util/api"; import { PostView } from "./PostView"; -import { StyleSheet } from "react-native"; +import { style } from "../util/style"; export function PostsContainer(): JSX.Element { const [posts, setPosts] = React.useState([]); @@ -16,22 +16,11 @@ export function PostsContainer(): JSX.Element { }, []); return ( - + Hello World! {posts.map((post) => ( ))} ); -} - -const style = StyleSheet.create({ - container: { - height: '100%', - padding: 5, - flex: 1, - alignItems: 'center', - justifyContent: 'flex-start', - backgroundColor: '#fff', // For the container holding the posts - }, -}); \ No newline at end of file +} \ No newline at end of file diff --git a/src/util/style.ts b/src/util/style.ts new file mode 100644 index 0000000..6fb0b72 --- /dev/null +++ b/src/util/style.ts @@ -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", + }, +}); \ No newline at end of file