feat: Introduce financial goal and asset management with SQLite and NativeWind integration, new tab screens, and updated dependencies.

This commit is contained in:
2025-11-19 23:01:03 +00:00
parent 60360e8eb9
commit e002d0d1fd
21 changed files with 11538 additions and 98 deletions

54
db/index.ts Normal file
View File

@@ -0,0 +1,54 @@
import { openDatabaseSync } from 'expo-sqlite';
import { Platform } from 'react-native';
let db: any;
if (Platform.OS !== 'web') {
db = openDatabaseSync('finance.db');
} else {
// Mock DB for web to prevent crash
db = {
execSync: () => { },
getAllAsync: async () => [],
runAsync: async () => { },
getFirstAsync: async () => null,
};
}
export const initDatabase = () => {
try {
db.execSync(`
CREATE TABLE IF NOT EXISTS transactions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
amount REAL NOT NULL,
category TEXT NOT NULL,
date TEXT NOT NULL,
description TEXT,
type TEXT NOT NULL -- 'income' or 'expense'
);
CREATE TABLE IF NOT EXISTS assets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
type TEXT NOT NULL, -- 'stock', 'crypto', 'real_estate', etc.
value REAL NOT NULL,
quantity REAL,
purchase_date TEXT
);
CREATE TABLE IF NOT EXISTS goals (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
target_amount REAL NOT NULL,
current_amount REAL NOT NULL DEFAULT 0,
deadline TEXT
);
`);
console.log('Database initialized successfully');
return Promise.resolve(true);
} catch (error) {
console.error('Error initializing database', error);
return Promise.reject(error);
}
};
export const getDB = () => db;