~diegosarmentero/unity/phablet_app-purchase

« back to all changes in this revision

Viewing changes to Dash/Apps/AppPurchase.qml

  • Committer: Diego Sarmentero
  • Date: 2013-05-22 20:21:25 UTC
  • Revision ID: diego.sarmentero@gmail.com-20130522202125-n495emv4oupfqzk2
ProgressBar and moving Tile working

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
import Ubuntu.Components 0.1
 
3
import ".."
 
4
import "../../Applications"
 
5
import "../../Components"
 
6
 
 
7
DashBasePreview {
 
8
    id: root
 
9
 
 
10
    property var item
 
11
    property string price: ""
 
12
    property int index
 
13
 
 
14
    signal download(int index)
 
15
 
 
16
    title: "Diego"
 
17
 
 
18
    body: Rectangle {
 
19
        anchors.fill: parent
 
20
        Column{
 
21
            spacing: units.gu(1)
 
22
            anchors.left: parent.left
 
23
            anchors.leftMargin: units.gu(2)
 
24
 
 
25
            Row {
 
26
                id: rowInstall
 
27
                width: root.width
 
28
                spacing: units.gu(6)
 
29
                property int buttonWidth: Math.min(units.gu(22), (width - spacing) / 2)
 
30
 
 
31
                Column {
 
32
                    Label{
 
33
                        text: "Rate"
 
34
                        color: "white"
 
35
                        fontSize: "medium"
 
36
                        width: parent.width
 
37
                    }
 
38
 
 
39
                    RatingStars {
 
40
                        maximumRating: 10 // FIXME: this should happen on the backend side
 
41
                        rating: 8
 
42
                    }
 
43
                }
 
44
 
 
45
                Button {
 
46
                    id: btnInstall
 
47
                    width: parent.buttonWidth
 
48
                    color: "#dd4814"
 
49
                    text: root.price ? "Buy" : "Install"
 
50
                    visible: text != ""
 
51
                    iconSource: "graphics/icon_button_u1.png"
 
52
                    iconPosition: "right"
 
53
 
 
54
                    onClicked: {
 
55
                        btnInstall.visible = false;
 
56
                        progressBar.opacity = 1;
 
57
                        progressBar.timer.start();
 
58
                        download(index);
 
59
                    }
 
60
                }
 
61
 
 
62
                ProgressBar {
 
63
                    id: progressBar
 
64
                    opacity: 0
 
65
                    value: 0
 
66
                    maximumValue: 100
 
67
                    width: parent.buttonWidth
 
68
                    height: btnInstall.height
 
69
 
 
70
                    property alias timer: timerEvent
 
71
 
 
72
                    Behavior on opacity { PropertyAnimation { duration: 400; } }
 
73
 
 
74
                    Timer {
 
75
                        id: timerEvent
 
76
                        interval: 1000
 
77
                        running: false
 
78
                        onTriggered: {
 
79
                            if(progressBar.value < 100){
 
80
                                progressBar.value += 10;
 
81
                                timerEvent.restart();
 
82
                            }else{
 
83
                                progressBar.opacity = 0;
 
84
                            }
 
85
                        }
 
86
                    }
 
87
                }
 
88
            }
 
89
        }
 
90
    }
 
91
 
 
92
}