on 22208df help sign in
167 lines 4.5 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 Unity.Indicators 0.1
26HeroMessage {
27 id: snapDecision
29 property string title: ""
30 property var 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: timeFormatter.timeString
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 TimeFormatter {
63 id: timeFormatter
64 time: snapDecision.time
65 format: "hh:mm - MMM dd"
66 }
68 Button {
69 text: "Message"
70 color: "#bababa"
71 anchors.left: parent.left
72 anchors.top: parent.top
73 anchors.bottom: parent.bottom
74 width: (parent.width - units.gu(1)) / 2
76 onClicked: {
77 if (quickreply.state === "") {
78 quickreply.state = "expanded";
79 } else {
80 quickreply.state = "";
81 }
82 }
83 }
85 Button {
86 id: actionButton
87 text: "Call back"
88 color: enabled ? "#c94212" : "#bababa"
89 anchors.right: parent.right
90 anchors.top: parent.top
91 anchors.bottom: parent.bottom
92 width: (parent.width - units.gu(1)) / 2
93 enabled: snapDecision.activateEnabled
95 onClicked: {
96 snapDecision.activate();
97 }
98 }
100 states: State {
101 name: "expanded"
102 when: snapDecision.state === "expanded"
104 PropertyChanges {
105 target: buttons
106 opacity: 1.0
107 }
108 }
109 transitions: Transition {
110 NumberAnimation {
111 property: "opacity"
112 duration: 200
113 easing.type: Easing.OutQuad
114 }
115 }
116 }
118 QuickReply {
119 id: quickreply
121 onReply: {
122 snapDecision.reply(value);
123 }
125 messages: ""
126 buttonText: "Send"
127 anchors {
128 top: buttons.bottom
129 topMargin: units.gu(2)
130 left: parent.left
131 right: parent.right
132 }
133 height: 0
134 opacity: 0.0
135 enabled: false
136 replyEnabled: snapDecision.replyEnabled
138 states: State {
139 name: "expanded"
141 PropertyChanges {
142 target: quickreply
143 height: expandedHeight
144 opacity: 1.0
145 }
147 PropertyChanges {
148 target: quickreply
149 enabled: true
150 }
151 }
153 transitions: Transition {
154 NumberAnimation {
155 properties: "opacity,height"
156 duration: 200
157 easing.type: Easing.OutQuad
158 }
159 }
160 }
162 onStateChanged: {
163 if (state === "") {
164 quickreply.state = "";
165 }
166 }