blob: bb8712b63910568d2c1e0b0e1bd00659c9b9a5ba (
plain)
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
265
266
|
import QtQuick 2.4
import Ubuntu.Components 1.3
import QtQuick.Layouts 1.1
import RockWork 1.0
Page {
id: root
title: showWatchApps ? i18n.tr("Add new watchapp") : i18n.tr("Add new watchface")
property var pebble: null
property bool showWatchApps: false
property bool showWatchFaces: false
property string link: ""
function fetchHome() {
if (showWatchApps) {
client.fetchHome(AppStoreClient.TypeWatchapp)
} else {
client.fetchHome(AppStoreClient.TypeWatchface)
}
}
head {
actions: [
Action {
iconName: "search"
onTriggered: {
if (searchField.shown) {
searchField.shown = false;
root.fetchHome();
} else {
searchField.shown = true;
}
}
}
]
}
Component.onCompleted: {
if (root.link) {
client.fetchLink(link)
} else {
root.fetchHome()
}
}
AppStoreClient {
id: client
hardwarePlatform: pebble.hardwarePlatform
}
Item {
id: searchField
anchors { left: parent.left; right: parent.right; top: parent.top }
anchors.topMargin: shown ? 0 : -height
Behavior on anchors.topMargin { UbuntuNumberAnimation {} }
opacity: shown ? 1 : 0
Behavior on opacity { UbuntuNumberAnimation {} }
height: units.gu(6)
property bool shown: false
onShownChanged: {
if (shown) {
searchTextField.focus = true;
}
}
TextField {
id: searchTextField
anchors.centerIn: parent
width: parent.width - units.gu(2)
onDisplayTextChanged: {
searchTimer.restart()
}
Timer {
id: searchTimer
interval: 300
onTriggered: {
client.search(searchTextField.displayText, root.showWatchApps ? AppStoreClient.TypeWatchapp : AppStoreClient.TypeWatchface);
}
}
}
}
Item {
anchors { left: parent.left; top: searchField.bottom; right: parent.right; bottom: parent.bottom }
ListView {
anchors.fill: parent
model: ApplicationsFilterModel {
id: appsFilterModel
model: client.model
}
clip: true
section.property: "groupId"
section.labelPositioning: ViewSection.CurrentLabelAtStart |
ViewSection.InlineLabels
section.delegate: ListItem {
height: section ? label.implicitHeight + units.gu(3) : 0
Rectangle {
anchors.fill: parent
color: "white"
}
RowLayout {
anchors.fill: parent
anchors.margins: units.gu(1)
Label {
id: label
text: client.model.groupName(section)
fontSize: "large"
// font.weight: Font.DemiBold
elide: Text.ElideRight
Layout.fillWidth: true
}
AbstractButton {
Layout.fillHeight: true
implicitWidth: seeAllLabel.implicitWidth + height
Row {
anchors.verticalCenter: parent.verticalCenter
Label {
id: seeAllLabel
text: i18n.tr("See all")
}
Icon {
implicitHeight: parent.height
implicitWidth: height
name: "go-next"
}
}
onClicked: {
pageStack.push(Qt.resolvedUrl("AppStorePage.qml"), {pebble: root.pebble, link: client.model.groupLink(section), title: client.model.groupName(section)});
}
}
}
}
footer: Item {
height: client.model.links.length > 0 ? units.gu(6) : 0
width: parent.width
RowLayout {
anchors {
fill: parent
margins: units.gu(1)
}
spacing: units.gu(1)
Repeater {
model: client.model.links
Button {
text: client.model.linkName(client.model.links[index])
onClicked: client.fetchLink(client.model.links[index]);
color: UbuntuColors.orange
Layout.fillWidth: true
}
}
}
}
delegate: ListItem {
height: delegateColumn.height + units.gu(2)
RowLayout {
id: delegateRow
anchors.fill: parent
anchors.margins: units.gu(1)
spacing: units.gu(1)
AnimatedImage {
Layout.fillHeight: true
Layout.preferredWidth: height
source: model.icon
asynchronous: true
// sourceSize.width: width
// sourceSize.height: height
}
ColumnLayout {
id: delegateColumn
Layout.fillWidth: true;
Layout.fillHeight: true;
Label {
Layout.fillWidth: true
text: model.name
font.weight: Font.DemiBold
elide: Text.ElideRight
}
Label {
Layout.fillWidth: true
text: model.category
}
RowLayout {
Icon {
name: "like"
Layout.preferredHeight: parent.height
Layout.preferredWidth: height
implicitHeight: parent.height
}
Label {
Layout.fillWidth: true
text: model.hearts
}
Icon {
id: tickIcon
name: "tick"
implicitHeight: parent.height
Layout.preferredWidth: height
visible: root.pebble.installedApps.contains(model.storeId) || root.pebble.installedWatchfaces.contains(model.storeId)
Connections {
target: root.pebble.installedApps
onChanged: {
tickIcon.visible = root.pebble.installedApps.contains(model.storeId) || root.pebble.installedWatchfaces.contains(model.storeId)
}
}
Connections {
target: root.pebble.installedWatchfaces
onChanged: {
tickIcon.visible = root.pebble.installedApps.contains(model.storeId) || root.pebble.installedWatchfaces.contains(model.storeId)
}
}
}
}
}
}
onClicked: {
client.fetchAppDetails(model.storeId);
pageStack.push(Qt.resolvedUrl("AppStoreDetailsPage.qml"), {app: appsFilterModel.get(index), pebble: root.pebble})
}
}
}
// RowLayout {
// id: buttonRow
// anchors { left: parent.left; bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
// spacing: units.gu(1)
// Button {
// text: i18n.tr("Previous")
// Layout.fillWidth: true
// enabled: client.offset > 0
// onClicked: {
// client.previous()
// }
// }
// Button {
// text: i18n.tr("Next")
// Layout.fillWidth: true
// onClicked: {
// client.next()
// }
// }
// }
}
ActivityIndicator {
anchors.centerIn: parent
running: client.busy
}
}
|