slight refactor of all the code, made it so that login and onboarding works, need to add system to validate connections to google photos + NAS before just blindly accepting

Added library home page and navigation bar at the bottom, using emojis as icon placeholders, album page also works.

elipses for settings and icon also work.
This commit is contained in:
bobbert committed 2026-02-21 13:52:28 +00:00
1 parent 37511780b7
commit c1d7139055
17 files changed
+1431 -10040

No files matched your search

+54 -134
View File
@@ -2,80 +2,68 @@ import { AuthServiceBase } from './AuthServiceBase';
/**
* Google Photos Authentication Service
* Handles OAuth2 authentication with Google Photos API
*
* Uses placeholder tokens for now.
* To enable real Google OAuth, set up a Google Cloud project with Photos Library API,
* create OAuth 2.0 credentials, and replace GOOGLE_CLIENT_ID below.
*
* Real OAuth flow uses expo-auth-session + expo-web-browser.
*/
// TODO: Replace with your real Google Cloud OAuth Client ID
const GOOGLE_CLIENT_ID = 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com';
class GoogleAUTH extends AuthServiceBase {
constructor() {
super();
this.accessToken = null;
this.refreshToken = null;
this.expiresAt = null;
this.email = null;
}
/**
* Authenticate with Google OAuth
* In a real app, you would use Google Sign-In library
* Authenticate with Google
* Currently uses placeholder tokens. Replace with real OAuth when client ID is configured.
*/
async authenticate(authCode) {
async authenticate() {
try {
// Validate input
if (!authCode) {
throw new Error('Authorization code is required');
if (GOOGLE_CLIENT_ID === 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com') {
// Placeholder mode - no real client ID configured
console.log('Google Auth: Using placeholder mode (no client ID configured)');
this.accessToken = 'placeholder_google_token_' + Date.now();
this.refreshToken = 'placeholder_refresh_' + Date.now();
this.expiresAt = Date.now() + 3600000;
this.email = 'google-user';
return {
success: true,
accessToken: this.accessToken,
refreshToken: this.refreshToken,
email: this.email,
};
}
// TODO: Implement actual Google OAuth flow
// This would typically involve:
// 1. Initiating Google Sign-In
// 2. Getting the authorization code
// 3. Exchanging it for access and refresh tokens
console.log('Authenticating with Google...');
// Placeholder: In production, exchange authCode for tokens
this.accessToken = 'google_access_token_placeholder';
this.refreshToken = 'google_refresh_token_placeholder';
this.expiresAt = Date.now() + 3600000; // 1 hour from now
return {
success: true,
message: 'Google authentication successful',
accessToken: this.accessToken,
};
// Real OAuth flow would go here using expo-auth-session
// const discovery = { authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth', tokenEndpoint: 'https://oauth2.googleapis.com/token' };
// Use AuthSession.makeRedirectUri() and AuthSession.useAuthRequest()
throw new Error('Google OAuth client ID configured but real OAuth flow not yet implemented');
} catch (error) {
console.error('Google authentication error:', error);
throw error;
}
}
/**
* Get current access token
*/
async getAccessToken() {
if (this.accessToken && this.expiresAt > Date.now()) {
return this.accessToken;
}
// If token is expired, refresh it
if (this.refreshToken) {
return await this.refreshToken();
}
throw new Error('No valid access token available');
if (this.accessToken && this.expiresAt > Date.now()) return this.accessToken;
throw new Error('No valid Google access token');
}
/**
* Refresh the access token using refresh token
*/
async refreshToken() {
async refreshAccessToken() {
try {
if (!this.refreshToken) {
throw new Error('No refresh token available');
}
// TODO: Implement actual token refresh with Google API
console.log('Refreshing Google access token...');
// Placeholder: In production, call Google token endpoint
this.accessToken = 'new_google_access_token_placeholder';
this.accessToken = 'refreshed_google_token_' + Date.now();
this.expiresAt = Date.now() + 3600000;
return this.accessToken;
} catch (error) {
console.error('Token refresh error:', error);
@@ -83,111 +71,43 @@ class GoogleAUTH extends AuthServiceBase {
}
}
/**
* Revoke access and clear tokens
*/
async revokeAccess() {
try {
// TODO: Implement actual revocation with Google API
console.log('Revoking Google access...');
this.accessToken = null;
this.refreshToken = null;
this.expiresAt = null;
return {
success: true,
message: 'Google access revoked',
};
} catch (error) {
console.error('Revoke error:', error);
throw error;
}
this.accessToken = null;
this.refreshToken = null;
this.expiresAt = null;
this.email = null;
return { success: true };
}
/**
* Get user info from Google
*/
async getUserInfo() {
try {
const token = await this.getAccessToken();
// TODO: Implement actual API call to Google People API
console.log('Fetching user info from Google...');
// Placeholder user info
return {
id: 'google_user_id_placeholder',
email: 'user@gmail.com',
name: 'Google User',
photoUrl: 'https://via.placeholder.com/150',
};
} catch (error) {
console.error('Get user info error:', error);
throw error;
}
return {
id: 'google_user',
email: this.email || 'unknown',
name: 'Google User',
};
}
/**
* Get media list from Google Photos
*/
async getPhotos(pageSize = 50, pageToken = null) {
async getPhotos(pageSize = 50) {
try {
const token = await this.getAccessToken();
// TODO: Implement actual API call to Google Photos API
console.log('Fetching photos from Google Photos...');
// Placeholder response
return {
mediaItems: [],
nextPageToken: null,
};
await this.getAccessToken();
// In production: call Google Photos API
// https://photoslibrary.googleapis.com/v1/mediaItems
return { mediaItems: [], nextPageToken: null };
} catch (error) {
console.error('Get photos error:', error);
throw error;
}
}
/**
* Get albums from Google Photos
*/
async getAlbums(pageSize = 50, pageToken = null) {
async getAlbums() {
try {
const token = await this.getAccessToken();
// TODO: Implement actual API call to Google Photos API
console.log('Fetching albums from Google Photos...');
return {
albums: [],
nextPageToken: null,
};
await this.getAccessToken();
return { albums: [], nextPageToken: null };
} catch (error) {
console.error('Get albums error:', error);
throw error;
}
}
/**
* Search photos by date range
*/
async searchPhotos(filters = {}) {
try {
const token = await this.getAccessToken();
// TODO: Implement actual API call with filters
console.log('Searching photos with filters:', filters);
return {
mediaItems: [],
nextPageToken: null,
};
} catch (error) {
console.error('Search photos error:', error);
throw error;
}
}
}
export default GoogleAUTH;