Dekko
SenderIdentityField.qml
1 /* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2 
3  This file is part of Dekko email client for Ubuntu devices
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License as
7  published by the Free Software Foundation; either version 2 of
8  the License or (at your option) 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 import QtQuick 2.4
19 import Lomiri.Components 1.3
20 import Dekko.Mail.Accounts 1.0
21 import Dekko.Components 1.0
22 import Dekko.Mail.API 1.0
23 import Dekko.Mail.Stores.Composer 1.0
24 import Dekko.Lomiri.Constants 1.0
25 import Dekko.Lomiri.Components 1.0
26 
27 FocusScope {
28  id: root
29  width: parent.width
30  height: state === "collapsed" ? from.height : from.height + col.height
31  clip: true
32 
33  Item {
34  id: from
35  height: units.gu(4)
36  width: parent.width
37  StretchRow {
38  anchors {
39  leftMargin: Style.smallSpacing
40  fill: parent
41  rightMargin: units.gu(1.75)
42  }
43  spacing: Style.defaultSpacing
44 
45  Label {
46  id: type
47  anchors {
48  left: parent.left
49  top: parent.top
50  leftMargin: Style.smallSpacing
51  topMargin: Style.smallSpacing
52  }
53  text: qsTr("From:")
54  }
55 
56  Stretcher {
57 
58  LomiriShape {
59  id: delegate
60  aspect: LomiriShape.Flat
61  color: Qt.rgba(0, 0, 0, 0.05)
62  radius: "small"
63  height: units.gu(3)
64  width: inner_avatar.width + label.width + units.gu(1.5)
65  implicitHeight: height
66  implicitWidth: width
67  visible: ComposerStore.hasValidIdentity
68  anchors {
69  left: parent.left
70  top: parent.top
71  topMargin: units.gu(0.5)
72  }
73 
74  Avatar {
75  id: inner_avatar
76  width: height
77  anchors {
78  left: parent.left
79  top: parent.top
80  bottom: parent.bottom
81  margins: units.dp(1)
82  }
83  name: ComposerStore.identity.name
84  initials: ComposerStore.identity.initials
85  email: ComposerStore.identity.email
86  fontSize: "x-small"
87  validContact: true
88  }
89 
90  Label {
91  id: label
92  anchors {
93  left: inner_avatar.right
94  leftMargin: units.gu(0.5)
95  verticalCenter: parent.verticalCenter
96  }
97  text: ComposerStore.identity.name
98  }
99  }
100  }
101  Icon {
102  height: units.gu(2.25)
103  width: height
104  anchors {
105  top: parent.top
106  topMargin: Style.smallSpacing
107  }
108  name: root.state === "collapsed" ? "down" : "up"
109  }
110  }
111  MouseArea {
112  anchors.fill: parent
113  onClicked: root.state === "collapsed" ? root.state = "expanded" : root.state = "collapsed"
114  }
115  }
116 
117  Column {
118  id: col
119  anchors {
120  left: parent.left
121  right: parent.right
122  top: from.bottom
123  }
124 
125  Repeater {
126  model: ComposerStore.identitiesModel
127  delegate: ListItem {
128  id: d
129  property var wrapper: model.qtObject
130  height: layout.height
131  anchors {
132  left: parent ? parent.left : undefined
133  right: parent ? parent.right : undefined
134  }
135  Rectangle {
136  anchors.fill: parent
137  visible: ComposerStore.identityIndex === model.index
138  color: Qt.rgba(0, 0, 0, 0.05)
139  }
140  ListItemLayout {
141  id: layout
142  height: units.gu(5.5)
143  title.text: d.wrapper ? d.wrapper.identity.name : ""
144  subtitle.text: d.wrapper ? d.wrapper.identity.email : ""
145 
146  Avatar {
147  height: units.gu(4.5)
148  width: height
149  name: d.wrapper ? d.wrapper.identity.name : ""
150  initials: d.wrapper ? d.wrapper.identity.initials : ""
151  email: d.wrapper ? d.wrapper.identity.email: ""
152  fontSize: "medium"
153  validContact: true
154  SlotsLayout.position: SlotsLayout.Leading
155  }
156  }
157  onClicked: {
158  root.state = "collapsed"
159  ComposerActions.setIdentity(model.index)
160  }
161  }
162  }
163  }
164  state: "collapsed"
165  states: [
166  State {
167  name: "collapsed"
168  },
169  State {
170  name: "expanded"
171  }
172  ]
173  Behavior on height {
174  LomiriNumberAnimation{}
175  }
176 
177  Line {
178  anchors {
179  left: parent.left
180  right: parent.right
181  bottom: parent.bottom
182  }
183  }
184 }
185 
Dekko::Lomiri::Components::Avatar
Definition: Avatar.qml:26
Dekko
Definition: Dekko.qml:30
Dekko::Lomiri::Components::Line
Definition: Line.qml:22
Dekko::Lomiri::Constants::Style::defaultSpacing
int defaultSpacing
Definition: Style.qml:27
Dekko::Lomiri::Constants::Style
Definition: Style.qml:23
Dekko::Lomiri::Constants::Style::smallSpacing
int smallSpacing
Definition: Style.qml:33