QML UI: DiveDetailsView: make key dive info consistent with dive list

Remove the grid layout and replace it with code that is derived from the delegate
that we use in the dive list. In order to look proportional I ended up using a
larger font for the location and therefore decided to allow that text to wrap
instead of forcing single line.

This implements a good chunk of another one of Davide's great
suggestions.

See #431

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-06-20 12:02:30 -07:00
parent cbcb43247e
commit 7ccda01e7e

View file

@ -16,7 +16,7 @@ Item {
property real col3Width: gridWidth * 0.30 property real col3Width: gridWidth * 0.30
width: diveDetailsPage.width - diveDetailsPage.leftPadding - diveDetailsPage.rightPadding width: diveDetailsPage.width - diveDetailsPage.leftPadding - diveDetailsPage.rightPadding
height: mainLayout.implicitHeight + bottomLayout.implicitHeight + Kirigami.Units.iconSizes.large height: divePlate.implicitHeight + bottomLayout.implicitHeight + Kirigami.Units.iconSizes.large
Rectangle { Rectangle {
z: 99 z: 99
color: Kirigami.Theme.textColor color: Kirigami.Theme.textColor
@ -28,73 +28,69 @@ Item {
bottom: parent.bottom bottom: parent.bottom
} }
} }
GridLayout { Item {
id: mainLayout id: divePlate
anchors { width: parent.width - Kirigami.Units.gridUnit
top: parent.top height: childrenRect.height - Kirigami.Units.smallSpacing
left: parent.left anchors.left: parent.left
right: parent.right Kirigami.Label {
margins: Kirigami.Units.gridUnit id: locationText
}
columns: 4
rowSpacing: Kirigami.Units.smallSpacing * 2
columnSpacing: Kirigami.Units.smallSpacing
Kirigami.Heading {
id: detailsViewHeading
Layout.fillWidth: true
text: dive.location text: dive.location
Layout.columnSpan: 4 font.weight: Font.Bold
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere font.pointSize: subsurfaceTheme.titlePointSize
Layout.topMargin: Kirigami.Units.largeSpacing wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: Kirigami.Theme.textColor
anchors {
left: parent.left
top: parent.top
right: parent.right
margins: Math.round(Kirigami.Units.gridUnit / 2)
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
visible: dive.gps_decimal !== ""
onClicked: { onClicked: {
if (dive.gps_decimal !== "") if (dive.gps_decimal !== "")
showMap(dive.gps_decimal) showMap(dive.gps_decimal)
} }
} }
} }
Kirigami.Label { Row {
id: dateLabel anchors {
text: qsTr("Date: ") left: locationText.left
opacity: 0.6 top: locationText.bottom
} bottom: numberText.bottom
Kirigami.Label { }
text: dive.date + " " + dive.time
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere Kirigami.Label {
Layout.columnSpan: 2 text: dive.date + " " + dive.time
width: Math.max(locationText.width * 0.45, paintedWidth)
font.pointSize: subsurfaceTheme.smallPointSize
color: Kirigami.Theme.textColor
}
// let's try to show the depth / duration very compact
Kirigami.Label {
text: dive.depth + ' / ' + dive.duration
width: Math.max(Kirigami.Units.gridUnit * 3, paintedWidth)
font.pointSize: subsurfaceTheme.smallPointSize
color: Kirigami.Theme.textColor
}
} }
Kirigami.Label { Kirigami.Label {
id: numberText id: numberText
text: "#" + dive.number text: "#" + dive.number
font.pointSize: subsurfaceTheme.smallPointSize
color: Kirigami.Theme.textColor color: Kirigami.Theme.textColor
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere anchors {
right: parent.right
top: locationText.bottom
}
} }
Kirigami.Label {
id: depthLabel
text: qsTr("Depth: ")
opacity: 0.6
}
Kirigami.Label {
text: dive.depth
Layout.fillWidth: true
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
}
Kirigami.Label {
text: qsTr("Duration: ")
opacity: 0.6
Layout.alignment: Qt.AlignRight
}
Kirigami.Label {
text: dive.duration
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
} }
GridLayout { GridLayout {
id: bottomLayout id: bottomLayout
anchors { anchors {
top: mainLayout.bottom top: divePlate.bottom
left: parent.left left: parent.left
right: parent.right right: parent.right
margins: Math.round(Kirigami.Units.gridUnit / 2) margins: Math.round(Kirigami.Units.gridUnit / 2)