From e531fb05576462688e597a2164a24450837b43bb Mon Sep 17 00:00:00 2001 From: Dhanushit419 Date: Wed, 14 Feb 2024 19:55:15 +0530 Subject: [PATCH 01/46] 14/02-2 --- App.js | 5 +- Pages/Dashboard.js | 123 +++++++++++++++++++++++++++++++++++++++++++++ Pages/login.js | 9 ---- 3 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 Pages/Dashboard.js diff --git a/App.js b/App.js index 8f9605f..e291b9d 100644 --- a/App.js +++ b/App.js @@ -2,14 +2,15 @@ import 'react-native-gesture-handler' import { NavigationContainer } from "@react-navigation/native"; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import Login from "./Pages/login" - +import DashBoard from "./Pages/Dashboard" const BottomTab = createBottomTabNavigator() export default function App() { return ( - + + diff --git a/Pages/Dashboard.js b/Pages/Dashboard.js new file mode 100644 index 0000000..47bc4f4 --- /dev/null +++ b/Pages/Dashboard.js @@ -0,0 +1,123 @@ +import { StyleSheet, View, Text, ScrollView } from "react-native" + +export default function DashBoard() { + return ( + + {/* top container */} + + {/*First view for welcome msg */} + + Welcome + Dhanushkumar B.tech IT + + {/* second view for 3 boxes */} + + + + + + + + + + + + + + + {/* bottom container */} + + For upcoming classes + + + Hours + Subject + Faculty + + + Hour 1 + + + Hour 1 + + + Hour 1 + + + Hour 1 + + + Hour 1 + + + Hour 1 + + + Hour 1 + + + + + + ); +} + +const styles = StyleSheet.create({ + main: { + flex: 1, + padding: 20, + + }, + top: { + flex: 2, + }, + bottom: { + flex: 3, + }, + welcome: { + flex: 1 + }, + nametext: { + justifyContent: "center", + marginLeft: 30 + }, + boxContainer: { + flex: 2, + flexDirection: "row", + justifyContent: "space-around", + alignItems: "center" + }, + box: { + height: 100, + width: 100, + elevation: 5, + backgroundColor: "#fff", + borderWidth: 1, + borderColor: "silver", + borderRadius: 10, + margin: 1, + padding: 10, + justifyContent: "center", + alignItems: "center" + + }, + periods: { + flex: 1, + flexDirection: "column", + justifyContent: "space-around", + alignItems: "center", + }, + periodsRow: { + flex: 1, + flexDirection: "row", + justifyContent: "space-around", + width: "100%", + + } + +}) \ No newline at end of file diff --git a/Pages/login.js b/Pages/login.js index 6a03fcb..0969028 100644 --- a/Pages/login.js +++ b/Pages/login.js @@ -32,15 +32,6 @@ export default function App() { return ( Login Form - {/* - Dark mode - Seton((previouValue) => !previouValue)} - trackColor={{ true: "blue", false: "red" }} - thumbColor="white" - /> - */} From e0314472e21c8d4887293aee9ff7371d7928b04e Mon Sep 17 00:00:00 2001 From: Dhanushit419 Date: Thu, 15 Feb 2024 10:21:37 +0530 Subject: [PATCH 02/46] 15/02 --- Components/Schedule.json | 10 +++ Pages/Dashboard.js | 148 ++++++++++++++++++++++++++++----------- 2 files changed, 117 insertions(+), 41 deletions(-) create mode 100644 Components/Schedule.json diff --git a/Components/Schedule.json b/Components/Schedule.json new file mode 100644 index 0000000..ac7caa3 --- /dev/null +++ b/Components/Schedule.json @@ -0,0 +1,10 @@ +[ + {"Hour":"1","Subject":"SRP Lab","staff":"Jasmine","location":"KP"}, + {"Hour":"2","Subject":"SRP Lab","staff":"Jasmine","location":"KP"}, + {"Hour":"3","Subject":"Social Network Analysis","staff":"Mala","location":"KP"}, + {"Hour":"4","Subject":"Social Network Analysis","staff":"Mala","location":"KP"}, + {"Hour":"5","Subject":"IOT ","staff":"Selvi Ravindran","location":"KP"}, + {"Hour":"6","Subject":"IOT ","staff":"Selvi Ravindran","location":"KP"}, + {"Hour":"7","Subject":"SRP Lab","staff":"Jasmine","location":"KP"}, + {"Hour":"8","Subject":"SRP Lab","staff":"Jasmine","location":"KP"} +] \ No newline at end of file diff --git a/Pages/Dashboard.js b/Pages/Dashboard.js index 47bc4f4..63f84d6 100644 --- a/Pages/Dashboard.js +++ b/Pages/Dashboard.js @@ -1,6 +1,20 @@ -import { StyleSheet, View, Text, ScrollView } from "react-native" - +import { StyleSheet, View, Text, ScrollView, FlatList } from "react-native" +import { useState, useEffect } from "react"; +import Schedule from "../Components/Schedule.json" export default function DashBoard() { + const [currentTime, setCurrentTime] = useState(new Date()); + + useEffect(() => { + const interval = setInterval(() => { + setCurrentTime(new Date()); + }, 1000); + // console.log(currentTime.toLocaleTimeString()) + return () => clearInterval(interval); + + }, []); + + const formattedTime = currentTime.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }); + return ( {/* top container */} @@ -17,14 +31,14 @@ export default function DashBoard() { {/* second view for 3 boxes */} - - - - - + + + 11 + Classes Missed + - - + + {formattedTime} @@ -32,33 +46,38 @@ export default function DashBoard() { {/* bottom container */} - For upcoming classes + For upcoming classes + - - Hours - Subject - Faculty - - - Hour 1 - - - Hour 1 - - - Hour 1 - - - Hour 1 - - - Hour 1 - - - Hour 1 - - - Hour 1 + + + + { + //console.log(item.Subject) + return ( + + + {item.Hour} + + + + {item.Subject} + + + + {item.staff} + 📍{item.location} + + + + + ) + }} + /> + + @@ -97,26 +116,73 @@ const styles = StyleSheet.create({ width: 100, elevation: 5, backgroundColor: "#fff", - borderWidth: 1, - borderColor: "silver", + // borderWidth: 1, + //borderColor: "silver", borderRadius: 10, - margin: 1, + marginBottom: 5, padding: 10, justifyContent: "center", alignItems: "center" }, + box2: { + //time box + flex: 2, + height: 120, + elevation: 5, + backgroundColor: "#fff", + // borderWidth: 1, + //borderColor: "silver", + borderRadius: 10, + marginBottom: 5, + marginLeft: 20, + padding: 10, + justifyContent: "center", + alignItems: "center" + }, + time: { + fontSize: 30, + fontFamily: "monospace" + }, periods: { flex: 1, flexDirection: "column", justifyContent: "space-around", - alignItems: "center", + width: "100%", + }, periodsRow: { + backgroundColor: "white", + padding: 10, + width: "100%", + marginBottom: 5, + flexDirection: "row", + marginTop: 5, + borderColor: "silver", + borderWidth: 1, + borderRadius: 10, + elevation: 5 + + }, + rowLeft: { + flex: 1, + justifyContent: "center", + alignItems: "center", + borderRightWidth: 1, + }, + rowRight: { + flex: 9 + }, + rowTop: { + flex: 1, + //marginLeft: 30 + paddingLeft: 10 + }, + rowBottom: { flex: 1, flexDirection: "row", - justifyContent: "space-around", - width: "100%", + justifyContent: "space-between", + padding: 10, } From 4a67108ccfb8f7ae7f953182f28b90153f0c1127 Mon Sep 17 00:00:00 2001 From: Dhanushit419 Date: Thu, 15 Feb 2024 18:48:55 +0530 Subject: [PATCH 03/46] 15/02 2 --- App.js | 2 + Components/info.json | 0 Pages/Dashboard.js | 26 +- Pages/Notifications.js | 28 ++ Pages/Signup.js | 148 +++++++ Pages/login.js | 17 +- package-lock.json | 942 +++++++++++++++++++++++++++++++---------- package.json | 6 +- 8 files changed, 930 insertions(+), 239 deletions(-) create mode 100644 Components/info.json create mode 100644 Pages/Notifications.js create mode 100644 Pages/Signup.js diff --git a/App.js b/App.js index e291b9d..102695d 100644 --- a/App.js +++ b/App.js @@ -3,6 +3,7 @@ import { NavigationContainer } from "@react-navigation/native"; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import Login from "./Pages/login" import DashBoard from "./Pages/Dashboard" +import SignUp from "./Pages/Signup" const BottomTab = createBottomTabNavigator() export default function App() { @@ -10,6 +11,7 @@ export default function App() { + diff --git a/Components/info.json b/Components/info.json new file mode 100644 index 0000000..e69de29 diff --git a/Pages/Dashboard.js b/Pages/Dashboard.js index 63f84d6..d8e9ccf 100644 --- a/Pages/Dashboard.js +++ b/Pages/Dashboard.js @@ -1,7 +1,9 @@ -import { StyleSheet, View, Text, ScrollView, FlatList } from "react-native" +import { StyleSheet, View, Text, ScrollView, FlatList, TouchableOpacity } from "react-native" import { useState, useEffect } from "react"; import Schedule from "../Components/Schedule.json" -export default function DashBoard() { +import { Ionicons } from '@expo/vector-icons'; + +export default function DashBoard({ navigation }) { const [currentTime, setCurrentTime] = useState(new Date()); useEffect(() => { @@ -14,6 +16,18 @@ export default function DashBoard() { }, []); const formattedTime = currentTime.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }); + navigation.setOptions({ + headerRight: () => ( + { + console.log("Notification pressed"); + }} + > + + + ) + }); return ( @@ -46,7 +60,7 @@ export default function DashBoard() { {/* bottom container */} - For upcoming classes + Upcoming classes @@ -67,8 +81,8 @@ export default function DashBoard() { - {item.staff} - 📍{item.location} + {item.staff} + {item.location} @@ -169,6 +183,8 @@ const styles = StyleSheet.create({ justifyContent: "center", alignItems: "center", borderRightWidth: 1, + marginRight: 5, + paddingRight: 6 }, rowRight: { flex: 9 diff --git a/Pages/Notifications.js b/Pages/Notifications.js new file mode 100644 index 0000000..5862db8 --- /dev/null +++ b/Pages/Notifications.js @@ -0,0 +1,28 @@ +import { StyleSheet, View, Text, ScrollView, FlatList } from "react-native" +import { useState, useEffect } from "react"; +import { Ionicons } from '@expo/vector-icons'; +import Info from "../Components/info.json" + +export default function Notification() { + return ( + + { + + return ( + + Im notification {Info.info} + + ) + }} + /> + + ) +} + +const style = StyleSheet.create({ + container: { + + }, +}) \ No newline at end of file diff --git a/Pages/Signup.js b/Pages/Signup.js new file mode 100644 index 0000000..7b35ad5 --- /dev/null +++ b/Pages/Signup.js @@ -0,0 +1,148 @@ +import { StatusBar } from 'expo-status-bar'; +import React, { useState } from 'react'; +import { StyleSheet, Text, View, TextInput, Button } from 'react-native'; +import { useNavigation } from '@react-navigation/native'; +import axios from 'axios'; + +export default function App() { + const navigate = useNavigation(); + + const [userDetails, setUserDetails] = useState({ + roll: "", + name: "", + dept: "", + year: "", + password: "" + }); + const [error, setError] = useState({}); + + const validateForm = () => { + let errors = {}; + if (!userDetails.roll) errors.roll = "Please enter your roll number"; + if (!userDetails.name) errors.name = "Please enter your name"; + if (!userDetails.dept) errors.dept = "Please enter your department"; + if (!userDetails.year) errors.year = "Please enter your year"; + if (!userDetails.password) errors.password = "Please enter your password"; + setError(errors); + return Object.keys(errors).length === 0; + } + + const handleChange = (field, value) => { + + setUserDetails(prevState => ({ + ...prevState, + [field]: value + })); + } + + const handleSubmit = () => { + if (validateForm()) { + console.log("Form is valid. Submitting..."); + + axios({ + url: "http://10.0.0.2/auth/signup", + method: "POST", + params: userDetails + }) + .then((res) => { + if (res.data.success) { + navigate.navigate("login") + } + else if (!res.data.newUser) { + console.log("User already registered") + } + else { + console.log("oh no !") + } + }) + + + } else { + console.log("Form validation failed. Please check the fields."); + } + } + + return ( + + Sign Up Form + + handleChange('roll', value)} + placeholder="Roll Number" + style={styles.input} + /> + {error.roll && {error.roll}} + + handleChange('name', value)} + placeholder="Name" + style={styles.input} + /> + {error.name && {error.name}} + + handleChange('dept', value)} + placeholder="Department" + style={styles.input} + /> + {error.dept && {error.dept}} + + handleChange('year', value)} + placeholder="Year" + style={styles.input} + /> + {error.year && {error.year}} + + handleChange('password', value)} + placeholder="Password" + style={styles.input} + secureTextEntry + /> + {error.password && {error.password}} + +