@@ -0,0 +1,70 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.3
18+import Ubuntu.Components 1.1
19+import Ubuntu.Components.Styles 1.1
20+
21+/**
22+ * TODO: Once the SDK version of PullToRefreshStyle doesn't have bug 1375799
23+ * (https://launchpad.net/bugs/1375799) anymore, we should switch to using a
24+ * a subclass of the Ambiance version with a hidden ActivityIndicator.
25+ */
26+PullToRefreshStyle {
27+ releaseToRefresh: styledItem.target.originY - styledItem.target.contentY > activationThreshold
28+
29+ Connections {
30+ target: styledItem.target
31+ onDraggingChanged: if (!styledItem.target.dragging && releaseToRefresh) styledItem.refresh()
32+ }
33+
34+ Label {
35+ id: pullLabel
36+ anchors.horizontalCenter: parent.horizontalCenter
37+ horizontalAlignment: Text.AlignHCenter
38+ verticalAlignment: Text.AlignVCenter
39+ states: [
40+ State {
41+ name: "pulling"
42+ when: styledItem.target.dragging && !releaseToRefresh
43+ PropertyChanges { target: pullLabel; text: i18n.tr("Pull to refresh…") }
44+ },
45+ State {
46+ name: "releasable"
47+ when: styledItem.target.dragging && releaseToRefresh
48+ PropertyChanges { target: pullLabel; text: i18n.tr("Release to refresh…") }
49+ }
50+ ]
51+ transitions: Transition {
52+ SequentialAnimation {
53+ UbuntuNumberAnimation {
54+ target: pullLabel
55+ property: "opacity"
56+ to: 0.0
57+ }
58+ PropertyAction {
59+ target: pullLabel
60+ property: "text"
61+ }
62+ UbuntuNumberAnimation {
63+ target: pullLabel
64+ property: "opacity"
65+ to: 1.0
66+ }
67+ }
68+ }
69+ }
70+}