-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
83 lines (70 loc) · 2.35 KB
/
Copy pathApp.js
File metadata and controls
83 lines (70 loc) · 2.35 KB
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
import React, { useState, useEffect } from 'react';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
import 'react-native-gesture-handler';
import Home from './src/screens/Home'
import PostMaker from './src/screens/PostMaker'
import PostEditor from './src/screens/PostEditor'
import SearchId from './src/screens/SearchId'
import storageApiData from './src/services/storageApiData'
import getData from './src/services/getData'
import storagaData from './src/services/storageData'
const Drawer = createDrawerNavigator();
export default function App() {
const [data, setData] = useState([])
useEffect(() => {
storageApiData()
refreshPostCard()
}, [])
async function refreshPostCard() {
const asyncStorageData = await getData()
setData(asyncStorageData)
}
async function removePostCard(id) {
const posts = await getData()
const post = posts.filter(post => post.id === id)
if (post[0].id === id) {
posts.splice(posts.indexOf(post[0]), 1)
storagaData(posts)
refreshPostCard()
}
}
return (
<NavigationContainer>
<Drawer.Navigator
initialRouteName="Home"
screenOptions={{
drawerStyle: {
backgroundColor: '#2D333B'
},
drawerLabelStyle: {
color: '#ADBAC7'
},
sceneContainerStyle: {
backgroundColor: '#1C2128'
},
headerStyle: {
backgroundColor: '#2D333B',
},
headerTintColor: '#ADBAC7',
headerTitleStyle: {
fontWeight: 'bold',
}
}}
>
<Drawer.Screen name="Home" >
{(props) => <Home {...props} data={data} setData={setData} refreshPostCard={refreshPostCard} removePostCard={removePostCard} />}
</Drawer.Screen>
<Drawer.Screen name="Criar post" >
{(props) => <PostMaker {...props} refreshPostCard={refreshPostCard} />}
</Drawer.Screen>
<Drawer.Screen name="Editor de post" screenOptions={{headerShown: false}} >
{(props) => <PostEditor {...props} refreshPostCard={refreshPostCard} />}
</Drawer.Screen>
<Drawer.Screen name="Search ID" >
{(props) => <SearchId {...props} />}
</Drawer.Screen>
</Drawer.Navigator>
</NavigationContainer>
)
}