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"
20 import "../Components/Flickables" as Flickables
24 property var navigation: null
25 property var currentNavigation: null
26 property var scopeStyle: null
27 property color foregroundColor: Theme.palette.normal.baseText
28 signal enterNavigation(var newNavigationId, bool hasChildren)
29 signal goBackToParentClicked()
30 signal allNavigationClicked()
32 readonly property int itemHeight: units.gu(5)
33 implicitHeight: flickable.contentHeight
36 style: root.scopeStyle ? root.scopeStyle.navigationBackground : "color:///#f5f5f5"
43 UbuntuNumberAnimation {
45 duration: UbuntuAnimation.SnapDuration
49 Flickables.Flickable {
54 flickableDirection: Flickable.VerticalFlick
55 contentHeight: column.height
62 // TODO: check if SDK ListItems could be used here
63 // and if not make them be useful since this is a quite common pattern
67 objectName: "backButton"
69 visible: navigation && !navigation.isRoot || false
72 onClicked: root.goBackToParentClicked();
77 verticalCenter: parent.verticalCenter
79 leftMargin: units.gu(2)
84 color: root.foregroundColor
89 verticalCenter: parent.verticalCenter
92 leftMargin: units.gu(0.5)
93 rightMargin: units.gu(2)
95 text: navigation ? navigation.parentLabel : ""
96 color: root.foregroundColor
99 elide: Text.ElideMiddle
104 bottom: parent.bottom
107 leftMargin: units.gu(2)
108 rightMargin: units.gu(2)
110 color: root.foregroundColor
118 objectName: "allButton"
120 visible: navigation && (!navigation.isRoot || (!navigation.hidden && root.currentNavigation && !root.currentNavigation.isRoot && root.currentNavigation.parentNavigationId == navigation.navigationId)) || false
125 verticalCenter: parent.verticalCenter
128 leftMargin: units.gu(2)
129 rightMargin: units.gu(2)
131 text: navigation ? (navigation.allLabel != "" ? navigation.allLabel : navigation.label) : ""
133 color: root.foregroundColor
136 elide: Text.ElideMiddle
141 bottom: parent.bottom
144 leftMargin: units.gu(2)
145 rightMargin: units.gu(2)
147 color: root.foregroundColor
152 onClicked: root.allNavigationClicked();
156 model: navigation && navigation.loaded ? navigation : null
158 delegate: AbstractButton {
159 objectName: root.objectName + "child" + index
160 height: root.itemHeight
163 onClicked: root.enterNavigation(navigationId, hasChildren)
167 verticalCenter: parent.verticalCenter
169 leftMargin: units.gu(2)
170 right: rightIcon.visible ? rightIcon.left : parent.right
171 rightMargin: rightIcon.visible ? units.gu(0.5) : units.gu(2)
174 color: root.foregroundColor
177 elide: Text.ElideMiddle
183 verticalCenter: parent.verticalCenter
185 rightMargin: units.gu(2)
189 name: hasChildren ? "go-next" : "tick"
190 color: root.foregroundColor
191 visible: hasChildren || isActive
196 bottom: parent.bottom
199 leftMargin: units.gu(2)
200 rightMargin: units.gu(2)
202 color: root.foregroundColor
205 visible: index != navigation.count - 1