Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enhance login screen with social login options #373

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2bda6c0
feat: implement user information component
kshitij79 Jan 30, 2025
ebdc526
fix(css): fixed css properties
kshitij79 Feb 2, 2025
231799c
fix: refactor account component for better modularity & testability
kshitij79 Feb 9, 2025
bcf806c
Merge pull request #347 from gamesover/chore/340/bump-expo-to-52
pierrelstan Feb 16, 2025
f9ba193
fix: refactor account component and added test components
kshitij79 Feb 16, 2025
1d91eff
Merge pull request #329 from kshitij79/feature/user-info-component
pierrelstan Feb 16, 2025
112c816
chore: add missing workspace scripts in package.json
pierrelstan Feb 19, 2025
b7adea3
Merge pull request #349 from Greenstand/chore/add-missing-scripts
pierrelstan Feb 20, 2025
b10fb6d
feat: add custom button
pierrelstan Feb 20, 2025
687bdeb
refactor: rename function, add slot
pierrelstan Feb 20, 2025
3c63f8c
fix: add onboarding
pierrelstan Feb 20, 2025
e37268d
fix: rename function, add verifyAppLayoutStatus
pierrelstan Feb 20, 2025
df766df
Merge pull request #351 from Greenstand/fix/onboarding-screen
pierrelstan Feb 20, 2025
b402f81
feat: add login screen textinput button title (#354)
pierrelstan Feb 21, 2025
fa00544
feat: refactor code for reusability and remove third party package
Agastya18 Feb 23, 2025
8e376cb
feat: update login screen styles and improve accessibility of social …
Agastya18 Feb 26, 2025
7bb6659
fix: reset head pointer two steps back
Agastya18 Mar 1, 2025
f2b2ffe
feat: add social button component
Agastya18 Feb 23, 2025
9c91257
Merge branch 'main' into login-page
pierrelstan Mar 2, 2025
1eb01c6
Merge branch 'login-page' of https://github.com/Agastya18/treetracker…
Agastya18 Mar 3, 2025
4923a11
feat: implement login functionality and add password reset link
Agastya18 Mar 3, 2025
ff8e6d5
fix: enhance login screen with social login options and improve passw…
Agastya18 Mar 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 72 additions & 22 deletions apps/native/app/(auth)/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,25 @@ import {
StyleSheet,
KeyboardAvoidingView,
Platform,
TouchableOpacity,
Text,
ScrollView,
} from "react-native";
import { router } from "expo-router";
import SocialButton from "@/components/SocialButton";
import CustomTextInput from "@/components/ui/common/CustomTextInput";
import CustomTitle from "@/components/ui/common/CustomTitle";
import CustomSubmitButton from "@/components/ui/common/CustomSubmitButton";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useRouter } from "expo-router";

const LoginScreen = () => {
const [email, setEmail] = useState("");
const [isAuth, setAuth] = useState(false);
const [password, setPassword] = useState("");
const isLoginEnabled = email.length > 0 && password.length > 0;
console.log(isLoginEnabled);
const router = useRouter();

const handleLogIn = () => {
setAuth(true);
if (isAuth) {
router.push("/(tabs)/home");

AsyncStorage.setItem("isAuth", `${isAuth}`);
}
console.log("login....");
console.log("Logging in...");
};

return (
Expand Down Expand Up @@ -58,21 +54,54 @@ const LoginScreen = () => {
title="log in"
onPress={handleLogIn}
disabled={isLoginEnabled}
style={[
isLoginEnabled ? styles.buttonActive : styles.buttonDisabled,
{ textTransform: "uppercase" },
]}
style={
(isLoginEnabled ? styles.buttonActive : styles.buttonDisabled,
[{ textTransform: "uppercase" }])
}
/>
</View>

<View style={styles.forgotPasswordSection}>
<Text style={styles.forgotPasswordLabel}>Forgot password? </Text>
<TouchableOpacity>
<Text style={styles.resetLink}>Reset</Text>
</TouchableOpacity>
</View>

<Text style={styles.dividerText}>or</Text>

{/* Add the SocialButton component here */}

<SocialButton
iconName="google"
title="Log in with Gmail"
onPress={() => console.log("Gmail Login")}
/>

<SocialButton
iconName="facebook-square"
title="Log in with Facebook"
onPress={() => console.log("Facebook Login")}
/>

<SocialButton
iconName="github"
title="Log in with GitHub"
onPress={() => console.log("GitHub Login")}
/>

<View style={styles.signupSection}>
<Text style={styles.signupPrompt}>Don't have an account? </Text>
<TouchableOpacity onPress={() => router.push("/(auth)/register")}>
<Text style={styles.signupActionLink}>Sign up</Text>
</TouchableOpacity>
</View>
</ScrollView>
</KeyboardAvoidingView>
);
};

const styles = StyleSheet.create({
container: {
backgroundColor: "white",
},
keyboardContainer: {
flex: 1,
},
Expand All @@ -81,7 +110,6 @@ const styles = StyleSheet.create({
justifyContent: "center",
paddingHorizontal: 20,
},

buttonContainer: {
paddingVertical: 13,
alignItems: "center",
Expand All @@ -99,10 +127,32 @@ const styles = StyleSheet.create({
width: "100%",
alignItems: "center",
},
buttonText: {
fontSize: 18,
fontWeight: "bold",
color: "white",
dividerText: {
textAlign: "center",
color: "#666",
marginVertical: 15,
},
forgotPasswordSection: {
flexDirection: "row",
justifyContent: "center",
marginBottom: 20,
},
forgotPasswordLabel: {
color: "#333",
},
resetLink: {
color: "#6B8E23",
},
signupSection: {
flexDirection: "row",
justifyContent: "center",
marginTop: 20,
},
signupPrompt: {
color: "#333",
},
signupActionLink: {
color: "#6B8E23",
},
});

Expand Down
46 changes: 46 additions & 0 deletions apps/native/components/SocialButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from "react";
import { TouchableOpacity, Text, StyleSheet, ViewStyle } from "react-native";
import AntDesign from "@expo/vector-icons/AntDesign";

type SocialButtonProps = {
iconName: string;
title: string;
onPress: () => void;
style?: ViewStyle;
};

const SocialButton: React.FC<SocialButtonProps> = ({
iconName,
title,
onPress,
style,
}) => {
return (
<TouchableOpacity style={[styles.socialButton, style]} onPress={onPress}>
<AntDesign name={iconName} size={20} color="#6B8E23" />
<Text style={styles.buttonText}>{title}</Text>
</TouchableOpacity>
);
};

const styles = StyleSheet.create({
socialButton: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
padding: 12,
borderRadius: 4,
borderWidth: 1,
borderColor: "#6B8E23",
marginBottom: 12,
},
buttonText: {
color: "#6B8E23",
marginLeft: 10,
fontSize: 14,
fontWeight: "600",
textTransform: "uppercase",
},
});

export default SocialButton;
20 changes: 13 additions & 7 deletions packages/queue/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ describe("tests client subscription", () => {
clientID2 = uuid.v4();

// subscribe clients to a channel, return a promise and verify message/payload from resolved promise
subscribe({ pgClient: pgClient, channel: messageObj.channel, clientID: clientID1 }).then(emitter1 => {
subscribe({ pgClient: pgClient2, channel: messageObj.channel, clientID: clientID2 }).then(emitter2 => {

const promise1 = new Promise((resolve) => {
subscribe({
pgClient: pgClient,
channel: messageObj.channel,
clientID: clientID1,
}).then(emitter1 => {
subscribe({
pgClient: pgClient2,
channel: messageObj.channel,
clientID: clientID2,
}).then(emitter2 => {
const promise1 = new Promise(resolve => {
emitter1.on("message", message1 => {
expect(message1).toMatchObject(messageObj); // eslint-disable-line
expect(new Date(message1.ack[clientID1])).toBeInstanceOf(Date); // eslint-disable-line
resolve(message1);
});
});

const promise2 = new Promise((resolve) => {
const promise2 = new Promise(resolve => {
emitter2.on("message", message2 => {
expect(message2).toMatchObject(messageObj); // eslint-disable-line
expect(new Date(message2.ack[clientID2])).toBeInstanceOf(Date); // eslint-disable-line
Expand All @@ -48,9 +55,8 @@ describe("tests client subscription", () => {
Promise.all([promise1, promise2]).then(() => {
done();
});

});
})
});

// publish message to a given channel
publish({ pgClient, channel: messageObj.channel, data: messageObj.data });
Expand Down
9 changes: 3 additions & 6 deletions packages/queue/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const EventEmitter = require("events");

// subscribes a client to a channel
async function subscribe({ pgClient, clientID, channel }) {

const eventEmitter = new EventEmitter();

// subscribes a client to a channel
Expand All @@ -19,11 +18,9 @@ async function subscribe({ pgClient, clientID, channel }) {
const dateStr = date.toISOString();

// sends message receipt confirmation to DB
ack({ pgClient, id: newRow.id, dateStr, clientID }).then(
response => {
eventEmitter.emit("message", response[0]);
},
);
ack({ pgClient, id: newRow.id, dateStr, clientID }).then(response => {
eventEmitter.emit("message", response[0]);
});
});

return eventEmitter;
Expand Down
46 changes: 4 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -906,20 +906,7 @@
"@babel/parser" "^7.25.9"
"@babel/types" "^7.25.9"

"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3":
version "7.26.9"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.26.9.tgz#4398f2394ba66d05d988b2ad13c219a2c857461a"
integrity sha512-ZYW7L+pL8ahU5fXmNbPF+iZFHCv5scFak7MZ9bwaRPLUhHh7QQEMjZUg0HevihoqCM5iSYHN61EyCoZvqC+bxg==
dependencies:
"@babel/code-frame" "^7.26.2"
"@babel/generator" "^7.26.9"
"@babel/parser" "^7.26.9"
"@babel/template" "^7.26.9"
"@babel/types" "^7.26.9"
debug "^4.3.1"
globals "^11.1.0"

"@babel/traverse@^7.25.3", "@babel/traverse@^7.26.8", "@babel/traverse@^7.26.9":
"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3", "@babel/traverse@^7.25.3", "@babel/traverse@^7.26.8", "@babel/traverse@^7.26.9":
version "7.26.9"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.26.9.tgz#4398f2394ba66d05d988b2ad13c219a2c857461a"
integrity sha512-ZYW7L+pL8ahU5fXmNbPF+iZFHCv5scFak7MZ9bwaRPLUhHh7QQEMjZUg0HevihoqCM5iSYHN61EyCoZvqC+bxg==
Expand Down Expand Up @@ -12607,16 +12594,7 @@ string-length@^5.0.1:
char-regex "^2.0.0"
strip-ansi "^7.0.1"

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -12725,7 +12703,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -12739,13 +12717,6 @@ strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -13850,7 +13821,7 @@ word-wrap@^1.2.5:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -13868,15 +13839,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down