This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.android.js
119 lines (108 loc) · 3.41 KB
/
index.android.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
import React, { Component } from "react";
import {
View,
AppRegistry,
AsyncStorage,
DrawerLayoutAndroid
} from "react-native";
import { StackNavigator } from "react-navigation";
import { NavigationActions } from "react-navigation";
import { compose, applyMiddleware, createStore } from "redux";
import { Provider } from "react-redux";
import { persistStore, autoRehydrate } from "redux-persist";
import { mainReducer } from "./reducers/Reducers";
import LoadingScreen from "./components/LoadingScreen";
import SendPostScreen from "./components/SendPostScreen";
import { TabScreen } from "./components/TabScreen";
import LogIn from "./components/LogIn";
import SignUp from "./components/SignUp";
import PostScreen from "./components/PostScreen";
import SendReplyScreen from "./components/SendReplyScreen";
import UserPage from "./components/UserPage";
import AboutUsPage from "./components/AboutUsPage";
import DrawerMenu from "./components/DrawerMenu";
import { addBackHandler } from "./functions/BackHandlerAdder";
const App = StackNavigator({
LoadingScreen: { screen: LoadingScreen },
LogIn: { screen: LogIn },
SignUp: { screen: SignUp },
Home: { screen: TabScreen },
SendPostScreen: { screen: SendPostScreen },
SendReplyScreen: { screen: SendReplyScreen },
PostScreen: { screen: PostScreen },
UserPage: { screen: UserPage },
AboutUsPage: { screen: AboutUsPage }
});
class Unagi extends Component {
constructor(props) {
super(props);
this.openDrawer = this.openDrawer.bind(this);
this.closeDrawer = this.closeDrawer.bind(this);
this.lockDrawer = this.lockDrawer.bind(this);
this.unlockDrawer = this.unlockDrawer.bind(this);
addBackHandler(this);
this.state = {
run: false
};
this.store = createStore(
mainReducer,
undefined,
compose(applyMiddleware(), autoRehydrate())
);
// this.store.subscribe(() => {
// console.log("State Changed");
// console.log("------------------------------");
// console.log(this.store.getState().drawer.openDrawer);
// console.log("------------------------------");
// });
const config = {
storage: AsyncStorage,
blacklist: ["app", "navigation", "pageName"]
};
persistStore(this.store, config, () => {
console.log("Store loaded from local storage");
this.setState({
run: true
});
this.store.dispatch({ type: "SET_APP_REF", app: this });
});
}
openDrawer() {
this.drawer.openDrawer();
}
closeDrawer() {
this.drawer.closeDrawer();
}
unlockDrawer() {
this.drawer.setNativeProps({
drawerLockMode: "unlocked"
});
}
lockDrawer() {
this.drawer.setNativeProps({
drawerLockMode: "locked-closed"
});
}
drawerTouchLock = false;
render() {
return (
<Provider store={this.store}>
{this.state.run
? <DrawerLayoutAndroid
ref={rf => (this.drawer = rf)}
drawerWidth={250}
drawerPosition={DrawerLayoutAndroid.positions.Right}
renderNavigationView={() => <DrawerMenu />}
drawerLockMode="locked-closed"
onDrawerOpen={() => {
this.drawerTouchLock = false;
}}
>
<App />
</DrawerLayoutAndroid>
: <View style={{ flex: 1, backgroundColor: "#0091ea" }} />}
</Provider>
);
}
}
AppRegistry.registerComponent("Unagi", () => Unagi);