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  delegate: Loader {
57  asynchronous: true
58  height: root.itemHeight
59  width: column.width
60  // FIXME Move to ListItem (and remove import) once 1556971 is fixed
61  sourceComponent: ListItems.Empty {
62  objectName: root.objectName + "child" + index
63  anchors {
64  left: parent.left
65  right: parent.right
66  leftMargin: units.gu(2)
67  rightMargin: units.gu(2)
68  }
69 
70  onClicked: root.enterNavigation(navigationId, allLabel != "" ? allLabel : label, hasChildren)
71 
72  Icon {
73  id: leftIcon
74  anchors {
75  verticalCenter: parent.verticalCenter
76  left: parent.left
77  }
78  height: units.gu(2)
79  width: height
80  name: "tick"
81  color: "#3EB34F"
82  visible: isActive
83  }
84 
85  Label {
86  anchors {
87  verticalCenter: parent.verticalCenter
88  left: leftIcon.right
89  leftMargin: units.gu(1)
90  right: rightIcon.left
91  rightMargin: units.gu(2)
92  }
93  text: label
94  color: isActive ? "#333333" : "#888888"
95  wrapMode: Text.Wrap
96  maximumLineCount: 2
97  elide: Text.ElideMiddle
98  }
99 
100  Icon {
101  id: rightIcon
102  anchors {
103  verticalCenter: parent.verticalCenter
104  right: parent.right
105  }
106  height: units.gu(2)
107  width: height
108  name: "go-next"
109  visible: hasChildren
110  }
111 
112  divider.visible: index != navigation.count - 1
113  }
114  }
115  }
116  }
117  }
118 }