From 1cbfa7eba8d8d5fb951dbafff10fa1e557f18a08 Mon Sep 17 00:00:00 2001
From: Cyber Majeed <73933962+cybermajeed@users.noreply.github.com>
Date: Tue, 16 Apr 2024 21:39:43 +0400
Subject: [PATCH] Add files via upload
---
mobile/App.js | 10 ++--
mobile/app.json | 10 +---
mobile/app/dashboard.js | 28 ++++++++++
mobile/app/login.js | 112 ++++++++++++++++++++++++++++++++++++++++
mobile/style.js | 103 ++++++++++++++++++++++++++++++++++++
5 files changed, 250 insertions(+), 13 deletions(-)
create mode 100644 mobile/app/dashboard.js
create mode 100644 mobile/app/login.js
create mode 100644 mobile/style.js
diff --git a/mobile/App.js b/mobile/App.js
index 2409154..5509ab5 100644
--- a/mobile/App.js
+++ b/mobile/App.js
@@ -1,5 +1,5 @@
-import loginPage from "./login";
-import userPage from "./user";
+import userLogin from "./app/login";
+import userDashboard from "./app/dashboard";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
const Stack = createNativeStackNavigator();
@@ -17,12 +17,12 @@ export default function App() {
diff --git a/mobile/app.json b/mobile/app.json
index bfdbdea..85e7ccf 100644
--- a/mobile/app.json
+++ b/mobile/app.json
@@ -21,16 +21,10 @@
"adaptiveIcon": {
"foregroundImage": "./assets/logo.png",
"backgroundColor": "#ffffff"
- },
- "package": "com.cybermajeed.Notifire"
+ }
},
"web": {
"favicon": "./assets/logo.png"
- },
- "extra": {
- "eas": {
- "projectId": "768915cc-8129-4740-b178-fe5d9651326d"
- }
}
}
-}
+}
\ No newline at end of file
diff --git a/mobile/app/dashboard.js b/mobile/app/dashboard.js
new file mode 100644
index 0000000..aa3e592
--- /dev/null
+++ b/mobile/app/dashboard.js
@@ -0,0 +1,28 @@
+import { SafeAreaView, Button, Text } from "react-native";
+import { styles } from "../style";
+import { auth, signOut, onAuthStateChanged } from "../auth";
+import { useState } from "react";
+export default function App({ navigation }) {
+ const [name, setName] = useState("");
+ onAuthStateChanged(auth, (user) => {
+ if (user) {
+ const name = user.email.split("@")[0];
+ setName(name);
+ }
+ });
+ const LogoutUser = () => {
+ signOut(auth)
+ .then(() => {
+ console.log("signed out");
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
+ return (
+
+ Hello {name}
+
+
+ );
+}
diff --git a/mobile/app/login.js b/mobile/app/login.js
new file mode 100644
index 0000000..cf2b310
--- /dev/null
+++ b/mobile/app/login.js
@@ -0,0 +1,112 @@
+import {
+ View,
+ SafeAreaView,
+ Image,
+ TextInput,
+ Text,
+ TouchableOpacity,
+} from "react-native";
+import { StatusBar } from "expo-status-bar";
+import { styles } from "../style";
+import { useState, useEffect } from "react";
+import { auth, signInWithEmailAndPassword } from "../auth";
+
+export default function App({ navigation }) {
+ const [username, setUsername] = useState("");
+ const [password, setPassword] = useState("");
+ //
+ useEffect(() => {
+ const unsubscribe = auth.onAuthStateChanged((user) => {
+ if (user) {
+ navigation.navigate("Dashboard");
+ } else {
+ navigation.navigate("Login");
+ }
+ setUsername("");
+ setPassword("");
+ this.usrnmInp.clear();
+ this.pswdInp.clear();
+ });
+ return unsubscribe;
+ }, []);
+ //
+ const LoginUser = () => {
+ //
+ signInWithEmailAndPassword(auth, username, password)
+ .then((userCredential) => {
+ // Signed in
+ const user = userCredential.user;
+ console.log("logged in as: " + user.email);
+ // ...
+ })
+ .catch((error) => {
+ const errorCode = error.code;
+ const errorMessage = error.message;
+ console.log(errorCode);
+ console.log(errorMessage);
+ });
+ };
+ //
+ return (
+
+
+
+
+
+
+
+
+ Welcome To Notifire
+
+
+ setUsername(usrnm)}
+ placeholderTextColor={"#949494"}
+ keyboardType="email-address"
+ style={styles.loginScreen.loginInputs.username}
+ ref={(inp) => {
+ this.usrnmInp = inp;
+ }}
+ />
+ setPassword(pswd)}
+ secureTextEntry={true}
+ style={styles.loginScreen.loginInputs.password}
+ ref={(inp) => {
+ this.pswdInp = inp;
+ }}
+ />
+
+ {
+ if (username.trim() && password.trim()) {
+ LoginUser;
+ }
+ }}
+ style={styles.loginScreen.loginInputs.loginBtn}
+ >
+ Login
+
+
+
+
+ );
+}
diff --git a/mobile/style.js b/mobile/style.js
new file mode 100644
index 0000000..4d84baf
--- /dev/null
+++ b/mobile/style.js
@@ -0,0 +1,103 @@
+import { StyleSheet, Platform } from "react-native";
+
+const styles = StyleSheet.create({
+ container: {
+ overflow: "hidden",
+ flex: 1,
+ backgroundColor: "#fff",
+ alignItems: "center",
+ justifyContent: "center",
+ },
+ bg: {
+ flex: 0.5,
+ backgroundColor: "dodgerblue",
+ height: "100%",
+ width: "200%",
+ position: "absolute",
+ top: "-50%",
+ left: "-50%",
+ transform: "rotate(-15deg)",
+ },
+ loginScreen: {
+ height: "85%",
+ width: "80%",
+ backgroundColor: "#fff",
+ borderRadius: 10,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ cehsLogo: {
+ width: "100%",
+ flex: 1.8,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ },
+ loginInputs: {
+ flex: 1.2,
+ width: "100%",
+ minHeight: 100,
+ height: 100,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ gap: 20,
+ username: {
+ width: "80%",
+ backgroundColor: "#ebebeb",
+ paddingVertical: 8,
+ paddingHorizontal: 16,
+ borderRadius: 6,
+ },
+ password: {
+ width: "80%",
+ backgroundColor: "#ebebeb",
+ paddingVertical: 8,
+ paddingHorizontal: 16,
+ borderRadius: 6,
+ },
+ loginBtn: {
+ paddingVertical: 10,
+ paddingHorizontal: 25,
+ marginTop: 10,
+ borderRadius: 100,
+ ...Platform.select({
+ default: {
+ shadowColor: "#000",
+ shadowOffset: { width: 0, height: 3 },
+ shadowRadius: 5,
+ shadowOpacity: 0.4,
+ },
+ ios: {
+ shadowColor: "#000",
+ shadowOffset: { width: 0, height: 3 },
+ shadowRadius: 5,
+ shadowOpacity: 0.4,
+ },
+ android: {
+ elevation: 2,
+ },
+ }),
+ },
+ },
+ ...Platform.select({
+ default: {
+ shadowColor: "#000",
+ shadowOffset: { width: 0, height: 10 },
+ shadowRadius: 15,
+ shadowOpacity: 0.5,
+ },
+ ios: {
+ shadowColor: "#000",
+ shadowOffset: { width: 0, height: 10 },
+ shadowRadius: 15,
+ shadowOpacity: 0.5,
+ },
+ android: {
+ elevation: 8,
+ },
+ }),
+ },
+});
+
+export { styles };