summaryrefslogtreecommitdiff
path: root/rockwork/qml/AppStoreDetailsPage.qml
blob: dbb8d5f1d74b24479006101216cf181d47307916 (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
267
268
269
270
271
272
273
274
275
276
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtGraphicalEffects 1.0

Page {
    id: root
    title: i18n.tr("App details")

    property var pebble: null
    property var app: null

    ColumnLayout {
        anchors.fill: parent
        spacing: units.gu(1)

        Item {
            Layout.fillWidth: true
            height: headerColumn.height + units.gu(1)

            RowLayout {
                anchors.fill: parent
                anchors.margins: units.gu(1)
                spacing: units.gu(1)
                height: headerColumn.height

                UbuntuShape {
                    id: iconShape
                    Layout.fillHeight: true
                    Layout.preferredWidth: height

                    source: Image {
                        height: iconShape.height
                        width: iconShape.width
                        source: root.app.icon
                    }
                }

                ColumnLayout {
                    id: headerColumn
                    Layout.fillWidth: true
                    Label {
                        text: root.app.name
                        fontSize: "large"
                        Layout.fillWidth: true
                        elide: Text.ElideRight
                    }
                    Label {
                        text: root.app.vendor
                        Layout.fillWidth: true
                    }
                }

                Button {
                    id: installButton
                    text: enabled ? i18n.tr("Install") : (installing && !installed ? i18n.tr("Installing...") : i18n.tr("Installed"))
                    color: UbuntuColors.green
                    enabled: !installed && !installing
                    property bool installing: false
                    property bool installed: root.pebble.installedApps.contains(root.app.storeId) || root.pebble.installedWatchfaces.contains(root.app.storeId)
                    Connections {
                        target: root.pebble.installedApps
                        onChanged: {
                            installButton.installed = root.pebble.installedApps.contains(root.app.storeId) || root.pebble.installedWatchfaces.contains(root.app.storeId)
                        }
                    }

                    Connections {
                        target: root.pebble.installedWatchfaces
                        onChanged: {
                            installButton.installed = root.pebble.installedApps.contains(root.app.storeId) || root.pebble.installedWatchfaces.contains(root.app.storeId)
                        }
                    }

                    onClicked: {
                        root.pebble.installApp(root.app.storeId)
                        installButton.installing = true
                    }
                }
            }
        }

        Flickable {
            Layout.fillHeight: true
            Layout.fillWidth: true
            contentHeight: contentColumn.height
            bottomMargin: units.gu(1)
            clip: true

            Column {
                id: contentColumn
                width: parent.width
                height: childrenRect.height

                Image {
                    width: parent.width
                    // ss.w : ss.h = w : h
                    height: sourceSize.height * width / sourceSize.width
                    fillMode: Image.PreserveAspectFit
                    source: root.app.headerImage
                }

                RowLayout {
                    anchors {
                        left: parent.left
                        right: parent.right
                    }
                    height: units.gu(6)

                    Item {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        Row {
                            anchors.centerIn: parent
                            spacing: units.gu(1)
                            Icon {
                                name: "like"
                                height: parent.height
                                width: height
                            }
                            Label {
                                text: root.app.hearts
                            }
                        }
                    }

                    Rectangle {
                        Layout.preferredHeight: parent.height - units.gu(2)
                        Layout.preferredWidth: units.dp(1)
                        color: UbuntuColors.lightGrey
                    }

                    Item {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        Row {
                            anchors.centerIn: parent
                            spacing: units.gu(1)
                            Icon {
                                name: root.app.isWatchFace ? "clock-app-symbolic" : "stock_application"
                                height: parent.height
                                width: height
                            }
                            Label {
                                text: root.app.isWatchFace ? "Watchface" : "Watchapp"
                            }
                        }
                    }
                }

                ColumnLayout {
                    anchors { left: parent.left; right: parent.right; margins: units.gu(1) }
                    spacing: units.gu(1)

                    PebbleModels {
                        id: modelModel
                    }


                    Item {
                        id: screenshotsItem
                        Layout.preferredHeight: units.gu(20)
                        Layout.fillWidth: true

                        property bool isRound: modelModel.get(root.pebble.model).shape === "round"

                        ListView {
                            id: screenshotsListView
                            anchors.centerIn: parent
                            width: parent.width
                            height: screenshotsItem.isRound ? units.gu(10) : units.gu(9.5)
                            orientation: ListView.Horizontal
                            spacing: units.gu(1)
                            snapMode: ListView.SnapToItem
                            preferredHighlightBegin: (screenshotsListView.width - height * .95) / 2
                            preferredHighlightEnd: (screenshotsListView.width + height * .95) / 2
                            highlightRangeMode: ListView.StrictlyEnforceRange

                            model: root.app.screenshotImages
                            delegate: AnimatedImage {
                                height: screenshotsListView.height
                                width: height * 0.95
                                fillMode: Image.PreserveAspectFit
                                source: modelData
                            }
                        }
                        Image {
                            id: watchImage
                            // ssw : ssh = w : h
                            height: parent.height
                            width: height * sourceSize.width / sourceSize.height
                            fillMode: Image.PreserveAspectFit
                            anchors.centerIn: parent
                            source:  modelModel.get(root.pebble.model).image
                            Rectangle {
                                anchors.centerIn: parent
                                height: units.gu(10)
                                width: height
                                color: "black"
                                radius: screenshotsItem.isRound ? height / 2 : 0
                            }
                        }

                        OpacityMask {
                            anchors.fill: screenshotsListView
                            source: screenshotsListView
                            maskSource: maskRect
                        }

                        Rectangle {
                            id: maskRect
                            anchors.fill: screenshotsListView
                            color: "transparent"
                            visible: false

                            Rectangle {
                                color: "blue"
                                anchors.centerIn: parent
                                height: screenshotsListView.height
                                width: screenshotsItem.isRound ? height : height * 0.9
                                radius: screenshotsItem.isRound ? height / 2 : units.gu(.5)
//                                anchors.fill: watchImage
//                                anchors.margins: units.gu(5)
//                                radius: modelModel.get(root.pebble.model).shape === "rectangle" ? units.gu(.5) : height / 2
//                                visible: false
                            }
                        }

                    }

                    Label {
                        Layout.fillWidth: true
                        font.bold: true
                        text: i18n.tr("Description")
                    }

                    Rectangle {
                        Layout.fillWidth: true
                        Layout.preferredHeight: units.dp(1)
                        color: UbuntuColors.lightGrey
                    }

                    Label {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        wrapMode: Text.WordWrap
                        text: root.app.description
                    }

                    GridLayout {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        columns: 2
                        columnSpacing: units.gu(1)
                        rowSpacing: units.gu(1)
                        Label {
                            text: i18n.tr("Developer")
                            font.bold: true
                        }
                        Label {
                            text: root.app.vendor
                            Layout.fillWidth: true
                        }
                        Label {
                            text: i18n.tr("Version")
                            font.bold: true
                        }
                        Label {
                            text: root.app.version
                            Layout.fillWidth: true
                        }
                    }
                }
            }
        }
    }
}