Dekko
Loading...
Searching...
No Matches
ContactDetail.qml
1import QtQuick 2.4
2import QtQuick.Controls.Suru 2.2
3import Lomiri.Components 1.3
4import Dekko.Components 1.0
5import Dekko.Lomiri.Components 1.0
7Item {
8 property bool editable: false
9 property alias title: title.text
10 property alias detail: value.text
11 property Action detailAction: null
12 height: col.height > units.gu(5) ? col.height + units.gu(2) : units.gu(5)
13 width: parent.width
14 signal valueChanged(string val)
15
16 Column {
17 id: col
18 spacing: units.gu(1)
19 anchors {
20 left: parent.left
21 leftMargin: units.gu(2)
22 top: parent.top
23 topMargin: units.gu(2)
24 right: actionButton.left
25 rightMargin: units.gu(2)
26
27 }
28
29 Label {
30 id: title
31 visible: text !== ""
32 anchors {
33 left: parent.left
34 right: parent.right
35 }
36 color: Suru.secondaryForegroundColor
37 }
38 Label {
39 id: value
40 visible: !editable && text !== ""
41 anchors {
42 left: parent.left
43 leftMargin: units.gu(1)
44 right: parent.right
45 }
46 }
47 TextField {
48 id: editField
49 visible: editable
50 anchors {
51 left: parent.left
52 right: parent.right
53 }
54 text: value.text
55 onTextChanged: valueChanged(text)
56 }
57 }
58 AbstractButton {
59 id: actionButton
60 visible: detailAction !== null && !editable
61 width: visible ? height : 0
62 anchors {
63 right: parent.right
64 rightMargin: units.gu(2)
65 top: parent.top
66 topMargin: units.gu(1)
67 bottom: parent.bottom
68 }
69 CachedImage {
70 height: units.gu(2.5)
71 width: height
72 name: Icons.MailUnreadIcon
73 anchors.centerIn: parent
74 }
75 onClicked: detailAction.trigger()
76 }
77}