From ee0929f0d875874686c6f5c303b401b4600b9f8e Mon Sep 17 00:00:00 2001 From: deniz6221 Date: Thu, 2 May 2024 22:10:25 +0300 Subject: [PATCH 01/11] Added post screens and connected post creation to backend. --- application/mobile/App.js | 2 + application/mobile/App/Screens/FeedScreen.js | 4 + .../mobile/App/Screens/PostCreationScreen.js | 22 ++- application/mobile/App/Screens/PostScreen.js | 147 ++++++++++++++++++ 4 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 application/mobile/App/Screens/PostScreen.js diff --git a/application/mobile/App.js b/application/mobile/App.js index dd236d0d..17a70a6b 100644 --- a/application/mobile/App.js +++ b/application/mobile/App.js @@ -43,6 +43,8 @@ export default function App() { component={SearchResultScreen} options={{ headerShown: false }} /> + } + options={{ headerShown: false }}> ); diff --git a/application/mobile/App/Screens/FeedScreen.js b/application/mobile/App/Screens/FeedScreen.js index 14939185..e1866970 100644 --- a/application/mobile/App/Screens/FeedScreen.js +++ b/application/mobile/App/Screens/FeedScreen.js @@ -162,11 +162,15 @@ export default function FeedScreen({ navigation, route }) { ( + { + navigation.navigate("PostScreen", {"item": item}); + }}> + )} style={styles.flatList} /> diff --git a/application/mobile/App/Screens/PostCreationScreen.js b/application/mobile/App/Screens/PostCreationScreen.js index 97a9e258..c04f74c5 100644 --- a/application/mobile/App/Screens/PostCreationScreen.js +++ b/application/mobile/App/Screens/PostCreationScreen.js @@ -15,6 +15,9 @@ import Icon from "react-native-vector-icons/Entypo"; import axios from "axios"; import AutoExpandingTextInput from "../components/AutoExpandingTextInput"; import * as ImagePicker from 'expo-image-picker/src/ImagePicker'; +import {VITE_API_URL} from "@env"; + + export default function PostCreationScreen({navigation}){ const profile = { profilePhoto: require("../assets/dummy_pics/pp2.png"), @@ -24,6 +27,7 @@ export default function PostCreationScreen({navigation}){ }; const[selectedImage, selectImage] = useState(null); const[selectedCommunity, selectCommunity] = useState(""); + const[postMessage, changePost] = useState(""); const [isMenuVisible, setIsMenuVisible] = useState(false); @@ -66,9 +70,23 @@ export default function PostCreationScreen({navigation}){ const removeImage = () => { selectImage(null); } + const textChanged = (text) =>{ + changePost(text); + } const pickCommunity = (comm) =>{ selectCommunity(comm); } + const sendPost = () => { + axios.post(`${VITE_API_URL}/api/v1/posts`, {"user_id": 1, + "title": profile.username, "text": postMessage, "teamName": profile.supportedTeam, "user": profile.email}).then( (response) => { + alert(response); + navigation.navigate("Feed");} + ).catch((error) => { + alert("Something went wrong"); + }) + + } + return( @@ -86,7 +104,7 @@ export default function PostCreationScreen({navigation}){ - + {selectedImage !== null && ( @@ -98,7 +116,7 @@ export default function PostCreationScreen({navigation}){ -