Basic styling

This commit is contained in:
Imbus 2023-12-14 20:09:12 +01:00
parent ca12938fb0
commit f97c22f6e0
3 changed files with 29 additions and 5 deletions

View file

@ -3,7 +3,7 @@ import { StyleSheet, Text, View } from 'react-native';
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={styles.container}>
<Text>Open up App.tsx to start working on your app!</Text> <Text>Open up App.tsx to start working on your app!</Text>
@ -16,7 +16,7 @@ export default function App() {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
backgroundColor: '#fff', backgroundColor: '#fff', // For the "entire" app
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}, },

View file

@ -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 { StyleSheet } from "react-native";
/** /**
* This is the component that holds a single Post * This is the component that holds a single Post
@ -14,8 +15,19 @@ 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.container}>
<Text>{thisPost.content}</Text> <Text style={style.font} >{thisPost.content}</Text>
</View> </View>
); );
} }
const style = StyleSheet.create({
container: {
flexDirection: "row",
backgroundColor: '#fff',
paddingVertical: 5,
},
font: {
color: "#000",
}
});

View file

@ -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 { StyleSheet } from "react-native";
export function PostsContainer(): JSX.Element { export function PostsContainer(): JSX.Element {
const [posts, setPosts] = React.useState<Post[]>([]); const [posts, setPosts] = React.useState<Post[]>([]);
@ -15,7 +16,7 @@ export function PostsContainer(): JSX.Element {
}, []); }, []);
return ( return (
<View style={{ height: 100, padding: 20 }}> <View style={style.container}>
<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} />
@ -23,3 +24,14 @@ export function PostsContainer(): JSX.Element {
</View> </View>
); );
} }
const style = StyleSheet.create({
container: {
height: '100%',
padding: 5,
flex: 1,
alignItems: 'center',
justifyContent: 'flex-start',
backgroundColor: '#fff', // For the container holding the posts
},
});