Skip to content

Commit ae4e127

Browse files
committed
Projeto Shop App, utilizando firebase finalizado
1 parent 0b319b1 commit ae4e127

30 files changed

+602
-25
lines changed

shop-app/App.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ import * as Font from "expo-font";
77
import ReduxThunk from "redux-thunk";
88
// import { composeWithDevTools } from "redux-devtools-extension";
99

10+
import { LogBox } from "react-native";
11+
LogBox.ignoreLogs(["Setting a timer for a long period of time, i.e."]);
12+
1013
import productsReducer from "./store/reducers/productsReducer";
1114
import cartReducer from "./store/reducers/cartReducer";
1215
import ordersReducer from "./store/reducers/ordersReducer";
13-
import ShopNavigator from "./navigation/ShopNavigator";
16+
import authReducer from "./store/reducers/authReducer";
17+
import NavigationContainer from "./navigation/NavigationContainer";
1418
import { SafeAreaView } from "react-native-safe-area-context";
1519

1620
const rootReducer = combineReducers({
1721
products: productsReducer,
1822
cart: cartReducer,
1923
orders: ordersReducer,
24+
auth: authReducer,
2025
});
2126

2227
const store = createStore(rootReducer, applyMiddleware(ReduxThunk));
@@ -44,7 +49,7 @@ export default function App() {
4449
return (
4550
<Provider store={store}>
4651
<SafeAreaView style={{ flex: 1 }}>
47-
<ShopNavigator />
52+
<NavigationContainer />
4853
</SafeAreaView>
4954
</Provider>
5055
);

shop-app/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Shop App
2+
3+
<p align="center">
4+
<img src="screen01.jpeg" width="25%" alt="tela da aplicação">
5+
<img src="screen02.jpeg" width="25%" alt="tela da aplicação">
6+
<img src="screen03.jpeg" width="25%" alt="tela da aplicação">
7+
<img src="screen04.jpeg" width="25%" alt="tela da aplicação">
8+
<img src="screen05.jpeg" width="25%" alt="tela da aplicação">
9+
<img src="screen06.jpeg" width="25%" alt="tela da aplicação">
10+
<img src="screen07.jpeg" width="25%" alt="tela da aplicação">
11+
<img src="screen08.jpeg" width="25%" alt="tela da aplicação">
12+
<img src="screen09.jpeg" width="25%" alt="tela da aplicação">
13+
<img src="screen10.jpeg" width="25%" alt="tela da aplicação">
14+
<img src="screen11.jpeg" width="25%" alt="tela da aplicação">
15+
<img src="screen12.jpeg" width="25%" alt="tela da aplicação">
16+
<img src="screen13.jpeg" width="25%" alt="tela da aplicação">
17+
<img src="screen14.jpeg" width="25%" alt="tela da aplicação">
18+
</p>
19+
20+
> Projeto mais robusto usando Expo, de um aplicativo com dados hospedados no servidor e base de dados do Firebase, sendo necessário realizar o Log in ou Sign up, com token de autenticação armazenado localmente pelo AsyncStorage, podendo adicionar produtos, editar, deletar, adicioná-los ao carrinho, fechar o pedido, os produtos são relacionados com a autenticação do usuário pelo Firebase, com gerenciamento de estados usando Redux, validação de Inputs, react navigation, stack, drawer, switch, projeto feito por Maximilian Schwarzmüller.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { useEffect, useRef } from "react";
2+
import { useSelector } from "react-redux";
3+
import { NavigationActions } from "react-navigation";
4+
5+
import ShopNavigator from "./ShopNavigator";
6+
7+
const NavigationContainer = () => {
8+
const navRef = useRef();
9+
const isAuth = useSelector((state) => !!state.auth.token);
10+
11+
useEffect(() => {
12+
if (!isAuth) {
13+
navRef.current.dispatch(
14+
NavigationActions.navigate({ routeName: "Auth" })
15+
);
16+
}
17+
}, [isAuth]);
18+
19+
return <ShopNavigator ref={navRef} />;
20+
};
21+
22+
export default NavigationContainer;

shop-app/navigation/ShopNavigator.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import React from "react";
22
import { createStackNavigator } from "react-navigation-stack";
3-
import { createDrawerNavigator } from "react-navigation-drawer";
4-
import { createAppContainer } from "react-navigation";
5-
import { Platform } from "react-native";
3+
import { createDrawerNavigator, DrawerItems } from "react-navigation-drawer";
4+
// import { createSwitchNavigator } from "react-navigation-switch";
5+
import { createAppContainer, createSwitchNavigator } from "react-navigation";
6+
import { Platform, SafeAreaView, Button, View } from "react-native";
67

78
import ProductsOverviewScreen from "../screens/shop/ProductsOverviewScreen";
89
import ProductDetailScreen from "../screens/shop/ProductDetailScreen";
910
import CartScreen from "../screens/shop/CartScreen";
1011
import OrdersScreen from "../screens/shop/OrdersScreen";
1112
import UserProductsScreen from "../screens/user/UserProductsScreen";
1213
import EditProductScreen from "../screens/user/EditProductScreen";
14+
import StartupScreen from "../screens/user/StartupScreen";
15+
import AuthScreen from "../screens/user/AuthScreen";
16+
1317
import Colors from "../constants/Colors";
1418
import { Ionicons } from "@expo/vector-icons";
1519

20+
import { useDispatch } from "react-redux";
21+
import * as authActions from "../store/actions/actionsAuth";
22+
1623
const defaultNavOptions = {
1724
headerTitleAlign: "center",
1825
headerStyle: {
@@ -94,7 +101,39 @@ const ShopNavigator = createDrawerNavigator(
94101
contentOptions: {
95102
activeTintColor: Colors.primary,
96103
},
104+
contentComponent: (props) => {
105+
const dispatch = useDispatch();
106+
return (
107+
<View style={{ flex: 1 }}>
108+
<SafeAreaView forceInset={{ top: "always", horizontal: "never" }}>
109+
<DrawerItems {...props} />
110+
<Button
111+
title="Logout"
112+
color={Colors.primary}
113+
onPress={() => {
114+
dispatch(authActions.logout());
115+
}}
116+
/>
117+
</SafeAreaView>
118+
</View>
119+
);
120+
},
97121
}
98122
);
99123

100-
export default createAppContainer(ShopNavigator);
124+
const AuthNavigator = createStackNavigator(
125+
{
126+
Auth: AuthScreen,
127+
},
128+
{
129+
defaultNavigationOptions: defaultNavOptions,
130+
}
131+
);
132+
133+
const MainNavigator = createSwitchNavigator({
134+
Startup: StartupScreen,
135+
Auth: AuthNavigator,
136+
Shop: ShopNavigator,
137+
});
138+
139+
export default createAppContainer(MainNavigator);

shop-app/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shop-app/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
},
1212
"dependencies": {
1313
"@expo/vector-icons": "^12.0.5",
14+
"@react-native-async-storage/async-storage": "~1.15.0",
1415
"@react-native-community/masked-view": "^0.1.11",
1516
"@react-navigation/native": "^6.0.8",
1617
"expo": "~44.0.0",
1718
"expo-app-loading": "~1.3.0",
1819
"expo-font": "^10.0.5",
20+
"expo-linear-gradient": "^11.0.3",
1921
"expo-status-bar": "~1.2.0",
2022
"moment": "^2.29.1",
2123
"react": "17.0.1",
@@ -31,6 +33,7 @@
3133
"react-navigation-drawer": "^2.7.2",
3234
"react-navigation-header-buttons": "^9.0.1",
3335
"react-navigation-stack": "^2.10.4",
36+
"react-navigation-switch": "^1.0.1",
3437
"react-redux": "^7.2.6",
3538
"redux": "^4.1.2",
3639
"redux-thunk": "^2.4.1"

shop-app/screen01.jpeg

28.1 KB
Loading

shop-app/screen02.jpeg

28.1 KB
Loading

shop-app/screen03.jpeg

49.5 KB
Loading

shop-app/screen04.jpeg

60.8 KB
Loading

0 commit comments

Comments
 (0)