2 * Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
18 import Ubuntu.Components 1.1
19 import "../Components"
23 property var navigation: null
24 property var currentNavigation: null
25 property var scopeStyle: null
26 property color foregroundColor: Theme.palette.normal.baseText
27 signal enterNavigation(var newNavigationId, bool hasChildren)
28 signal goBackToParentClicked()
29 signal allNavigationClicked()
31 readonly property int itemHeight: units.gu(5)
32 implicitHeight: flickable.contentHeight
35 style: root.scopeStyle ? root.scopeStyle.navigationBackground : "color:///#f5f5f5"
42 UbuntuNumberAnimation {
44 duration: UbuntuAnimation.SnapDuration
53 flickableDirection: Flickable.VerticalFlick
54 contentHeight: column.height
61 // TODO: check if SDK ListItems could be used here
62 // and if not make them be useful since this is a quite common pattern
66 objectName: "backButton"
68 visible: navigation && !navigation.isRoot || false
71 onClicked: root.goBackToParentClicked();
76 verticalCenter: parent.verticalCenter
78 leftMargin: units.gu(2)
83 color: root.foregroundColor
88 verticalCenter: parent.verticalCenter
91 leftMargin: units.gu(0.5)
92 rightMargin: units.gu(2)
94 text: navigation ? navigation.parentLabel : ""
95 color: root.foregroundColor
98 elide: Text.ElideMiddle
103 bottom: parent.bottom
106 leftMargin: units.gu(2)
107 rightMargin: units.gu(2)
109 color: root.foregroundColor
117 objectName: "allButton"
119 visible: navigation && (!navigation.isRoot || (!navigation.hidden && root.currentNavigation && !root.currentNavigation.isRoot && root.currentNavigation.parentNavigationId == navigation.navigationId)) || false
124 verticalCenter: parent.verticalCenter
127 leftMargin: units.gu(2)
128 rightMargin: units.gu(2)
130 text: navigation ? (navigation.allLabel != "" ? navigation.allLabel : navigation.label) : ""
132 color: root.foregroundColor
135 elide: Text.ElideMiddle
140 bottom: parent.bottom
143 leftMargin: units.gu(2)
144 rightMargin: units.gu(2)
146 color: root.foregroundColor
151 onClicked: root.allNavigationClicked();
155 model: navigation && navigation.loaded ? navigation : null
157 delegate: AbstractButton {
158 objectName: root.objectName + "child" + index
159 height: root.itemHeight
162 onClicked: root.enterNavigation(navigationId, hasChildren)
166 verticalCenter: parent.verticalCenter
168 leftMargin: units.gu(2)
169 right: rightIcon.visible ? rightIcon.left : parent.right
170 rightMargin: rightIcon.visible ? units.gu(0.5) : units.gu(2)
173 color: root.foregroundColor
176 elide: Text.ElideMiddle
182 verticalCenter: parent.verticalCenter
184 rightMargin: units.gu(2)
188 name: hasChildren ? "go-next" : "tick"
189 color: root.foregroundColor
190 visible: hasChildren || isActive
195 bottom: parent.bottom
198 leftMargin: units.gu(2)
199 rightMargin: units.gu(2)
201 color: root.foregroundColor
204 visible: index != navigation.count - 1