-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathApp.js
105 lines (91 loc) · 2.29 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from 'react';
// REDUX SECTION
import { configureStore } from 'redux-starter-kit';
import { Provider } from 'react-redux';
// Library
import SideMenu from 'react-native-side-menu';
import {
Container,
Root,
StyleProvider
} from 'native-base';
import {
StatusBar, Linking, Dimensions
} from 'react-native';
import rootReducer from './src/modules/store';
// Local
import Main from './src/views/Main';
import Menu from './src/views/SideMenu';
import getTheme from './native-base-theme/components';
import material from './native-base-theme/variables/material';
const store = configureStore({
reducer: rootReducer,
});
const { width } = Dimensions.get('window');
export default class App extends Component {
constructor(props) {
super(props);
this.toggle = this.toggle.bind(this);
this.state = {
isOpen: false,
selectedItem: 'Home',
};
}
onMenuItemSelected = (item) => {
if (item === 'Feedback') {
Linking.openURL('https://www.onepanel.io/contact');
}
else if(item === 'Free AI POC') {
Linking.openURL('https://www.onepanel.io/campaigns/free-aimodels-lead');
} else {
this.setState({
isOpen: false,
selectedItem: item,
});
}
};
updateMenuState(isOpen) {
this.setState({ isOpen });
}
toggle() {
const { isOpen } = this.state;
this.setState({
isOpen: !isOpen,
});
}
render() {
const { selectedItem, isOpen } = this.state;
const menu = (
<Menu
onItemSelected={this.onMenuItemSelected}
selectedItem={selectedItem}
/>
);
return (
<Root>
<Provider store={store}>
<StyleProvider style={getTheme(material)}>
<Container>
<SideMenu
menu={menu}
isOpen={isOpen}
edgeHitWidth={width}
onChange={(changedOpenState) => this.updateMenuState(changedOpenState)}
>
<StatusBar hidden />
<Main toggleSideBar={() => this.toggle()} title={selectedItem} />
</SideMenu>
</Container>
</StyleProvider>
</Provider>
</Root>
);
}
}