Dekko
Loading...
Searching...
No Matches
FilterBar.qml
1/* Copyright (C) 2014-2016 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 QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Dekko.Components 1.0
22import Dekko.Lomiri.Constants 1.0
23
24Item {
25 id: filterBar
26
27 property var filterSections: []
28 property alias selectedIndex: row.currentIndex
29 height: units.gu(0)
30 width: parent.width
31
32 Behavior on height {
33 LomiriNumberAnimation {duration: LomiriAnimation.SnapDuration}
34 }
35
36 Rectangle {
37 id: background
38 anchors.fill: parent
39 color: Suru.backgroundColor
40 }
41
42 ListView {
43 id: row
44 anchors {
45 fill: parent
46 leftMargin: Style.defaultSpacing
47 }
48 highlightFollowsCurrentItem: true
49 clip: true
50 snapMode: ListView.SnapToItem
51 orientation: ListView.Horizontal
52 layoutDirection: ListView.LeftToRight
53 cacheBuffer: units.gu(500)
54 currentIndex: 0
55 model: filterSections
56 delegate: AbstractButton {
57 id: d
58 width: label.implicitWidth + units.gu(3.5)
59 height: parent.height
60 Rectangle {
61 anchors {
62 fill: parent
63 }
64 color: Suru.neutralColor
65 visible: d.pressed
66 }
67
68 Label {
69 id: label
70 text: modelData
71 color: row.currentIndex === model.index ? LomiriColors.blue : Suru.tertiaryForegroundColor
72 anchors.horizontalCenter: parent.horizontalCenter
73 anchors.top: parent.top
74 anchors.topMargin: units.gu(0.2)
75 fontSize: "small"
76 renderType: Text.NativeRendering
77 }
78 Rectangle {
79 color: row.currentIndex === model.index ? LomiriColors.blue : Suru.neutralColor
80 height: units.dp(2)
81 width: parent.width
82 anchors.bottom: parent.bottom
83 }
84 onClicked: row.currentIndex = model.index
85 }
86
87 }
88}