Dekko
Loading...
Searching...
No Matches
NavigationGroup.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*/
18import QtQuick 2.4
19import Lomiri.Components 1.3
20import Dekko.Lomiri.Constants 1.0
21
22Item {
23 id: root
24 clip: true
25 width: parent.width
26 height: btn.height
27 property alias title: lbl.text
28 property alias model: repeater.model
29 property alias delegate: repeater.delegate
30
31 property bool expanded: false
32
33 AbstractButton {
34 id: btn
35 height: lbl.height + units.gu(2)
36 anchors {
37 left: parent.left
38 top: parent.top
39 right: parent.right
40 }
41
42 onClicked: root.expanded = !root.expanded
43
44 Rectangle {
45 anchors.fill: parent
46 color: LomiriColors.slate
47 visible: btn.pressed
48 }
49
50 Label {
51 id: lbl
52 anchors {
53 left: parent.left
54 leftMargin: units.gu(1)
55 right: parent.right
56 verticalCenter: parent.verticalCenter
57 }
58 color: LomiriColors.ash
59 }
60
61 Icon {
62 height: units.gu(3)
63 width: height
64 anchors {
65 right: parent.right
66 verticalCenter: parent.verticalCenter
67 rightMargin: units.gu(1.5)
68 }
69 name: root.expanded ? "view-collapse" : "view-expand"
70 }
71 }
72
73 Column {
74 id: col
75 anchors {
76 left: parent.left
77 right: parent.right
78 top: btn.bottom
79 }
80
81 Repeater {
82 id: repeater
83 }
84 }
85
86 Behavior on height {
87 LomiriNumberAnimation{}
88 }
89
90 states: [
91 State {
92 name: "collapsed"
93 when: !root.expanded
94 PropertyChanges {
95 target: root
96 height: btn.height
97 }
98 },
99 State {
100 name: "expanded"
101 when: root.expanded
102 PropertyChanges {
103 target: root
104 height: btn.height + col.height
105 }
106 }
107 ]
108}