-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
196 lines (151 loc) · 5.53 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// This template was developed to show how to use basic.js
// VARIABLES:
const APP_ID = "app-id";
const USED_WIDTH = 600; // Examples: 550, 600, 700, "100%" (Dont use when page.fit is active)
// NOTE: If you want bigger objects use smaller USED_WIDTH:
const MAX_ZOOMABLE_WIDTH = 800;
let waitingView;
// First running function.
const prepareApp = function() {
// Platforms: "web", "android", "ios"
console.log("Platform: " + app.getPlatformId());
// If more resolution is desired for large screen device:
//USED_WIDTH = app.calculateResolution();
// Supports all screen resolutions (Orientation: portrait)
page.fit(USED_WIDTH, MAX_ZOOMABLE_WIDTH);
// Show launch view.
launchView.create();
// Safearea outer spaces.
app.getSafeAreaOuterSpaces(function() {
// Ready to use: app.safeAreaInsetTop, app.safeAreaInsetBottom, app.safeAreaInsetLeft, app.safeAreaInsetRight
var safeAreaOptions = {
width: USED_WIDTH,
topOuterSpace: app.safeAreaInsetTop,
bottomOuterSpace: app.safeAreaInsetBottom,
backgroundColor: "transparent",
outerBackgroundColor: "white",
statusBarBackgroundColor: "rgba(0, 0, 0, 0.05)",
};
// SAFE AREA: App container.
safeArea.create(safeAreaOptions);
// Objects are first created in the "safeArea". (Previous value is the "page")
basic.setDefaultContainerBox(safeArea.getContainerBox());
// Change launchView layer after safeArea created.
launchView.showOnSafeArea();
// Start the app.
startApp();
});
};
// Second running function.
const startApp = function() {
//saveGlobal(); // Close this line to store data.
// NOTE: For reseting global variables, run saveGlobal() before loadGlobal():
loadGlobal();
/*
safeArea.setBackgroundColor("transparent");
safeArea.setOuterBackgroundColor("white");
safeArea.setStatusBarBackgroundColor("rgba(0, 0, 0, 0.0)"); // works only at notched devices.
*/
// UI DEFAULT VIEW: Default page view:
defaultView.create({
backgroundColor: "white",
scrollY: 1,
showWithMotion: 0,
});
// UI TOP BAR: Title and buttons:
topBar.create({
height: 105,
showWithMotion: 0,
});
topBar.menuButton.onClick(showSideBar);
// UI BOTTOM BAR: Image buttons at bottom:
bottomBar.create({
height: 80, // 70, 80, 90
showSelectedText: 1, // 0
highLightColor: "#141414", // "whitesmoke"
reverseColorOfSelectedIcon: 1, // 0
normalIconSpace: 16,
selectedIconSpace: 16, // 16
});
bottomBar.createItemsByDataList(database.getBottomBarItemDataList());
bottomBar.onItemClick(openPageById);
// UI BUDGE FOR BOTTOM BAR: Tasks count.
bottomBar.tasksUIBudge = bottomBar.createBudgeOnItem({ itemIndex: 3});
//that.setValue(storage.load("todoApp-taskDataList").length || 0);
that.setColor("indianred");
updateBottomBarTasksUIBudge();
//that.setVisible(0);
// UI SECOND VIEW: If you need a view without unload page in defaultView:
secondView.create({
backgroundColor: "white",
scrollY: 1,
showWithMotion: 1,
});
// UI SMALL VIEW: For small pages, extra info, custom dialogs etc.
smallView.create({
height: 500,
backgroundColor: "white",
coverColor: "rgba(0, 0, 0, 0.4)",
topRound: 13,
scrollY: 0,
showWithMotion: 1,
});
// UI SIDE MENU BAR: Right side menu:
sideBar.create();
sideBar.setTitle("CATEGORIES");
sideBar.createItemsByDataList(database.getSideMenuBarItemDataList());
sideBar.selectItemByIndex(0);
sideBar.onSelectionChange(sideBarItemSelectionChanged);
// UI OBJECT: Login view:
loginView.create();
//loginView.show();
sideBar.lockScreenButton.onClick(lockScreen);
// Shows where did you tap.
clickEffect.create({
clickColor: "black",
});
// WAITING VIEW: It prevents the user from touching the screen until the process is complete.
waitingView = WaitingView({
waitingIconFile: "components/ui-waiting-view/clock.png",
coverBackgroundColor: "rgba(0, 0, 0, 0.4)",
});
// NOTE: New component technique year:2024 (Template File: components/_component-template.js)
// Open the home page.
openPageById(homePage.PAGE_ID);
// Remove launch view.
launchView.remove();
}
const openPageById = function(pageId) {
switch(pageId) {
case homePage.PAGE_ID:
homePage.openInDefaultView();
break;
case searchPage.PAGE_ID:
searchPage.openInDefaultView();
break;
case examplesPage.PAGE_ID:
examplesPage.openInDefaultView();
break;
case tasksPage.PAGE_ID:
tasksPage.openInDefaultView();
break;
case settingsPage.PAGE_ID:
settingsPage.openInDefaultView();
break;
}
}
const sideBarItemSelectionChanged = function(item, itemId) {
console.log("Side bar selection changed: " + itemId);
}
const showSideBar = function() {
sideBar.setVisible(1);
}
const lockScreen = function() {
sideBar.setVisible(0);
loginView.show();
}
window.updateBottomBarTasksUIBudge = function(number) {
bottomBar.tasksUIBudge.setValue(number || ((storage.load("todoApp-taskDataList")) ? storage.load("todoApp-taskDataList").length : 0));
};
// Run the prepareApp() function when the device is ready:
app.onDeviceReady(prepareApp);