From fd4e9e34e21cea0d476d1e8be717690257592a18 Mon Sep 17 00:00:00 2001 From: onurcerli Date: Tue, 30 Apr 2024 14:48:09 +0300 Subject: [PATCH 1/5] new mobile development branch --- .gitignore | 1 + application/mobile/App.js | 12 + application/mobile/App/Screens/FeedScreen.js | 49 +++- application/mobile/App/Screens/LoginScreen.js | 29 ++- .../mobile/App/Screens/PostCreationScreen.js | 199 +++++++++++++++ .../mobile/App/Screens/ProfileScreen.js | 233 ++++++++++-------- .../mobile/App/Screens/RegisterScreen.js | 83 ++++++- .../mobile/App/Screens/SearchResultScreen.js | 95 +++++++ application/mobile/App/assets/community.png | Bin 0 -> 23272 bytes application/mobile/App/assets/image.png | Bin 0 -> 16111 bytes .../App/components/AutoExpandingTextInput.js | 42 ++++ application/mobile/App/components/Post.js | 70 +++--- application/mobile/app.json | 8 +- application/mobile/package-lock.json | 80 +++++- application/mobile/package.json | 7 +- 15 files changed, 744 insertions(+), 164 deletions(-) create mode 100644 .gitignore create mode 100644 application/mobile/App/Screens/PostCreationScreen.js create mode 100644 application/mobile/App/Screens/SearchResultScreen.js create mode 100644 application/mobile/App/assets/community.png create mode 100644 application/mobile/App/assets/image.png create mode 100644 application/mobile/App/components/AutoExpandingTextInput.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..62c89355 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/application/mobile/App.js b/application/mobile/App.js index 1a6fc5b7..dd236d0d 100644 --- a/application/mobile/App.js +++ b/application/mobile/App.js @@ -4,6 +4,8 @@ import LoginScreen from "./App/Screens/LoginScreen"; import RegisterScreen from "./App/Screens/RegisterScreen"; import FeedScreen from "./App/Screens/FeedScreen"; import ProfileScreen from "./App/Screens/ProfileScreen"; +import PostCreationScreen from "./App/Screens/PostCreationScreen"; +import SearchResultScreen from "./App/Screens/SearchResultScreen"; const Stack = createNativeStackNavigator(); @@ -31,6 +33,16 @@ export default function App() { component={ProfileScreen} options={{ headerShown: false }} /> + + ); diff --git a/application/mobile/App/Screens/FeedScreen.js b/application/mobile/App/Screens/FeedScreen.js index ce0e913a..14939185 100644 --- a/application/mobile/App/Screens/FeedScreen.js +++ b/application/mobile/App/Screens/FeedScreen.js @@ -14,7 +14,7 @@ import { import Icon from "react-native-vector-icons/Entypo"; import Post from "../components/Post"; -export default function FeedScreen({ navigation }) { +export default function FeedScreen({ navigation, route }) { const getPosts = () => { return [ { @@ -81,6 +81,8 @@ export default function FeedScreen({ navigation }) { }; const [isMenuVisible, setIsMenuVisible] = useState(false); + const [text, setText] = useState(""); + const [error, setError] = useState(""); const toggleMenu = () => { console.log("Toggle menu"); @@ -88,10 +90,12 @@ export default function FeedScreen({ navigation }) { }; const createPost = () => { + navigation.navigate("Post"); console.log("create post"); }; const viewProfile = () => { console.log("view profile"); + setIsMenuVisible(false); navigation.navigate("Profile"); }; const settings = () => { @@ -102,18 +106,26 @@ export default function FeedScreen({ navigation }) { navigation.navigate("Login"); }; + const search = () => { + navigation.navigate("Search", { + param: text, + authToken: route.params.accessToken, + }); + }; + return ( - - Fanatic - - - + + + + appFanatic. + + + + + + @@ -140,7 +152,12 @@ export default function FeedScreen({ navigation }) { - + { - console.log(email + " logged in with password " + password); - navigation.navigate("Feed"); + const userParams = { + email: email, + password: password, + }; + + axios + .post("http://192.168.64.163:8080/api/v1/auth/authenticate", userParams) + .then((response) => { + console.log(response.data); + navigation.navigate("Feed", { + email: email, + authToken: response.data.accessToken, + }); + }) + .catch((error) => { + setError("Incorrect e-mail or password!"); + console.log(error.response.data); + console.log(error.response.status); + }); }; const onSignupClick = () => { - console.log("sign up"); navigation.navigate("Register"); }; @@ -52,6 +70,7 @@ export default function LoginScreen({ navigation }) { ref={ref_password} /> + {error && {error}} Log In @@ -108,6 +127,10 @@ const styles = StyleSheet.create({ borderColor: "lightgrey", fontSize: 15, }, + errorText: { + color: "red", + textAlign: "center", + }, buttonContainer: { height: "10%", width: "90%", diff --git a/application/mobile/App/Screens/PostCreationScreen.js b/application/mobile/App/Screens/PostCreationScreen.js new file mode 100644 index 00000000..97a9e258 --- /dev/null +++ b/application/mobile/App/Screens/PostCreationScreen.js @@ -0,0 +1,199 @@ +import React, { useState, useRef } from "react"; +import { + ImageBackground, + StyleSheet, + TextInput, + View, + Text, + TouchableOpacity, + StatusBar, + Dimensions, + Image, + Button, +} from "react-native"; +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'; +export default function PostCreationScreen({navigation}){ + const profile = { + profilePhoto: require("../assets/dummy_pics/pp2.png"), + username: "james", + email: "james@gmail.com", + supportedTeam: "Fenerbahçe", + }; + const[selectedImage, selectImage] = useState(null); + const[selectedCommunity, selectCommunity] = useState(""); + + + const [isMenuVisible, setIsMenuVisible] = useState(false); + + const toggleMenu = () => { + console.log("Toggle menu"); + setIsMenuVisible(!isMenuVisible); + }; + + const createPost = () => { + navigation.navigate("Post"); + console.log("create post"); + }; + const viewProfile = () => { + console.log("view profile"); + setIsMenuVisible(false); + navigation.navigate("Profile"); + }; + const settings = () => { + console.log("settings"); + }; + const logout = () => { + console.log("logout"); + navigation.navigate("Login"); + }; + const pickImage = async () => { + const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync(); + if (permissionResult.granted === false) { + alert("Permission to access camera roll is required!"); + return; + } + const pickerResult = await ImagePicker.launchImageLibraryAsync(); + if (pickerResult.cancelled === true) { + return; + } + + + selectImage({ localUri: pickerResult.assets[0].uri }); + } + const removeImage = () => { + selectImage(null); + } + const pickCommunity = (comm) =>{ + selectCommunity(comm); + } + return( + + + + Fanatic + + + + + + + + + + + + {selectedImage !== null && ( + + )} + + + + + + +