| 1 |
/* |
| 2 |
* Copyright (C) 2015-2016 Canonical Ltd. |
| 3 |
* |
| 4 |
* This file is part of Lomiri Weather App |
| 5 |
* |
| 6 |
* Lomiri Weather App is free software: you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License version 3 as |
| 8 |
* published by the Free Software Foundation. |
| 9 |
* |
| 10 |
* Lomiri Weather App 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 |
*/ |
| 18 |
|
| 19 |
import QtQuick 2.12 |
| 20 |
import Lomiri.Components 1.3 |
| 21 |
|
| 22 |
/* |
| 23 |
Component which extends the SDK Expandable list item and provides a easy |
| 24 |
to use component where the title, subtitle and a listview can be displayed. It |
| 25 |
matches the design specification provided for clock. |
| 26 |
*/ |
| 27 |
|
| 28 |
ListItem { |
| 29 |
id: expandableListItem |
| 30 |
|
| 31 |
// Public APIs |
| 32 |
property ListModel model |
| 33 |
property Component delegate |
| 34 |
property alias title: expandableHeader.title |
| 35 |
property alias subText: expandableHeader.subtitle |
| 36 |
property alias description: expandableHeader.summary |
| 37 |
property alias listViewHeight: expandableList.height |
| 38 |
|
| 39 |
// For autopilot |
| 40 |
readonly property double expansionHeight: expansion.height |
| 41 |
|
| 42 |
//highlightColor: "Transparent" |
| 43 |
height: expandableHeader.height |
| 44 |
divider.visible: false |
| 45 |
expansion.height: contentColumn.height |
| 46 |
onClicked: toggleExpansion() |
| 47 |
|
| 48 |
function toggleExpansion() { |
| 49 |
expansion.expanded = !expansion.expanded |
| 50 |
} |
| 51 |
|
| 52 |
Column { |
| 53 |
id: contentColumn |
| 54 |
|
| 55 |
anchors { |
| 56 |
left: parent.left |
| 57 |
right: parent.right |
| 58 |
} |
| 59 |
|
| 60 |
ListItem { |
| 61 |
height: expandableHeader.height + divider.height |
| 62 |
divider.visible: false |
| 63 |
|
| 64 |
ListItemLayout { |
| 65 |
id: expandableHeader |
| 66 |
summary.font.pixelSize: units.gu(1.3) |
| 67 |
|
| 68 |
Icon { |
| 69 |
id: arrow |
| 70 |
width: units.gu(2) |
| 71 |
height: width |
| 72 |
SlotsLayout.position: SlotsLayout.Trailing |
| 73 |
SlotsLayout.overrideVerticalPositioning: true |
| 74 |
anchors.verticalCenter: parent.verticalCenter |
| 75 |
name: "go-down" |
| 76 |
rotation: expandableListItem.expansion.expanded ? 180 : 0 |
| 77 |
|
| 78 |
Behavior on rotation { |
| 79 |
LomiriNumberAnimation {} |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
ListView { |
| 86 |
id: expandableList |
| 87 |
width: parent.width - units.gu(2) |
| 88 |
anchors.right: parent.right |
| 89 |
interactive: false |
| 90 |
model: expandableListItem.model |
| 91 |
delegate: expandableListItem.delegate |
| 92 |
} |
| 93 |
} |
| 94 |
} |