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

Onboarding Screen #33

Merged
merged 32 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c60bddb
supabase init
Naveen-g09 Mar 24, 2024
294db3e
config keys
Naveen-g09 Mar 24, 2024
eaca316
some fixes
Naveen-g09 Mar 24, 2024
71717da
minor dependency fix
Naveen-g09 Mar 24, 2024
b68a971
little fix
Naveen-g09 Mar 24, 2024
df0fefb
something
Naveen-g09 Mar 24, 2024
9b8bdc5
nice
Naveen-g09 Mar 24, 2024
b455596
minor fix
Naveen-g09 Mar 24, 2024
bc9acbe
nice
Naveen-g09 Mar 24, 2024
e8fa642
build fix
Naveen-g09 Mar 24, 2024
71a7f33
dont know
Naveen-g09 Mar 24, 2024
ee71c51
init
Naveen-g09 Mar 24, 2024
df12641
Merge branch 'supabase' into onboarding
Naveen-g09 Mar 24, 2024
fa6cab7
Revert "init"
Naveen-g09 Mar 25, 2024
70afd63
bit of authentication
Naveen-g09 Mar 25, 2024
8c082cc
minor lint fix
Naveen-g09 Mar 25, 2024
dd3d7ff
adding onboarding
Naveen-g09 Mar 25, 2024
30b6906
little config
Naveen-g09 Mar 25, 2024
20c0802
little bit of this and that
Naveen-g09 Mar 25, 2024
3be815e
minor fix
Naveen-g09 Mar 25, 2024
dca2520
nice hai
Naveen-g09 Mar 26, 2024
d46af05
harcoding the api keys to test
Naveen-g09 Mar 26, 2024
8d5322e
login and logout feature
Naveen-g09 Mar 26, 2024
9d13793
eod
Naveen-g09 Mar 26, 2024
5aa6aa5
style update
Naveen-g09 Mar 26, 2024
970c748
eod
Naveen-g09 Mar 26, 2024
1d0c184
adding header
Naveen-g09 Mar 27, 2024
e802709
dumbness at peak
Naveen-g09 Mar 27, 2024
0df2af9
Revert "eod"
Naveen-g09 Mar 27, 2024
bb8a51a
chore finish auth
Naveen-g09 Mar 27, 2024
dfdd792
Merge pull request #31 from Naveen-g09/supabase
Naveen-g09 Mar 27, 2024
7258472
Merge branch 'onboarding' of https://github.com/Naveen-g09/Residentro…
Naveen-g09 Mar 27, 2024
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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EXPO_PUBLIC_SUPABASE_URL="https://hnmqvjnnscdkcbxcbvyu.supabase.co"
EXPO_PUBLIC_SUPABASE_ANON_KEY= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhubXF2am5uc2Nka2NieGNidnl1Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTEyOTgxMjMsImV4cCI6MjAyNjg3NDEyM30.xjzSaG22KLkzskY4U3NaohE_RLTLTkeTW_2qD5RFPUc"
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EXPO_PUBLIC_SUPABASE_URL=
EXPO_PUBLIC_SUPABASE_ANON_KEY=
39 changes: 37 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,43 @@ yarn-error.*
# typescript
*.tsbuildinfo

# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
# @generated expo-cli sync-b5df6a44d8735348b729920a7406b633cfb74d4c
# The following patterns were generated by expo-cli

expo-env.d.ts
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo

# @end expo-cli
1 change: 1 addition & 0 deletions app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="nativewind/types" />
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"plugins": ["expo-router"],
"experiments": {
"typedRoutes": false
"typedRoutes": true
},
"extra": {
"router": {
Expand All @@ -45,7 +45,7 @@
"policy": "appVersion"
},
"updates": {
"url": "https://u.expo.dev/a85a4ec3-52c3-42a4-9158-fa4c62823448"
"url": "https://u.expo.dev/c60ed383-fb7e-4a56-a589-acae0e73b49f"
},
"owner": "cheetah-works"
}
Expand Down
6 changes: 6 additions & 0 deletions app/(auth)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Slot } from "expo-router";
import React from "react";

export default function AuthLayout() {
return <Slot />;
}
120 changes: 120 additions & 0 deletions app/(auth)/login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { Stack } from "expo-router";
import React, { useState } from "react";
import { Alert, StyleSheet, TextInput, View, Text } from "react-native";
import { TouchableOpacity } from "react-native-gesture-handler";

import { supabase } from "../lib/supabase-client";

export default function AuthPage() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [loading, setLoading] = useState(false);

async function signInWithEmail() {
setLoading(true);
const { error } = await supabase.auth.signInWithPassword({
email,
password,
});

if (error) Alert.alert("Sign In Error", error.message);
setLoading(false);
}

async function signUpWithEmail() {
setLoading(true);
const { error } = await supabase.auth.signUp({
email,
password,
});

if (error) Alert.alert("Sign Up Error", error.message);
setLoading(false);
}

return (
<View style={styles.container}>
<Stack.Screen options={{ headerShown: true, title: "Residentron" }} />
<View style={[styles.verticallySpaced, styles.mt20]}>
<TextInput
style={styles.textInput}
onChangeText={(text) => setEmail(text)}
value={email}
placeholder="[email protected]"
autoCapitalize="none"
/>
</View>
<View style={styles.verticallySpaced}>
<TextInput
style={styles.textInput}
onChangeText={(text) => setPassword(text)}
value={password}
secureTextEntry
placeholder="Password"
autoCapitalize="none"
/>
</View>
<View style={[styles.verticallySpaced, styles.mt20]}>
<TouchableOpacity
disabled={loading}
onPress={() => signInWithEmail()}
style={styles.buttonContainer}
>
<Text style={styles.buttonText}>SIGN IN</Text>
</TouchableOpacity>
</View>
<View style={styles.verticallySpaced}>
<TouchableOpacity
disabled={loading}
onPress={() => signUpWithEmail()}
style={styles.buttonContainer}
>
<Text style={styles.buttonText}>SIGN UP</Text>
</TouchableOpacity>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
backgroundColor: "powderblue",
paddingHorizontal: 20,
},
verticallySpaced: {
paddingTop: 8,
paddingBottom: 8,
alignSelf: "stretch",
},
mt20: {
marginTop: 20,
},
buttonContainer: {
backgroundColor: "#0052cc",
borderRadius: 10,
paddingVertical: 12,
paddingHorizontal: 16,
margin: 8,
elevation: 4, // Add elevation for a raised effect
},
buttonText: {
fontSize: 18,
color: "#fff",
fontWeight: "bold",
alignSelf: "center",
textTransform: "uppercase",
},
textInput: {
backgroundColor: "#f0f0f0", // Light background color for input field
borderColor: "#ccc",
borderRadius: 8,
borderWidth: 1,
paddingVertical: 12,
paddingHorizontal: 16,
margin: 8,
width: "100%",
},
});
83 changes: 83 additions & 0 deletions app/(settings)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Stack } from "expo-router";
import React, { useEffect, useState } from "react";
import {
SafeAreaView,
Text,
View,
TouchableOpacity,
StyleSheet,
Alert,
} from "react-native";

import { supabase } from "@/app/lib/supabase-client";

export default function SettingsPage() {
const [user, setUser] = useState(null);
useEffect(() => {
supabase.auth
.getUser()
.then(({ data: { user } }: { data: { user: any } }) => {
if (user) {
setUser(user);
} else {
Alert.alert("Error Accessing User");
}
});
}, []);

const doLogout = async () => {
const { error } = await supabase.auth.signOut();
if (error) {
Alert.alert("Error Signing Out User", error.message);
}
};

return (
<SafeAreaView style={{ flex: 1 }}>
<Stack.Screen options={{ headerShown: true, title: "Settings" }} />
<View style={{ padding: 16 }}>
<Text>{JSON.stringify(user, null, 2)}</Text>
<TouchableOpacity onPress={doLogout} style={styles.buttonContainer}>
<Text style={styles.buttonText}>LOGOUT</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
);
}

const styles = StyleSheet.create({
container: {
marginTop: 40,
padding: 12,
},
verticallySpaced: {
paddingTop: 4,
paddingBottom: 4,
alignSelf: "stretch",
},
mt20: {
marginTop: 20,
},
buttonContainer: {
backgroundColor: "#000968",
borderRadius: 10,
paddingVertical: 10,
paddingHorizontal: 12,
margin: 8,
},
buttonText: {
fontSize: 18,
color: "#fff",
fontWeight: "bold",
alignSelf: "center",
textTransform: "uppercase",
},
textInput: {
borderColor: "#000968",
borderRadius: 4,
borderStyle: "solid",
borderWidth: 1,
padding: 12,
margin: 8,
},
});
35 changes: 28 additions & 7 deletions app/(tabs)/account.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { BottomSheetModal, useBottomSheetModal } from "@gorhom/bottom-sheet";
import React, { useRef } from "react";
import React, { useEffect, useState, useRef } from "react";
import {
Text,
TouchableOpacity,
ScrollView,
StyleSheet,
Alert,
ScrollView,
Button,
} from "react-native";

import AccountSheet from "../../components/bottomSheet";

import { supabase } from "@/app/lib/supabase-client";

//TODO: add a notification icon
//TODO: add a profile icon
//TODO: details grids of profile picture, name, email, phone number, address, and edit button
Expand All @@ -22,12 +25,31 @@
const { dismiss } = useBottomSheetModal();
const handleOpenPress = () => bottomSheetRef.current?.present();

const [user, setUser] = useState(null);

Check warning on line 28 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

'user' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 28 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

'user' is assigned a value but never used
useEffect(() => {
supabase.auth
.getUser()
.then(({ data: { user } }: { data: { user: any } }) => {
if (user) {
setUser(user);
} else {
Alert.alert("Error Accessing User");
}
});
}, []);

const doLogout = async () => {
const { error } = await supabase.auth.signOut();
if (error) {
Alert.alert("Error Signing Out User", error.message);
}
};

return (
<ScrollView contentContainerStyle={styles.container}>
<TouchableOpacity style={styles.button} onPress={handleOpenPress}>
<Text style={styles.buttonText}>Personal Details</Text>
</TouchableOpacity>

<TouchableOpacity style={styles.button} onPress={handleOpenPress}>
<Text style={styles.buttonText}>Transactions</Text>
</TouchableOpacity>
Expand All @@ -43,10 +65,9 @@
<TouchableOpacity style={styles.button} onPress={handleOpenPress}>
<Text style={styles.buttonText}>Calendar</Text>
</TouchableOpacity>

{/* <TouchableOpacity style={styles.button} onPress={handleOpenPress}>
<Text style={styles.buttonText}> Edit Access</Text>
</TouchableOpacity> */}
<TouchableOpacity onPress={doLogout} style={styles.button}>
<Text style={styles.buttonText}>LOGOUT</Text>
</TouchableOpacity>

<Button title="Dismiss" onPress={() => dismiss()} />

Expand Down
16 changes: 12 additions & 4 deletions app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { Link } from "expo-router";
import React from "react";
import React, { useEffect } from "react";
import { Text, ScrollView, TouchableOpacity, StyleSheet } from "react-native";

import { storage } from "@/utils/mmkvHelpers";

//TODO: this is homepage of the app
//TODO: add a notification icon
//TODO: it will have details of the society, details of the resident, details of the flat, details of the family members, details of the parking, details of the utilities, details of the maintenance, details of the bills, details of the orders, details of the payments, details of the receipts, details of the complaints, details of the suggestions, details of the feedbacks, details of the polls, details of the announcements, details of the notices, details of the chats, details of the events, details of the posts, details of the category, details of the community, details of the account, details of the index
//TODO: options of payment dues, gate updates, guest notification, help, etc
//TODO: in notification component it will push notifications of payment dues, gate updates, guest notification, help, etc

const index = () => {
export const Index = () => {
useEffect(() => {
// storage.clearAll();
const keys = storage.getAllKeys();
//fetch keys as per chatcard id
if (!keys.length) {
}
});

return (
<ScrollView contentContainerStyle={styles.container}>
<Link href="/(tabs)/visitors" asChild>
Expand Down Expand Up @@ -75,5 +85,3 @@ const styles = StyleSheet.create({
fontWeight: "bold",
},
});

export default index;
Loading
Loading