-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.js
170 lines (122 loc) · 6.43 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import React, {useContext} from 'react';
import { View, ActivityIndicator } from 'react-native';
import { IconContent } from "./src/app/styles/crud";
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
import { faPlus, faGear } from "@fortawesome/free-solid-svg-icons";
import Start from './src/app/screens/inicio/start';
import Config from './src/app/config/config';
import ConfigApiUrl from './src/app/config/configApiUrl';
import Preco from './src/app/screens/preco';
import CreatePreco from './src/app/screens/preco/create';
import EditPreco from './src/app/screens/preco/edit';
import ShowPreco from './src/app/screens/preco/show';
import Cliente from './src/app/screens/cliente';
import CreateCliente from './src/app/screens/cliente/create';
import EditCliente from './src/app/screens/cliente/edit';
import ShowCliente from './src/app/screens/cliente/show';
import Atendimento from './src/app/screens/vendas/atendimento';
import Vendas from './src/app/screens/vendas/vendas';
import ShowVendas from './src/app/screens/vendas/show';
import Reabertura from './src/app/screens/vendas/reabertura';
import ReabrirVenda from './src/app/screens/vendas/reabertura/reabrir';
import AtendimentoOrcamentos from './src/app/screens/orcamentos/atendimento';
import Orcamentos from './src/app/screens/orcamentos/orcamentos';
import ShowOrcamento from './src/app/screens/orcamentos/show';
import ReaberturaOrcamentos from './src/app/screens/orcamentos/reabertura';
import ReabrirOrcamento from './src/app/screens/orcamentos/reabertura/reabrir';
import { AuthenticationProvider } from './src/app/context/authentication';
import { AuthenticationContext } from './src/app/context/authentication'
import { ConfigProvider } from './src/app/context/config';
import { ConfigContext } from './src/app/context/config';
function App() {
return (
<ConfigProvider>
<AuthenticationProvider>
<Conteudo/>
</AuthenticationProvider>
</ConfigProvider>
)
}
const Stack = createNativeStackNavigator();
function Conteudo() {
const { userPermissions, loading } = useContext(AuthenticationContext)
const { baseUrl, appInfo, setInfoApp } = useContext(ConfigContext)
if(baseUrl == '') {
return (
<NavigationContainer>
<ConfigApiUrl/>
</NavigationContainer>
);
}
if(baseUrl !== '') {
if(loading) {
return(
<View style={{flex:1,
backgroundColor: appInfo.cor_de_fundo,
alignItems:'center',
justifyContent:'center', }}>
<ActivityIndicator size="large" color={appInfo.cor_segundaria} />
</View>
)
}
return (
<NavigationContainer>
<Stack.Navigator screenOptions={{
headerStyle: {
backgroundColor: appInfo.cor_principal,
},
headerTintColor: appInfo.cor_de_fundo,
headerTitleStyle: {
fontWeight: 'bold',
},
}} initialRouteName="Start">
{/* INICIO */}
<Stack.Screen name="Start" component={Start} options={({ navigation }) => { return { title: appInfo.nome_do_app, headerRight: () => (<IconContent onPress={() => navigation.navigate('Config')}>
<FontAwesomeIcon icon={faGear} size={ 25 } color={ appInfo.cor_de_fundo } />
</IconContent>) } }}/>
{/* CONFIG */}
<Stack.Screen name="Config" component={Config} options={{ title: 'Configurações' }}/>
{/* PREÇO */}
<Stack.Screen name="Preco" component={Preco} options={({ navigation }) => {
if(userPermissions.includes('CadastrarProduto')) { return { title: 'Produtos', headerRight: () => (
<IconContent onPress={() => navigation.navigate('CreatePreco')}>
<FontAwesomeIcon icon={faPlus} size={ 25 } color={ appInfo.cor_de_fundo } />
</IconContent>
) }}
if(!userPermissions.includes('CadastrarProduto')) { return { title: 'Produtos' }}
}}/>
<Stack.Screen name="ShowPreco" component={ShowPreco} options={{ title: 'Visualizar Produto' }}/>
<Stack.Screen name="CreatePreco" component={CreatePreco} options={{ title: 'Cadastrar Produto' }}/>
<Stack.Screen name="EditPreco" component={EditPreco} options={{ title: 'Editar Produto' }}/>
{/* CLIENTE */}
<Stack.Screen name="Cliente" component={Cliente} options={({ navigation }) => {
if(userPermissions.includes('CadastrarCliente')) { return { title: 'Clientes', headerRight: () => (
<IconContent onPress={() => navigation.navigate('CreateCliente')}>
<FontAwesomeIcon icon={faPlus} size={ 25 } color={ appInfo.cor_de_fundo } />
</IconContent>
) } }
if(!userPermissions.includes('CadastrarCliente')) { return { title: 'Clientes' }}
}}/>
<Stack.Screen name="ShowCliente" component={ShowCliente} options={{ title: 'Visualizar Cliente' }}/>
<Stack.Screen name="CreateCliente" component={CreateCliente} options={{ title: 'Cadastrar Cliente' }}/>
<Stack.Screen name="EditCliente" component={EditCliente} options={{ title: 'Editar Cliente' }}/>
{/* PRE-VENDAS */}
<Stack.Screen name="Atendimento" component={Atendimento} options={{ title: 'Atendimento' }}/>
<Stack.Screen name="Vendas" component={Vendas} options={{ title: 'Suas Vendas' }}/>
<Stack.Screen name="ShowVendas" component={ShowVendas} options={{ title: 'Visualizar Venda' }}/>
<Stack.Screen name="Reabertura" component={Reabertura} options={{ title: 'Reabertura' }}/>
<Stack.Screen name="ReabrirVenda" component={ReabrirVenda} options={{ title: 'Reabrir Venda' }}/>
{/* ORÇAMENTOS */}
<Stack.Screen name="AtendimentoOrcamentos" component={AtendimentoOrcamentos} options={{ title: 'Atendimento (Orçamentos)' }}/>
<Stack.Screen name="Orcamentos" component={Orcamentos} options={{ title: 'Seus Orçamentos' }}/>
<Stack.Screen name="ShowOrcamento" component={ShowOrcamento} options={{ title: 'Visualizar Orçamento' }}/>
<Stack.Screen name="ReaberturaOrcamentos" component={ReaberturaOrcamentos} options={{ title: 'Reabertura (Orçamentos)' }}/>
<Stack.Screen name="ReabrirOrcamento" component={ReabrirOrcamento} options={{ title: 'Reabrir Orçamento' }}/>
</Stack.Navigator>
</NavigationContainer>
);
}
}
export default App;