Commit bb5b112f authored by Volker Krause's avatar Volker Krause

Only expand the current journey item

Also, add a proper header to the cards.
parent 33a618ee
...@@ -20,6 +20,7 @@ import QtQuick.Layouts 1.1 ...@@ -20,6 +20,7 @@ import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2 import QtQuick.Controls 2.1 as QQC2
import org.kde.kirigami 2.4 as Kirigami import org.kde.kirigami 2.4 as Kirigami
import org.kde.kpublictransport 1.0 import org.kde.kpublictransport 1.0
import org.kde.itinerary 1.0
import "." as App import "." as App
Kirigami.ScrollablePage { Kirigami.ScrollablePage {
...@@ -52,7 +53,7 @@ Kirigami.ScrollablePage { ...@@ -52,7 +53,7 @@ Kirigami.ScrollablePage {
Rectangle { Rectangle {
id: colorBar id: colorBar
width: Kirigami.Units.largeSpacing width: Kirigami.Units.largeSpacing
color: modelData.route.line.color color: modelData.route.line.hasColor ? modelData.route.line.color : "transparent"
Layout.fillHeight: true Layout.fillHeight: true
} }
...@@ -155,20 +156,58 @@ Kirigami.ScrollablePage { ...@@ -155,20 +156,58 @@ Kirigami.ScrollablePage {
Component { Component {
id: journeyDelegate id: journeyDelegate
Kirigami.Card { Kirigami.Card {
id: top
property var journey: modelData property var journey: modelData
header: Text { text: journey.scheduledDepartureTime } // TODO proper header
// TODO collapse sections by default, only expand current element header: Rectangle {
contentItem: ListView { id: headerBackground
delegate: sectionDelegate Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
model: journey.sections Kirigami.Theme.inherit: false
implicitHeight: contentHeight color: Kirigami.Theme.backgroundColor
spacing: Kirigami.Units.smallSpacing implicitHeight: headerLayout.implicitHeight + Kirigami.Units.largeSpacing * 2
anchors.leftMargin: -root.leftPadding
anchors.topMargin: -root.topPadding
anchors.rightMargin: -root.rightPadding
RowLayout {
id: headerLayout
anchors.fill: parent
anchors.margins: Kirigami.Units.largeSpacing
QQC2.Label {
text: Localizer.formatTime(journey, "scheduledDepartureTime")
Layout.fillWidth: true
}
QQC2.Label {
text: displayDuration(journey.duration)
}
}
} }
contentItem: ColumnLayout {
ListView {
delegate: sectionDelegate
model: journeyView.currentIndex == index ? journey.sections : 0
implicitHeight: contentHeight
spacing: Kirigami.Units.smallSpacing
boundsBehavior: Flickable.StopAtBounds
}
QQC2.Label {
text: i18np("One change", "%1 changes", journey.numberOfChanges)
visible: journeyView.currentIndex != index
}
}
// TODO add actions to update to this alternative // TODO add actions to update to this alternative
onClicked: {
journeyView.currentIndex = index;
}
} }
} }
Kirigami.CardsListView { Kirigami.CardsListView {
id: journeyView
anchors.fill: parent anchors.fill: parent
clip: true clip: true
delegate: journeyDelegate delegate: journeyDelegate
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment