Vou criar o aplicativo PoupAmor conforme solicitado, aproveitando o site que você já desenvolveu.
Aplicativo PoupAmor - Controle Financeiro para Casais
Estrutura do Projeto
// Estrutura de pastas
poupamor/
├── mobile/
│ ├── src/
│ │ ├── screens/
│ │ │ ├── Home.js
│ │ │ ├── Dashboard.js
│ │ │ ├── Transactions.js
│ │ │ ├── ImportBill.js
│ │ │ ├── Settings.js
│ │ ├── components/
│ │ │ ├── TransactionForm.js
│ │ │ ├── Charts.js
│ │ │ ├── CategorySelector.js
│ │ │ ├── OCRScanner.js
│ │ ├── utils/
│ │ │ ├── ocrProcessor.js
│ │ │ ├── categoryDetector.js
│ │ │ ├── pdfParser.js
│ │ ├── theme/
│ │ │ ├── colors.js
│ │ │ ├── darkTheme.js
│ │ │ ├── lightTheme.js
│ ├── App.js
│ ├── package.json
├── web/
├── public/
├── src/
├── pages/
├── components/
├── utils/
├── theme/
├── App.js
├── index.js
Componente Principal do App Mobile
// App.js (React Native)
import React, { useState, useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { ThemeProvider } from 'styled-components/native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { StatusBar } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
// Screens
import Home from './src/screens/Home';
import Dashboard from './src/screens/Dashboard';
import Transactions from './src/screens/Transactions';
import ImportBill from './src/screens/ImportBill';
import Settings from './src/screens/Settings';
// Themes
import { lightTheme, darkTheme } from './src/theme';
const Tab = createBottomTabNavigator();
const App = () => {
const [isDarkMode, setIsDarkMode] = useState(false);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
// Carregar preferência de tema
const loadThemePreference = async () => {
try {
const savedTheme = await AsyncStorage.getItem('theme');
if (savedTheme !== null) {
setIsDarkMode(savedTheme === 'dark');
}
setIsLoading(false);
} catch (error) {
console.error('Erro ao carregar tema:', error);
setIsLoading(false);
}
};
loadThemePreference();
}, []);
const toggleTheme = async () => {
try {
const newTheme = !isDarkMode;
await AsyncStorage.setItem('theme', newTheme ? 'dark' : 'light');
setIsDarkMode(newTheme);
} catch (error) {
console.error('Erro ao salvar tema:', error);
}
};
if (isLoading) {
return null; // Ou um componente de loading
}
const theme = isDarkMode ? darkTheme : lightTheme;
return (
<ThemeProvider theme={theme}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={theme.background}
/>
<NavigationContainer>
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'Home') {
iconName = 'home';
} else if (route.name === 'Dashboard') {
iconName = 'chart-pie';
} else if (route.name === 'Transactions') {
iconName = 'cash-multiple';
} else if (route.name === 'ImportBill') {
iconName = 'file-upload';
} else if (route.name === 'Settings') {
iconName = 'cog';
}
return <Icon name={iconName} size={size} color={color} />;
},
tabBarActiveTintColor: theme.primary,
tabBarInactiveTintColor: theme.textSecondary,
tabBarStyle: {
backgroundColor: theme.cardBackground,
borderTopColor: theme.border,
},
headerStyle: {
backgroundColor: theme.cardBackground,
},
headerTintColor: theme.text,
})}
>
<Tab.Screen name="Home" component={Home} />
<Tab.Screen name="Dashboard" component={Dashboard} />
<Tab.Screen name="Transactions" component={Transactions} />
<Tab.Screen name="ImportBill" component={ImportBill} />
<Tab.Screen
name="Settings"
children={() => <Settings toggleTheme={toggleTheme} isDarkMode={isDarkMode} />}
/>
</Tab.Navigator>
</NavigationContainer>
</ThemeProvider>
);
};
export default App;
Componente de Importação de Faturas com OCR
// ImportBill.js
import React, { useState } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Image, ActivityIndicator } from 'react-native';
import { launchImageLibrary, launchCamera } from 'react-native-image-picker';
import DocumentPicker from 'react-native-document-picker';
import styled from 'styled-components/native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { processOCR } from '../utils/ocrProcessor';
import { detectCategories } from '../utils/categoryDetector';
import { parsePDF } from '../utils/pdfParser';
const ImportBill = ({ navigation }) => {
const [loading, setLoading] = useState(false);
const [fileUri, setFileUri] = useState(null);
const [fileType, setFileType] = useState(null);
const pickImage = async () => {
try {
const result = await launchImageLibrary({
mediaType: 'photo',
includeBase64: true,
maxHeight: 2000,
maxWidth: 2000,
});
if (!result.didCancel && result.assets && result.assets.length > 0) {
setFileUri(result.assets[0].uri);
setFileType('image');
processFile(result.assets[0].uri, 'image', result.assets[0].base64);
}
} catch (error) {
console.error('Erro ao selecionar imagem:', error);
}
};
const takePicture = async () => {
try {
const result = await launchCamera({
mediaType: 'photo',
includeBase64: true,
maxHeight: 2000,
maxWidth: 2000,
});
if (!result.didCancel && result.assets && result.assets.length > 0) {
setFileUri(result.assets[0].uri);
setFileType('image');
processFile(result.assets[0].uri, 'image', result.assets[0].base64);
}
} catch (error) {
console.error('Erro ao capturar imagem:', error);
}
};
const pickPDF = async () => {
try {
const result = await DocumentPicker.pick({
type: [DocumentPicker.types.pdf],
});
setFileUri(result[0].uri);
setFileType('pdf');
processFile(result[0].uri, 'pdf');
} catch (error) {
if (!DocumentPicker.isCancel(error)) {
console.error('Erro ao selecionar PDF:', error);
}
}
};
const processFile = async (uri, type, base64 = null) => {
setLoading(true);
try {
let extractedText;
if (type === 'image') {
extractedText = await processOCR(base64);
} else if (type === 'pdf') {
extractedText = await parsePDF(uri);
}
// Detectar categorias e valores
const categorizedData = await detectCategories(extractedText);
// Navegar para tela de revisão com os dados extraídos
navigation.navigate('TransactionReview', {
transactions: categorizedData,
source: uri
});
} catch (error) {
console.error('Erro ao processar arquivo:', error);
// Mostrar mensagem de erro
} finally {
setLoading(false);
}
};
return (
<Container>
<Title>Importar Fatura</Title>
<OptionsContainer>
<OptionButton onPress={pickImage}>
<Icon name="image" size={30} color="#4A90E2" />
<OptionText>Galeria</OptionText>
</OptionButton>
<OptionButton onPress={takePicture}>
<Icon name="camera" size={30} color="#50C878" />
<OptionText>Câmera</OptionText>
</OptionButton>
<OptionButton onPress={pickPDF}>
<Icon name="file-pdf-box" size={30} color="#E74C3C" />
<OptionText>PDF</OptionText>
</OptionButton>
</OptionsContainer>
{fileUri && !loading && (
<PreviewContainer>
{fileType === 'image' ? (
<PreviewImage source={{ uri: fileUri }} />
) : (
<PDFIcon>
<Icon name="file-pdf-box" size={60} color="#E74C3C" />
<Text>PDF selecionado</Text>
</PDFIcon>
)}
</PreviewContainer>
)}
{loading && (
<LoadingContainer>
<ActivityIndicator size="large" color="#4A90E2" />
<LoadingText>Processando arquivo...</LoadingText>
</LoadingContainer>
)}
<InfoText>
Importe faturas de cartão de crédito, contas ou recibos para categorização automática.
</InfoText>
</Container>
);
};
const Container = styled.View`
flex: 1;
padding: 20px;
background-color: ${props => props.theme.background};
`;
const Title = styled.Text`
font-size: 24px;
font-weight: bold;
margin-bottom: 20px;
color: ${props => props.theme.text};
`;
const OptionsContainer = styled.View`
flex-direction: row;
justify-content: space-around;
margin-bottom: 30px;
`;
const OptionButton = styled.TouchableOpacity`
align-items: center;
padding: 15px;
background-color: ${props => props.theme.cardBackground};
border-radius: 12px;
width: 100px;
elevation: 3;
`;
const OptionText = styled.Text`
margin-top: 8px;
color: ${props => props.theme.text};
`;
const PreviewContainer = styled.View`
align-items: center;
margin-bottom: 20px;
padding: 10px;
background-color: ${props => props.theme.cardBackground};
border-radius: 12px;
`;
const PreviewImage = styled.Image`
width: 300px;
height: 300px;
border-radius: 8px;
`;
const PDFIcon = styled.View`
align-items: center;
padding: 20px;
`;
const LoadingContainer = styled.View`
align-items: center;
margin: 20px 0;
`;
const LoadingText = styled.Text`
margin-top: 10px;
color: ${props => props.theme.text};
`;
const InfoText = styled.Text`
text-align: center;
margin-top: 20px;
color: ${props => props.theme.textSecondary};
`;
export default ImportBill;
Componente de Dashboard com Gráficos
// Dashboard.js
import React, { useState, useEffect } from 'react';
import { ScrollView, View, Text, TouchableOpacity } from 'react-native';
import styled from 'styled-components/native';
import { LineChart, PieChart, BarChart } from 'react-native-chart-kit';
import { Dimensions } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
const screenWidth = Dimensions.get('window').width;
const Dashboard = () => {
const [selectedPeriod, setSelectedPeriod] = useState('month');
const [selectedChart, setSelectedChart] = useState('overview');
const [transactions, setTransactions] = useState([]);
// Simulação de dados - em um app real, isso viria de uma API ou banco de dados local
useEffect(() => {
// Carregar transações do AsyncStorage ou API
const mockTransactions = [
{ id: 1, amount: 1200, type: 'income', category: 'Salário', date: '2025-07-01' },
{ id: 2, amount: 350, type: 'expense', category: 'Alimentação', date: '2025-07-05' },
{ id: 3, amount: 120, type: 'expense', category: 'Transporte', date: '2025-07-08' },
{ id: 4, amount: 800, type: 'expense', category: 'Moradia', date: '2025-07-10' },
{ id: 5, amount: 200, type: 'expense', category: 'Lazer', date: '2025-07-15' },
{ id: 6, amount: 150, type: 'expense', category: 'Saúde', date: '2025-07-18' },
{ id: 7, amount: 100, type: 'income', category: 'Freelance', date: '2025-07-20' },
];
setTransactions(mockTransactions);
}, []);
// Dados para o gráfico de linha (evolução de gastos)
const lineChartData = {
labels: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul'],
datasets: [
{
data: [1500, 1700, 1600, 1800, 1550, 1650, 1620],
color: (opacity = 1) => `rgba(74, 144, 226, ${opacity})`,
strokeWidth: 2
},
{
data: [1200, 1300, 1250, 1400,