Unity 8
DashNavigationList.qml
1 /*
2  * Copyright (C) 2014,2015 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU 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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 import QtQuick 2.4
18 import Ubuntu.Components 1.3
19 import Ubuntu.Components.ListItems 1.3 as ListItems
20 import "../Components"
21 
22 Item {
23  id: root
24  property var navigation: null
25  property var currentNavigation: null
26  signal enterNavigation(var newNavigationId, string newNavigationLabel, bool hasChildren)
27 
28  readonly property int itemHeight: units.gu(5)
29  implicitHeight: flickable.contentHeight
30 
31  clip: true
32 
33  Behavior on height {
34  UbuntuNumberAnimation {
35  id: heightAnimation
36  duration: UbuntuAnimation.SnapDuration
37  }
38  }
39 
40  Flickable {
41  id: flickable
42 
43  anchors.fill: parent
44 
45  flickableDirection: Flickable.VerticalFlick
46  contentHeight: column.height
47  contentWidth: width
48 
49  Column {
50  id: column
51  width: parent.width
52 
53  Repeater {
54  model: navigation && navigation.loaded ? navigation : null
55  clip: true
56  // FIXME Move to ListItem (and remove import) once 1556971 is fixed
57  delegate: ListItems.Empty {
58  objectName: root.objectName + "child" + index
59  height: root.itemHeight
60  width: column.width
61  anchors {
62  left: column.left
63  right: column.right
64  leftMargin: units.gu(2)
65  rightMargin: units.gu(2)
66  }
67 
68  onClicked: root.enterNavigation(navigationId, allLabel != "" ? allLabel : label, hasChildren)
69 
70  Icon {
71  id: leftIcon
72  anchors {
73  verticalCenter: parent.verticalCenter
74  left: parent.left
75  }
76  height: units.gu(2)
77  width: height
78  name: "tick"
79  color: "#3EB34F"
80  visible: isActive
81  }
82 
83  Label {
84  anchors {
85  verticalCenter: parent.verticalCenter
86  left: leftIcon.right
87  leftMargin: units.gu(1)
88  right: rightIcon.left
89  rightMargin: units.gu(2)
90  }
91  text: label
92  color: isActive ? "#333333" : "#888888"
93  wrapMode: Text.Wrap
94  maximumLineCount: 2
95  elide: Text.ElideMiddle
96  }
97 
98  Icon {
99  id: rightIcon
100  anchors {
101  verticalCenter: parent.verticalCenter
102  right: parent.right
103  }
104  height: units.gu(2)
105  width: height
106  name: "go-next"
107  visible: hasChildren
108  }
109 
110  divider.visible: index != navigation.count - 1
111  }
112  }
113  }
114  }
115 }