~qqworini/ubuntu-rssreader-app/reboot-add-opml-support

« back to all changes in this revision

Viewing changes to shorts/qml/pages/SwipeDelete.qml

  • Committer: Roman Shchekin
  • Date: 2015-07-21 19:42:29 UTC
  • Revision ID: mrqtros@gmail.com-20150721194229-8hwozqrsnh501cis
"Edit Topics" page reworked.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013 Andrew Hayzen <ahayzen@gmail.com>
3
 
 *                    Daniel Holm <d.holmen@gmail.com>
4
 
 *                    Victor Thompson <victor.thompson@gmail.com>
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; version 3.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
 
19
 
import QtQuick 2.4
20
 
import Ubuntu.Components 1.2
21
 
 
22
 
/* SwipeDelete object */
23
 
Item {
24
 
    id: swipeBackground
25
 
    height: parent.height
26
 
    state: "normal"
27
 
    width: parent.width * 3
28
 
    x: 0 - parent.width  // start out of view
29
 
 
30
 
    property int duration: 0
31
 
    property bool deleteState: false
32
 
 
33
 
    function runSwipeDeletePrepareAnimation()
34
 
    {
35
 
        swipeDeletePrepareAnimation.start();
36
 
    }
37
 
 
38
 
    function runSwipeDeleteAnimation()
39
 
    {
40
 
        swipeDeleteAnimation.start();
41
 
    }
42
 
 
43
 
    Item {
44
 
        id: swipeBackgroundLeft
45
 
        anchors.left: parent.left
46
 
//        color: styleMusic.mainView.backgroundColor
47
 
        height: parent.height
48
 
        width: parent.width / 3
49
 
 
50
 
        Label {
51
 
            id: swipeBackgroundLeftText
52
 
            anchors.fill: parent
53
 
            anchors.margins: units.gu(2)
54
 
//            color: styleMusic.common.white
55
 
            fontSize: "large"
56
 
            horizontalAlignment: Text.AlignRight
57
 
            text: i18n.tr("Remove")
58
 
            verticalAlignment: Text.AlignVCenter
59
 
        }
60
 
    }
61
 
 
62
 
    Item {
63
 
        id: swipeBackgroundRight
64
 
        anchors.right: parent.right
65
 
//        color: styleMusic.mainView.backgroundColor
66
 
        height: parent.height
67
 
        width: parent.width / 3
68
 
 
69
 
        Label {
70
 
            id: swipeBackgroundRightText
71
 
            anchors.fill: parent
72
 
            anchors.margins: units.gu(2)
73
 
//            color: styleMusic.common.white
74
 
            fontSize: "large"
75
 
            horizontalAlignment: Text.AlignLeft
76
 
            text: i18n.tr("Remove")
77
 
            verticalAlignment: Text.AlignVCenter
78
 
        }
79
 
    }
80
 
 
81
 
    // Fade out the text in prepartion for removal
82
 
    ParallelAnimation {
83
 
        id: swipeDeletePrepareAnimation
84
 
        running: false
85
 
        NumberAnimation {
86
 
            target: swipeBackgroundLeftText
87
 
            property: "opacity"
88
 
            to: 0
89
 
            duration: swipeBackground.duration
90
 
        }
91
 
        NumberAnimation {
92
 
            target: swipeBackgroundRightText
93
 
            property: "opacity"
94
 
            to: 0
95
 
            duration: swipeBackground.duration
96
 
        }
97
 
    }
98
 
 
99
 
    /*
100
 
     * Animation to remove the swipe object
101
 
     * - Reduces the height to 0 to 'pull up' the row below
102
 
     * - On animation finish it removes the item from the model
103
 
     */
104
 
    NumberAnimation {
105
 
        id: swipeDeleteAnimation
106
 
        target: swipeBackground
107
 
        properties: "height"
108
 
        to: 0
109
 
        duration: swipeBackground.duration
110
 
 
111
 
        onRunningChanged: {
112
 
            if (running == false)
113
 
            {
114
 
                deleteState = true;
115
 
            }
116
 
        }
117
 
    }
118
 
}