-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
145 lines (127 loc) · 5.23 KB
/
index.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// import './../configs/globalVariables'
import { Navigation } from "react-native-navigation";
// Import screens
import MenuScreen from "./src/screens/MenuScreen";
import AlertsScreen from "./src/screens/AlertsScreen";
import DashboardScreen from "./src/screens/DashboardScreen";
import HarvestLogScreen from "./src/screens/HarvestLogScreen";
import SettingsScreen from "./src/screens/SettingsScreen";
import StrategiesScreen from "./src/screens/StrategiesScreen";
import SupportScreen from "./src/screens/SupportScreen";
import TasksScreen from "./src/screens/TasksScreen";
import YieldScreen from "./src/screens/YieldScreen";
// Register screens
Navigation.registerComponent("navigation.playground.MenuScreen", () => MenuScreen);
Navigation.registerComponent("navigation.playground.AlertsScreen", () => AlertsScreen);
Navigation.registerComponent("navigation.playground.DashboardScreen", () => DashboardScreen);
Navigation.registerComponent("navigation.playground.HarvestLogScreen", () => HarvestLogScreen);
Navigation.registerComponent("navigation.playground.SettingsScreen", () => SettingsScreen);
Navigation.registerComponent("navigation.playground.StrategiesScreen", () => StrategiesScreen);
Navigation.registerComponent("navigation.playground.SupportScreen", () => SupportScreen);
Navigation.registerComponent("navigation.playground.TasksScreen", () => TasksScreen);
Navigation.registerComponent("navigation.playground.YieldScreen", () => YieldScreen);
import MaterialIcons from "react-native-vector-icons/MaterialIcons";
class templateApp {
constructor(props) {
this.currentStackRootScreenId = "DashboardScreen"
this.homeIcon = null
}
startApp(){
Navigation.events().registerAppLaunchedListener(() => {
// Loading icons
MaterialIcons.getImageSource("menu", 32, "black").then(src => {
this.homeIcon = src;
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
id: "MenuScreen",
name: "navigation.playground.MenuScreen",
passProps: {
changeScreenCallback: this.changeScreen,
currentScreenId: this.currentStackRootScreenId,
}
},
},
//
center: {
stack: {
id: "mainStackRoot",
children: [{
component: {
id: this.currentStackRootScreenId ,
name: "navigation.playground." + this.currentStackRootScreenId,
options: {
topBar: {
title: {
text: "Dashboard",
},
leftButtons: [{
id: "menuButton",
icon: this.homeIcon
}, ],
},
},
},
}, ],
},
},
//
}
}
});
})
})
// Button press listener
Navigation.events().registerNavigationButtonPressedListener((event) => {
// launching menu
if (event.buttonId == "menuButton"){
Navigation.mergeOptions("MenuScreen", {
sideMenu: {
left: {
visible: true,
},
}
});
}
})
}
changeScreen = function(newScreenId, newScreenTitle){
if (this.currentStackRootScreenId != newScreenId) {
this.currentStackRootScreenId = newScreenId
Navigation.setStackRoot("mainStackRoot", {
component: {
id: this.currentStackRootScreenId,
name: "navigation.playground." + this.currentStackRootScreenId,
options: {
animations: {
setStackRoot: {
enable: true
}
},
topBar: {
title: {
text: newScreenTitle,
},
leftButtons: [{
id: "menuButton",
icon: this.homeIcon
}, ],
},
},
},
})
}
Navigation.mergeOptions("MenuScreen", {
sideMenu: {
left: {
visible: false,
},
}
});
}.bind(this)
}
const app = new templateApp()
app.startApp()
export default templateApp