diff --git a/src/screens/AddBankAccount/AddBankAccount.js b/src/components/Forms/AddAccount.js
similarity index 88%
rename from src/screens/AddBankAccount/AddBankAccount.js
rename to src/components/Forms/AddAccount.js
index 8206176..7723b76 100644
--- a/src/screens/AddBankAccount/AddBankAccount.js
+++ b/src/components/Forms/AddAccount.js
@@ -3,9 +3,9 @@ import { View, Text, TextInput, Button, Alert } from "react-native";
import { addAccounts } from "../../utils/storageAccounts.js";
-import styles from "./styles.js";
+import styles from "../../styles/styles";
-function AddBankAccount({ navigation }) {
+function AddAccount({ navigation }) {
const [name, setName] = useState("");
const [bank, setbank] = useState("");
const [balance, setbalance] = useState(0.0);
@@ -77,16 +77,9 @@ function AddBankAccount({ navigation }) {
-
);
}
-export default AddBankAccount;
+export default AddAccount;
diff --git a/src/screens/Add/TransactionForm.js b/src/components/Forms/AddTransaction.js
similarity index 98%
rename from src/screens/Add/TransactionForm.js
rename to src/components/Forms/AddTransaction.js
index e07f245..45d6c29 100644
--- a/src/screens/Add/TransactionForm.js
+++ b/src/components/Forms/AddTransaction.js
@@ -3,7 +3,7 @@ import { View, Text, TextInput, TouchableOpacity, Alert } from "react-native";
import DateTimePicker from "@react-native-community/datetimepicker";
import { Picker } from "@react-native-picker/picker";
-import styles from "./styles.js";
+import styles from "../../styles/AddTransactionStyle";
import { addRevenuesAndExpenses } from "../../utils/storage.js";
import { useAccountsCardStore } from "../../stores/CardsStore.js";
diff --git a/src/screens/EditBankAccount/EditBankAccount.js b/src/components/Forms/EditAccount.js
similarity index 94%
rename from src/screens/EditBankAccount/EditBankAccount.js
rename to src/components/Forms/EditAccount.js
index b611907..6bac508 100644
--- a/src/screens/EditBankAccount/EditBankAccount.js
+++ b/src/components/Forms/EditAccount.js
@@ -1,11 +1,10 @@
import React, { useState } from "react";
import { View, Text, TextInput, Button } from "react-native";
+import styles from "../../styles/EditFormsStyle";
import {updateAccounts} from "../../utils/storageAccounts";
-import styles from "./styles";
-
-const EditBankAccount = ({ route, navigation }) => {
+const EditAccount = ({ route, navigation }) => {
const { index, account } = route.params;
const [name, setName] = useState(account.name);
const [bank, setBank] = useState(account.bank);
@@ -84,4 +83,4 @@ const EditBankAccount = ({ route, navigation }) => {
);
};
-export default EditBankAccount;
+export default EditAccount;
diff --git a/src/screens/ExtractDetail/formEdit.js b/src/components/Forms/EditTransaction.js
similarity index 97%
rename from src/screens/ExtractDetail/formEdit.js
rename to src/components/Forms/EditTransaction.js
index 6a1039b..fb05f09 100644
--- a/src/screens/ExtractDetail/formEdit.js
+++ b/src/components/Forms/EditTransaction.js
@@ -9,10 +9,10 @@ import {
} from "react-native";
import DateTimePicker from '@react-native-community/datetimepicker';
-import styles from "./stylesForms.js";
+import styles from "../../styles/EditFormsStyle.js"
import { updateRevenuesAndExpenses } from "../../utils/storage.js";
-export default function EditForm({ route, navigation }) {
+export default function EditTransaction({ route, navigation }) {
const { transaction, index } = route.params;
const [name, setName] = useState(transaction.name);
const [value, setValue] = useState(transaction.value.toString());
diff --git a/src/routes/AddAccount.js b/src/routes/AddAccount.js
deleted file mode 100644
index 602cc9c..0000000
--- a/src/routes/AddAccount.js
+++ /dev/null
@@ -1,47 +0,0 @@
-import React from "react";
-
-import { createStackNavigator } from "@react-navigation/stack";
-
-import Accounts from "../screens/Accounts/Accounts";
-import AddCreditCard from "../screens/AddCreditCard/AddCreditCard";
-import AddBankAccount from "../screens/AddBankAccount/AddBankAccount";
-import DetailBankAccount from "../screens/DetailBankAccount/DetailBankAccount";
-import DetailCreditCard from "../screens/DetailCreditCard/DetailCreditCard";
-import EditBankAccount from "../screens/EditBankAccount/EditBankAccount";
-import EditCreditCard from "../screens/EditCreditCard/EditCreditCard";
-import ViewCard from "../screens/ViewCard/ViewCard";
-
-const Stack = createStackNavigator();
-
-export function AddRoute() {
- return (
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/src/routes/ExtractRoute.js b/src/routes/ExtractRoute.js
index 76a90c3..8d19058 100644
--- a/src/routes/ExtractRoute.js
+++ b/src/routes/ExtractRoute.js
@@ -2,8 +2,9 @@ import React from "react";
import { createStackNavigator } from "@react-navigation/stack";
import ExtractS from "../screens/Extract/Extract";
-import ExtractDetail from "../screens/ExtractDetail/ExtractDetail";
-import EditForm from "../screens/ExtractDetail/formEdit";
+import DetailTransaction from "../screens/DetailTransaction/DetailTransaction";
+import EditTransaction from "../components/Forms/EditTransaction";
+import FormsScreen from "../screens/FormsScreen/FormsScreen";
const Stack = createStackNavigator();
@@ -11,8 +12,9 @@ export function ExtractRoute() {
return (
-
-
+
+
+
);
}
diff --git a/src/routes/Main.js b/src/routes/Main.js
index d3c5bdc..d4135a0 100644
--- a/src/routes/Main.js
+++ b/src/routes/Main.js
@@ -3,16 +3,14 @@ import { NavigationContainer } from "@react-navigation/native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import Home from "../screens/Home/Home.js";
-import { AddRoute } from "./AddAccount.js";
+import { AddRoute } from "./RouteAccounts.js";
import { ExtractRoute } from "./ExtractRoute.js";
-import Add from "../screens/Add/Add";
import { LogoTitle } from "../components/LogoTitle.js";
import HomeIcon from "../assets/home.svg";
import ExtratoIcon from "../assets/extract.svg";
import ContasIcon from "../assets/accounts.svg";
-import AddIcon from "../assets/add.svg";
const Tab = createBottomTabNavigator();
@@ -42,8 +40,6 @@ export function MainRoute() {
return ;
case "Accounts":
return ;
- case "Add":
- return ;
default:
return null;
}
@@ -68,24 +64,22 @@ export function MainRoute() {
>
{(props) => }
-
-
-
+
+ headerStyle: { backgroundColor: "#2196f3" },
+ headerTintColor: "#fff",
+ }}
+ component={AddRoute}
+ />
);
diff --git a/src/routes/RouteAccounts.js b/src/routes/RouteAccounts.js
new file mode 100644
index 0000000..957a16d
--- /dev/null
+++ b/src/routes/RouteAccounts.js
@@ -0,0 +1,23 @@
+import React from "react";
+
+import { createStackNavigator } from "@react-navigation/stack";
+
+import Accounts from "../screens/Accounts/Accounts";
+import FormsScreen from "../screens/FormsScreen/FormsScreen";
+import AddAccount from "../components/Forms/AddAccount";
+import DetailAccount from "../screens/DetailAccount/DetailAccount";
+import EditAccount from "../components/Forms/EditAccount";
+
+const Stack = createStackNavigator();
+
+export function AddRoute() {
+ return (
+
+
+
+
+
+
+
+ );
+}
diff --git a/src/screens/Accounts/Accounts.js b/src/screens/Accounts/Accounts.js
index b12d4d1..603bd66 100644
--- a/src/screens/Accounts/Accounts.js
+++ b/src/screens/Accounts/Accounts.js
@@ -1,168 +1,58 @@
-import React, { useState, useEffect } from "react";
-import { View, Text, ScrollView, TouchableOpacity, Alert } from "react-native";
-import { useNavigation, useFocusEffect } from "@react-navigation/native";
-import AsyncStorage from "@react-native-async-storage/async-storage";
+import React, { useEffect } from "react";
+import { View, Text, TouchableOpacity } from "react-native";
import AddIcon from "../../assets/add.svg";
-import EditIcon from "../../assets/edit.svg";
-import DeleteIcon from "../../assets/delete_white.svg";
-import styles from "./styles.js";
-
-import { useAccountsStore } from "../../stores/AccountsStore.js";
-import { useCardStore } from "../../stores/CardsStore.js";
-
-import { removeAccounts } from "../../utils/storageAccounts";
-import { removeCards } from "../../utils/storageCards";
+import styles from "../../styles/listsStyle";
+import { useAccountsCardStore } from "../../stores/CardsStore.js";
+import AddAccount from "../../components/Forms/AddAccount";
const Accounts = ({ navigation }) => {
- const listAccounts = useAccountsStore((state) => state.listAccounts);
- const fetchAccounts = useAccountsStore((state) => state.fetchAccounts);
- const listCards = useCardStore((state) => state.listCards);
- const fetchCards = useCardStore((state) => state.fetchCards);
-
- const [updatedAccounts, setUpdatedAccounts] = useState(false);
+ const listAccountsCards = useAccountsCardStore(
+ (state) => state.listAccountsCards
+ );
+ const fetchAccountsCards = useAccountsCardStore(
+ (state) => state.fetchAccountsCards
+ );
useEffect(() => {
- fetchAccounts();
- fetchCards();
+ fetchAccountsCards();
}, []);
- useFocusEffect(
- React.useCallback(() => {
- fetchAccounts();
- fetchCards();
- }, [updatedAccounts])
- );
-
- const dialogDeleteCard = (index) => {
- Alert.alert("Delete card", "Do you really want to delete?", [
- {
- text: "Cancel",
- },
- {
- text: "Confirm",
- onPress: () => {
- fetchCards();
- removeCards(index);
- },
- },
- ]);
- };
-
- const dialogDetails = (account) => {
- Alert.alert(account.name, account.type_account);
- };
-
- const dialogDeleteAccount = (index) => {
- Alert.alert("Delete account", "Do you really want to delete?", [
- {
- text: "Cancel",
- },
- {
- text: "Confirm",
- onPress: async () => {
- removeAccounts(index);
- setUpdatedAccounts(true);
- },
- },
- ]);
- };
-
return (
- <>
-
-
- Bank Accounts
-
- {listAccounts.map((account, index) => {
- return (
+
+ <>
+ {listAccountsCards.map((account, index) => {
+ return (
+
navigation.navigate("DetailBankAccount", { account })}
+ onPress={() => {
+ navigation.navigate("DetailAccount", { account, index });
+ }}
>
-
-
- {account.bank}
+
+
+ {account.name}
+ {"\n"}
+
+ {"Bank:"} {account.bank}
+
- US$ {account.balance}
-
-
- {/* Edit button*/}
-
- navigation.navigate("EditBankAccount", { index, account })
- }
- >
-
-
-
- {/* Delete button */}
- dialogDeleteAccount(index)}>
-
-
-
- );
- })}
-
-
- navigation.navigate("AddBankAccount")}
- >
-
-
-
-
-
-
- Credit Cards
- {listCards.map((card, index) => {
- return (
-
- navigation.navigate("DetailCreditCard", { card, index })
- }
- >
-
-
- {card.name}
-
- US$ {card.totalInvoices}
-
-
- {/* Edit button*/}
-
- navigation.navigate("EditCreditCard", { index, card })
- }
- >
-
-
-
- {/* Delete button */}
- dialogDeleteCard(index)}>
-
-
-
-
-
- );
- })}
-
-
- navigation.navigate("AddCreditCard")}
- >
-
-
-
-
-
- >
+
+
+ );
+ })}
+
+ navigation.navigate("FormsScreen", { component: })}
+ >
+
+
+
+ >
+
);
};
diff --git a/src/screens/Accounts/styles.js b/src/screens/Accounts/styles.js
deleted file mode 100644
index 93d5429..0000000
--- a/src/screens/Accounts/styles.js
+++ /dev/null
@@ -1,116 +0,0 @@
-import { StyleSheet } from "react-native";
-
-export default styles = StyleSheet.create({
- container: {
- flex: 1,
- padding: 20,
- backgroundColor: "#fff",
- },
- textTitle: {
- fontSize: 20,
- fontWeight: "bold",
- textAlign: "center",
- paddingBottom: 5,
- },
- containerScroll: {
- padding: 20,
- width: "45%",
- },
- cardText: {
- color: "white",
- fontSize: 20,
- textAlign: "center",
- },
- cardTextTitle: {
- fontWeight: "bold",
- },
- cardIcons: {
- flexDirection: "row",
- gap: 15,
- },
- contaBancaria: {
- gap: 4,
- paddingBottom: 10,
- paddingTop: 10,
- marginBottom: 16,
- alignItems: "center",
- borderRadius: 10,
- backgroundColor: "#1a7bd5",
- },
- cardCartao: {
- gap: 4,
- paddingBottom: 10,
- paddingTop: 10,
- marginBottom: 16,
- alignItems: "center",
- borderRadius: 10,
- backgroundColor: "#757de8",
- },
- conta_bancaria: {
- width: "80%",
- paddingVertical: 15,
- paddingHorizontal: 20,
- fontSize: 16,
- fontWeight: "bold",
- borderRadius: 10,
- borderColor: "black",
- borderWidth: 1,
- marginVertical: 5,
- marginHorizontal: 1,
- backgroundColor: "#D9D9D9",
- },
- btnStyle: {
- alignItems: "center",
- alignContent: "center",
- justifyContent: "center",
- backgroundColor: "red",
- padding: 2,
- margin: 3,
- flexDirection: "row",
- width: 50,
- fontWeight: "bold",
- borderRadius: 0, // Alterado para 0 para criar botões quadrados
- },
- btnStyleEdit: {
- alignItems: "center",
- alignContent: "center",
- justifyContent: "center",
- backgroundColor: "yellow",
- padding: 2,
- margin: 3,
- flexDirection: "row",
- width: 50,
- fontWeight: "bold",
- borderRadius: 0,
- },
- button: {
- borderRadius: 100,
- height: 40,
- width: 40,
- alignItems: "center",
- alignContent: "center",
- justifyContent: "center",
- backgroundColor: "#1a7bd5",
- },
- viewbutton: {
- flexDirection: "row",
- justifyContent: "space-between",
- width: "100%",
- },
- viewsContainer: {
- flexDirection: "row",
- },
- viewbanco: {
- width: "100%",
- padding: 2,
- },
- ViewCartão: {
- width: "45%",
- left: 5,
- backgroundColor: "#D9D99",
- },
- addButtonContainer: {
- alignItems: 'center',
- marginTop: 20,
- },
-});
diff --git a/src/screens/Add/Add.js b/src/screens/Add/Add.js
deleted file mode 100644
index a65002f..0000000
--- a/src/screens/Add/Add.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import React from "react";
-import { View } from "react-native";
-
-import styles from "./styles.js";
-import Form from "./TransactionForm.js";
-
-export default function Add() {
- return (
-
-
-
- );
-}
diff --git a/src/screens/AddCreditCard/AddCreditCard.js b/src/screens/AddCreditCard/AddCreditCard.js
deleted file mode 100644
index 3d38bea..0000000
--- a/src/screens/AddCreditCard/AddCreditCard.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import React, { useState } from "react";
-import { View, Text, TextInput, Button, Alert } from "react-native";
-
-import { addCards } from "../../utils/storageCards";
-
-import styles from "./styles";
-
-function AddCard({ navigation }) {
- const [name, setName] = useState("");
- const [bank, setBank] = useState("");
- const [totalInvoices, setTotalInvoices] = useState(0.0);
-
- const handleAddCard = async () => {
- if (
- name === "" ||
- bank === "" ||
- totalInvoices === "" ||
- !Number(totalInvoices) ||
- Number(totalInvoices) < 0
- ) {
- Alert.alert("Fill in the fields correctly!");
- return;
- }
-
- if (name && bank && totalInvoices) {
- const card = {
- name,
- bank,
- totalInvoices,
- };
-
- try {
- addCards(card);
-
- // Clean the fields after adding the card
- setName("");
- setBank("");
- setTotalInvoices(0.0);
-
- Alert.alert("Card succesfully added!");
- } catch (error) {
- Alert.alert("Error saving card:", error);
- }
- navigation.goBack()
- }
- };
-
- return (
-
- Add Credit Card
- setName(text)}
- />
- setBank(text)}
- />
- setTotalInvoices(text)}
- />
-
-
-
-
-
-
- );
-}
-
-export default AddCard;
diff --git a/src/screens/DetailBankAccount/DetailBankAccount.js b/src/screens/DetailAccount/DetailAccount.js
similarity index 91%
rename from src/screens/DetailBankAccount/DetailBankAccount.js
rename to src/screens/DetailAccount/DetailAccount.js
index db5aced..84962b4 100644
--- a/src/screens/DetailBankAccount/DetailBankAccount.js
+++ b/src/screens/DetailAccount/DetailAccount.js
@@ -1,12 +1,12 @@
-import React, { useState, useEffect } from "react";
-import { View, Text, TextInput, Button, ScrollView, Alert } from "react-native";
+import React, { useEffect } from "react";
+import { View, Text, Button, ScrollView, Alert } from "react-native";
import { TouchableOpacity } from "react-native-gesture-handler";
import styles from "./styles";
import { removeAccounts } from "../../utils/storageAccounts";
import { useExtractStore } from "../../stores/ExtractStore.js";
-const DetailBankAccount = ({ route, navigation }) => {
+const DetailAccount = ({ route, navigation }) => {
const { account, index } = route.params;
const extract = useExtractStore((state) => state.extract);
@@ -54,7 +54,7 @@ const DetailBankAccount = ({ route, navigation }) => {