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/.env.example b/application/mobile/.env.example new file mode 100644 index 00000000..ca9963a0 --- /dev/null +++ b/application/mobile/.env.example @@ -0,0 +1 @@ +VITE_API_URL=http://localhost:8080 \ No newline at end of file diff --git a/application/mobile/.gitignore b/application/mobile/.gitignore index 545942e1..318a7401 100644 --- a/application/mobile/.gitignore +++ b/application/mobile/.gitignore @@ -28,8 +28,9 @@ yarn-error.* .DS_Store *.pem -# local env files +# env files .env*.local +.env # typescript *.tsbuildinfo 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(`${VITE_API_URL}/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 +71,7 @@ export default function LoginScreen({ navigation }) { ref={ref_password} /> + {error && {error}} Log In @@ -108,6 +128,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 && ( + + )} + + + + + + +