-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStoreManager.js
103 lines (84 loc) · 3.33 KB
/
StoreManager.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
import React, { useEffect } from 'react';
import {
PlatformColor
} from 'react-native';
import { useDispatch } from 'react-redux';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
import { getElections } from './redux/votes/votesSlice';
import Login from './views/login';
import Votes from './views/votes';
import Vote from './views/vote';
import Subject from './views/subject';
import Intro from './views/Intro';
import useSubstrate from './substrate-lib/useSubstrate';
/*
This component does not have any markup itself, it handles navigation and makes sure that
all other components that actually display something have access to the store.
*/
const StoreManager = () => {
const vaUrl = 'localhost:3000';
const providerSocket = 'ws://localhost:9944'
const dispatch = useDispatch();
//let api = undefined;
//const substrate = useSubstrate();
//console.log(substrate);
const { keyring, keyringState, api } = useSubstrate();
useEffect(() => {
if (api) {
console.log('Initializing...');
dispatch(getElections(api));
}
}, [dispatch, api]);
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Login"
component={Login}
options={{ title: 'Provotum', name: 'Login' }}
/>
<Stack.Screen name="votes" component={Votes} />
<Stack.Screen name="intro" component={Intro} />
<Stack.Screen
name="vote"
component={Vote}
options={({ route }) => (
{
title: route && route.params ? route.params.title : '',
headerStyle: {
backgroundColor: PlatformColor('systemBackground'),
},
headerTintColor: PlatformColor('label'),
headerTitleStyle: {
fontWeight: 'bold',
display: 'none',
},
//headerTitle: props => <Title1 {...props}>{route.params.title}</Title1>
})
}
/>
<Stack.Screen
name="subject"
component={Subject}
options={({ route }) => (
{
title: route && route.params ? route.params.title : '',
headerStyle: {
backgroundColor: PlatformColor('systemBackground'),
},
headerTintColor: PlatformColor('label'),
headerTitleStyle: {
fontWeight: 'bold',
display: 'none',
},
//headerTitle: props => <Title1 {...props}>{route.params.title}</Title1>
})
}
/>
</Stack.Navigator>
</NavigationContainer>
)
};
export default StoreManager;