Skip to content

Commit 1e56137

Browse files
authored
Implement Email/Password Authentication with Clean UI (#9)
* feat: Update frontend package and add authentication screens - Changed project name in package.json to "splitwiser" and updated main entry point. - Updated dependencies to newer versions for better performance and security. - Added HomeScreen component for user profile display and logout functionality. - Created LoginScreen component for user authentication with email/password and Google sign-in options. - Modified tsconfig.json for improved TypeScript support and configuration. * feat: update app configuration and remove deprecated Google authentication code * fix: updates the package.json * feat(auth): enhance login/signup error handling and add basic form validation
1 parent a0e221a commit 1e56137

34 files changed

+13144
-11400
lines changed

frontend/.gitignore

Lines changed: 0 additions & 39 deletions
This file was deleted.

frontend/App.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { NavigationContainer } from '@react-navigation/native';
2+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
3+
import { StatusBar } from 'expo-status-bar';
4+
5+
import { AuthProvider, useAuth } from './contexts/AuthContext';
6+
import HomeScreen from './screens/HomeScreen';
7+
import LoginScreen from './screens/LoginScreen';
8+
9+
const Stack = createNativeStackNavigator();
10+
11+
function AppNavigator() {
12+
const { isAuthenticated } = useAuth();
13+
14+
return (
15+
<Stack.Navigator>
16+
{isAuthenticated ? (
17+
<Stack.Screen
18+
name="Home"
19+
component={HomeScreen}
20+
options={{ title: 'Splitwiser' }}
21+
/>
22+
) : (
23+
<Stack.Screen
24+
name="Login"
25+
component={LoginScreen}
26+
options={{ headerShown: false }}
27+
/>
28+
)}
29+
</Stack.Navigator>
30+
);
31+
}
32+
33+
export default function App() {
34+
return (
35+
<AuthProvider>
36+
<NavigationContainer>
37+
<AppNavigator />
38+
<StatusBar style="auto" />
39+
</NavigationContainer>
40+
</AuthProvider>
41+
);
42+
}

frontend/README.md

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,79 @@
1-
# Welcome to your Expo app 👋
1+
# Splitwiser Frontend
22

3-
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
3+
A React Native (Expo) application for the Splitwiser bill-splitting app.
44

5-
## Get started
5+
## Features
66

7-
1. Install dependencies
7+
- User authentication (email/password and Google Sign-in)
8+
- Login and signup screens
9+
- JWT authentication with refresh token mechanism
10+
- Secure token storage
811

9-
```bash
10-
npm install
11-
```
12+
## Getting Started
1213

13-
2. Start the app
14+
### Prerequisites
1415

15-
```bash
16-
npx expo start
17-
```
16+
- Node.js (v14 or later)
17+
- npm or yarn
18+
- Expo CLI (`npm install -g expo-cli`)
1819

19-
In the output, you'll find options to open the app in a
20+
### Installation
2021

21-
- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
22-
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
23-
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
24-
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
22+
1. Install dependencies:
2523

26-
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
24+
```bash
25+
cd frontend
26+
npm install
27+
# or
28+
yarn install
29+
```
2730

28-
## Get a fresh project
31+
2. Configure environment variables:
32+
33+
- Update the API_URL in `contexts/AuthContext.tsx` with your backend URL.
34+
- Update the `WEB_CLIENT_ID` in `config/firebase.tsx` with your Firebase Web Client ID.
2935

30-
When you're ready, run:
36+
3. Start the development server:
3137

3238
```bash
33-
npm run reset-project
39+
npm start
40+
# or
41+
yarn start
42+
# or
43+
npx expo start
3444
```
3545

36-
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
46+
### Running on Physical Device
47+
48+
1. Install Expo Go app on your iOS or Android device
49+
2. Scan the QR code shown in the terminal after running `npm start`
50+
51+
### Running on Emulator
3752

38-
## Learn more
53+
- For Android: Press 'a' in the terminal after starting the development server
54+
- For iOS: Press 'i' in the terminal (requires macOS and Xcode)
3955

40-
To learn more about developing your project with Expo, look at the following resources:
56+
## Authentication Flow
4157

42-
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
43-
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
58+
This app follows the authentication flow as described in [auth-service.md](../docs/auth-service.md):
4459

45-
## Join the community
60+
1. **Email/Password Authentication**
61+
- Sign up with email, password, and name
62+
- Login with email and password
63+
64+
2. **Google Authentication**
65+
- Uses Firebase for Google authentication
66+
- Sends the ID token to the backend for verification
67+
68+
3. **Token Management**
69+
- Stores access tokens in memory
70+
- Stores refresh tokens securely using Expo SecureStore
71+
- Auto-refreshes expired tokens
72+
- Handles token rotation
4673

47-
Join our community of developers creating universal apps.
74+
## Project Structure
4875

49-
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
50-
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
76+
- `/screens` - React Native screens (LoginScreen, HomeScreen)
77+
- `/contexts` - React Context for global state management (AuthContext)
78+
- `/config` - Configuration files (Firebase)
79+
- `/assets` - Images and other static assets

frontend/app.json

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,32 @@
11
{
22
"expo": {
3-
"name": "frontend",
4-
"slug": "frontend",
3+
"name": "Splitwiser",
4+
"slug": "splitwiser",
55
"version": "1.0.0",
66
"orientation": "portrait",
7-
"icon": "./assets/images/icon.png",
8-
"scheme": "frontend",
9-
"userInterfaceStyle": "automatic",
10-
"newArchEnabled": true,
7+
"icon": "./assets/icon.png",
8+
"userInterfaceStyle": "light",
9+
"scheme": "splitwiser",
10+
"splash": {
11+
"image": "./assets/splash.png",
12+
"resizeMode": "contain",
13+
"backgroundColor": "#ffffff"
14+
},
15+
"assetBundlePatterns": [
16+
"**/*"
17+
],
1118
"ios": {
1219
"supportsTablet": true
13-
},
14-
"android": {
20+
}, "android": {
1521
"adaptiveIcon": {
16-
"foregroundImage": "./assets/images/adaptive-icon.png",
22+
"foregroundImage": "./assets/adaptive-icon.png",
1723
"backgroundColor": "#ffffff"
1824
},
19-
"edgeToEdgeEnabled": true,
20-
"package": "com.vrajpatelll.frontend"
25+
"googleServicesFile": "./google-services.json",
26+
"package": "splitwiser.app"
2127
},
2228
"web": {
23-
"bundler": "metro",
24-
"output": "static",
25-
"favicon": "./assets/images/favicon.png"
26-
},
27-
"plugins": [
28-
"expo-router",
29-
[
30-
"expo-splash-screen",
31-
{
32-
"image": "./assets/images/splash-icon.png",
33-
"imageWidth": 200,
34-
"resizeMode": "contain",
35-
"backgroundColor": "#ffffff"
36-
}
37-
],
38-
"expo-web-browser"
39-
],
40-
"experiments": {
41-
"typedRoutes": true
42-
},
43-
"extra": {
44-
"router": {},
45-
"eas": {
46-
"projectId": "45b14924-7fce-48f7-b527-5a6a12f2d64f"
47-
}
29+
"favicon": "./assets/favicon.png"
4830
}
4931
}
5032
}

frontend/app/(auth)/_layout.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

frontend/app/(auth)/components/GoogleSignInButton.tsx

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)