-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
264 lines (228 loc) · 6.88 KB
/
main.qml
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtWebKit 3.0
import QtQuick.Layouts 1.1
import "components" 1.0 as Components
import Api 1.0
import AppStates 1.0
import Utils 1.0
Item {
id: app
width: 320
height: 480
state: StateMaster.state
Messenger {
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.bottomMargin: 70
height: 40
z: 999;
ListModel {
id: msgQueue
}
Timer {
id: hidder
interval: 3000
running: false
repeat: false
onTriggered: {
if (msgQueue.count > 0) {
start()
msgQueue.remove(0, 1);
}
}
}
onPrintableMessage: {
msgQueue.append({desc: pritable});
if (!hidder.running) {
hidder.start()
}
}
ListView {
id: lstMsgs
anchors.fill: parent
visible: true
interactive: false
verticalLayoutDirection: ListView.BottomToTop
model: msgQueue
delegate: Rectangle {
height: dlgLabel.height
width: dlgLabel.width + 10
color: "white"
anchors.horizontalCenter: parent.horizontalCenter
Text {
id: dlgLabel
text: desc
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
}
}
User {
id: currentUser
onLoginRequired: StateMaster.consumeEvent(StateEvents.LoginRequired)
onLoginSucessful: StateMaster.consumeEvent(StateEvents.LoginSuccessful)
}
Rectangle {
id: splashView
visible: false
anchors.fill: parent
onVisibleChanged: {
if (visible) {
currentUser.loadData();
}
}
Label {
id: label1
text: qsTr("Loading...")
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
WebView {
id: loginView
anchors.fill: parent
visible: false
onLoadingChanged: {
if (loading == false && loadRequest.url == currentUser.loginUrl) {
StateMaster.consumeEvent(StateEvents.LoginCompleted)
}
}
}
ColumnLayout {
id: loggedInView
anchors.fill: parent
visible: false
spacing: 0
ColumnLayout {
id: userView
visible: false
Layout.fillHeight: true
Layout.fillWidth: true
onVisibleChanged: {
if (visible) {
currentUser.loadData();
}
}
Image {
id: profile_img
fillMode: Image.PreserveAspectFit
source: "static/profile_placeholder.png"
Layout.fillHeight: true
Layout.fillWidth: true
}
Label {
text: currentUser.name
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
Label {
text: currentUser.founds
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
}
ColumnLayout {
id: bankView
anchors.fill: parent
visible: false
onVisibleChanged: {
if (visible) {
bankTags.model.loadData();
}
bankTags.delegate = visible ? tagDelegate : null;
}
Components.TagInList {
id: tagDelegate
}
ListView {
id: bankTags
currentIndex: -1
Layout.fillHeight: true
Layout.fillWidth: true
model: TagModel {}
delegate: tagDelegate
highlight: Rectangle { color: "lightsteelblue"; radius: 2 }
}
}
ColumnLayout {
id: orderView
anchors.fill: parent
Layout.fillWidth: true
visible: false
spacing: 0
onVisibleChanged: {
if (visible) {
pendingOrders.model.loadData();
}
pendingOrders.delegate = visible ? orderDelegate : null;
}
Components.OrderInList {
id: orderDelegate
}
Text {
id: noPendingOrders
visible: !pendingOrders.visible
Layout.fillHeight: true
Layout.fillWidth: true
text: "No pending orders"
}
ListView {
id: pendingOrders
currentIndex: -1
Layout.fillHeight: true
Layout.fillWidth: true
model: OrderModel {}
delegate: orderDelegate
highlight: Rectangle { color: "lightsteelblue"; radius: 2 }
}
}
Components.Menu {
Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom
Layout.preferredHeight: 40
onBankClicked: StateMaster.consumeEvent(StateEvents.GoToBankView)
onUserClicked: StateMaster.consumeEvent(StateEvents.GoToUserView)
onOrdersClicked: StateMaster.consumeEvent(StateEvents.GoToOrdersView)
onHistoryClicked: StateMaster.consumeEvent(StateEvents.GoToHistoryView)
}
}
states: [
State {
name: "splashState"
PropertyChanges {target: splashView; visible: true }
},
State {
name: "loginState"
PropertyChanges {target: loginView; visible: true; url: currentUser.loginUrl; }
},
State {
name: "_loggedInBaseState"
PropertyChanges {target: loggedInView; visible: true; }
},
State {
name: "userState"
extend: "_loggedInBaseState"
PropertyChanges {target: userView; visible: true }
},
State {
name: "bankState"
extend: "_loggedInBaseState"
PropertyChanges {target: bankView; visible: true }
},
State {
name: "orderState"
extend: "_loggedInBaseState"
PropertyChanges {target: orderView; visible: true }
},
State {
name: "historyState"
extend: "_loggedInBaseState"
PropertyChanges {target: historyView; visible: true }
}
]
}