-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
53 lines (48 loc) · 1.39 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
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import {Provider, useSelector} from 'react-redux';
import store from './store';
import Home from './components/home';
import Navbar from './components/layouts/navbar'
import EditTodo from './components/editTodo';
const Stack = createStackNavigator();
export default function App() {
const screenOptions = {
headerShown: true,
headerTitle: props => <Navbar />,
headerStyle: {
backgroundColor: 'coral'
},
headerRight: () =>
{
const todos = useSelector(state => state.todo)
if(todos.length > 0) return <Text style={styles.navText}>{todos.length}</Text>;
return null;
}
}
return (
<Provider store={store}>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="home" component={Home} options={screenOptions} />
<Stack.Screen name="editTodo" component={EditTodo} options={screenOptions} />
</Stack.Navigator>
</NavigationContainer>
</Provider>
);
}
const styles = StyleSheet.create({
container: {
},
navText: {
paddingHorizontal: 10,
marginRight: 20,
fontWeight: 'bold',
fontSize: 18,
color: '#555',
backgroundColor: '#fff',
borderRadius: 20
}
});