summaryrefslogtreecommitdiff
path: root/app/qml/pages/AppStorePage.qml
blob: 4993b1b246f8165348a2bcc362c7d72ed02ee952 (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
import QtQuick 2.0
import QtQml 2.1
import Sailfish.Silica 1.0
import org.pebbled 0.1
import org.nemomobile.configuration 1.0

Page {
    id: page

    property bool showSearch;

    ConfigurationGroup {
        id: settings
        path: "/org/pebbled/settings"
        property string storeAccessToken: ""
    }

    SilicaFlickable {
        id: flickable
        anchors.top: parent.top
        width: parent.width
        height: column.height

        PullDownMenu {
            visible: webview.loggedin;

            MenuItem {
                text: qsTr("Logout")
                onClicked: {
                    remorse.execute(qsTr("Logging out..."), function() {
                        webview.logout();
                    });
                }
            }

            MenuItem {
                text: showSearch ? qsTr("Hide search") : qsTr("Show search");
                onClicked: {
                    showSearch = !showSearch;
                }
            }
        }

        Column {
            id: column
            width: page.width

            PageHeader {
                id: pageHeadTitle
                title: qsTr("Pebble Appstore")
            }

            SearchField {
                width: parent.width
                visible: webview.loggedin && showSearch
                id: searchField
                onTextChanged: {
                    var q = searchField.text.trim();
                    if (q.length >= 2) {
                        webview.searchQuery(q);
                    }
                }
            }

            Row {
                anchors.horizontalCenter: parent.horizontalCenter
                visible: webview.loggedin

                IconButton {
                    id: backButton
                    enabled: webview.canGoBack
                    icon.source: "image://theme/icon-m-back"
                    onClicked: {
                        webview.goBack();
                    }
                }

                Button {
                    text: qsTr("Apps")
                    width: (page.width - loadingIndicator.width - backButton.width - Theme.paddingMedium) / 2
                    onClicked: {
                        webview.gotoWatchApps();
                    }
                }

                Button {
                    text: qsTr("Faces")
                    width: (page.width - loadingIndicator.width - backButton.width - Theme.paddingMedium) / 2
                    onClicked: {
                        webview.gotoWatchFaces();
                    }
                }

                BusyIndicator {
                    id: loadingIndicator
                    running: webview.loading
                    size: BusyIndicatorSize.Medium
                }
            }

            Column {
                id: download
                visible: webview.downloadInProgress
                width: parent.width
                spacing: Theme.paddingLarge

                Label {
                    anchors.horizontalCenter: parent.horizontalCenter
                    id: downloadLabel
                    text: qsTr("Downloading...")
                }

                BusyIndicator {
                    anchors.horizontalCenter: parent.horizontalCenter
                    running: true
                    size: BusyIndicatorSize.Large
                }
            }
        }
    }

        RemorsePopup {
            id: remorse
        }

        PebbleStoreView  {
            id: webview
            visible: !webview.downloadInProgress
            width: page.width
            height: page.height - column.height

            anchors {
                top: flickable.bottom
            }

            accessToken: settings.storeAccessToken

            onAccessTokenChanged: {
                settings.storeAccessToken = accessToken;
            }

            onDownloadPebbleApp: {
                downloadLabel.text = qsTr("Downloading %1...").arg(downloadTitle)
            }

            onTitleChanged: {
                pageHeadTitle.title = title;
            }
        }


}