on xenial help sign in
Break out our custom PullToRefreshStyle into its own file and add a comment about what's keeping us from using the standard version
commitc6adb8d213a29b12e2b1ba46181d7f26df8e8cdf authorMichael Terry <michael.terry@canonical.com> dateTue 30 Sep 2014, 09:43 (12 years ago) parent597934d
2 files changed+71−45
qml/Dash/GenericScopeView.qml+1−45 qml/Dash/PullToRefreshScopeStyle.qml+70
qml/Dash/GenericScopeView.qml+1−45
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 1.1
19−import Ubuntu.Components.Styles 1.1
2019import Utils 0.1
2120import Unity 0.2
2221import Dash 0.1
@@ -526,52 +525,9 @@ FocusScope {
526525 onProcessingChanged: if (!scopeView.processing) pullToRefresh.refreshing = false
527526 }
528527
529− style: PullToRefreshStyle {
528+ style: PullToRefreshScopeStyle {
530529 anchors.fill: parent
531530 activationThreshold: units.gu(14)
532− releaseToRefresh: -pullToRefresh.contentY > activationThreshold
533−
534− Connections {
535− target: categoryView
536− onDraggingChanged: if (!categoryView.dragging && releaseToRefresh) pullToRefresh.refresh()
537− }
538−
539− Label {
540− id: pullLabel
541− anchors.horizontalCenter: parent.horizontalCenter
542− horizontalAlignment: Text.AlignHCenter
543− verticalAlignment: Text.AlignVCenter
544− states: [
545− State {
546− name: "pulling"
547− when: categoryView.dragging && !releaseToRefresh
548− PropertyChanges { target: pullLabel; text: i18n.tr("Pull to refresh…") }
549− },
550− State {
551− name: "releasable"
552− when: categoryView.dragging && releaseToRefresh
553− PropertyChanges { target: pullLabel; text: i18n.tr("Release to refresh…") }
554− }
555− ]
556− transitions: Transition {
557− SequentialAnimation {
558− UbuntuNumberAnimation {
559− target: pullLabel
560− property: "opacity"
561− to: 0.0
562− }
563− PropertyAction {
564− target: pullLabel
565− property: "text"
566− }
567− UbuntuNumberAnimation {
568− target: pullLabel
569− property: "opacity"
570− to: 1.0
571− }
572− }
573− }
574− }
575531 }
576532 }
577533 }
qml/Dash/PullToRefreshScopeStyle.qmlnew file+70
@@ -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+}