on fec22fa help sign in
161 lines 4.4 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24import "utils.js" as Utils
26HeroMessage {
27 id: snapDecision
29 property string title: ""
30 property string time: ""
31 property string message: ""
33 property bool activateEnabled: true
34 property alias actionButtonText: actionButton.text
36 property bool replyEnabled: true
37 property alias replyMessages: quickreply.messages
38 property alias replyButtonText: quickreply.buttonText
40 expandedHeight: buttons.y + buttons.height + quickreply.height + units.gu(2)
41 heroMessageHeader.titleText.text: title
42 heroMessageHeader.subtitleText.text: message
43 heroMessageHeader.subtitleText.color: "#e8e1d0"
44 heroMessageHeader.bodyText.text: time
45 heroMessageHeader.bodyText.color: "#8f8f88"
47 signal activate
48 signal reply(string value)
50 Item {
51 id: buttons
53 anchors.left: parent.left
54 anchors.leftMargin: units.gu(2)
55 anchors.right: parent.right
56 anchors.rightMargin: units.gu(2)
57 anchors.top: heroMessageHeader.bottom
58 anchors.topMargin: units.gu(1)
59 height: units.gu(4)
60 opacity: 0.0
62 Button {
63 text: "Message"
64 color: "#bababa"
65 anchors.left: parent.left
66 anchors.top: parent.top
67 anchors.bottom: parent.bottom
68 width: (parent.width - units.gu(1)) / 2
70 onClicked: {
71 if (quickreply.state === "") {
72 quickreply.state = "expanded";
73 } else {
74 quickreply.state = "";
75 }
76 }
77 }
79 Button {
80 id: actionButton
81 text: "Call back"
82 color: enabled ? "#c94212" : "#bababa"
83 anchors.right: parent.right
84 anchors.top: parent.top
85 anchors.bottom: parent.bottom
86 width: (parent.width - units.gu(1)) / 2
87 enabled: snapDecision.activateEnabled
89 onClicked: {
90 snapDecision.activate();
91 }
92 }
94 states: State {
95 name: "expanded"
96 when: snapDecision.state === "expanded"
98 PropertyChanges {
99 target: buttons
100 opacity: 1.0
101 }
102 }
103 transitions: Transition {
104 NumberAnimation {
105 property: "opacity"
106 duration: 200
107 easing.type: Easing.OutQuad
108 }
109 }
110 }
112 QuickReply {
113 id: quickreply
115 onReply: {
116 snapDecision.reply(value);
117 }
119 messages: ""
120 buttonText: "Send"
121 anchors {
122 top: buttons.bottom
123 topMargin: units.gu(2)
124 left: parent.left
125 right: parent.right
126 }
127 height: 0
128 opacity: 0.0
129 enabled: false
130 replyEnabled: snapDecision.replyEnabled
132 states: State {
133 name: "expanded"
135 PropertyChanges {
136 target: quickreply
137 height: expandedHeight
138 opacity: 1.0
139 }
141 PropertyChanges {
142 target: quickreply
143 enabled: true
144 }
145 }
147 transitions: Transition {
148 NumberAnimation {
149 properties: "opacity,height"
150 duration: 200
151 easing.type: Easing.OutQuad
152 }
153 }
154 }
156 onStateChanged: {
157 if (state === "") {
158 quickreply.state = "";
159 }
160 }