Compare commits

...

3 commits

Author SHA1 Message Date
Imbus
a1c8cd95d3 Merge branch 'master' of git.silversoft.se:Imbus/frostbyte-native 2023-12-14 20:22:02 +01:00
Imbus
ce7888667d Styling in style.ts, minor refactor 2023-12-14 20:21:57 +01:00
Imbus
f97c22f6e0 Basic styling 2023-12-14 20:09:12 +01:00
4 changed files with 38 additions and 18 deletions

20
App.tsx
View file

@ -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() {
export default function App(): JSX.Element {
return (
<View style={styles.container}>
<View style={style.app}>
<Text>Open up App.tsx to start working on your app!</Text>
<StatusBar style="auto" />
<PostsContainer />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});

View file

@ -1,6 +1,7 @@
import React from "react";
import { View, Text } from "react-native";
import { Post } from "../util/api";
import { style } from "../util/style";
/**
* 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);
return (
<View style={{ flexDirection: "row", height: 100, padding: 20 }}>
<Text>{thisPost.content}</Text>
<View style={style.postView}>
<Text style={style.postFont} >{thisPost.content}</Text>
</View>
);
}

View file

@ -2,6 +2,7 @@ import React from "react";
import { View, Text } from "react-native";
import { getPosts, Post } from "../util/api";
import { PostView } from "./PostView";
import { style } from "../util/style";
export function PostsContainer(): JSX.Element {
const [posts, setPosts] = React.useState<Post[]>([]);
@ -15,7 +16,7 @@ export function PostsContainer(): JSX.Element {
}, []);
return (
<View style={{ height: 100, padding: 20 }}>
<View style={style.postsContainer}>
<Text>Hello World!</Text>
{posts.map((post) => (
<PostView key={post.id} post={post} />

26
src/util/style.ts Normal file
View 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",
},
});