on xenial help sign in
Merge improve-header-layout.
076e198Michał Sawicz
qml/Dash/Card.qml+2−1
@@ -28,6 +28,7 @@ Item {
28
28
29 UbuntuShape {
29 UbuntuShape {
30 id: artShape
30 id: artShape
31+ radius: "medium"
31 objectName: "artShape"
32 objectName: "artShape"
32 width: {
33 width: {
33 if (!visible) return 0
34 if (!visible) return 0
@@ -73,7 +74,7 @@ Item {
73
74
74 Label {
75 Label {
75 objectName: "summaryLabel"
76 objectName: "summaryLabel"
76− anchors { top: header.bottom; left: parent.left; right: parent.right }
77+ anchors { top: header.visible ? header.bottom : artShape.bottom; left: parent.left; right: parent.right }
77 wrapMode: Text.Wrap
78 wrapMode: Text.Wrap
78 maximumLineCount: 5
79 maximumLineCount: 5
79 elide: Text.ElideRight
80 elide: Text.ElideRight
qml/Dash/CardHeader.qml+14−3
@@ -27,14 +27,21 @@ Item {
27 property alias altPrice: altPriceLabel.text
27 property alias altPrice: altPriceLabel.text
28
28
29 visible: mascotImage.status === Image.Ready || title || price
29 visible: mascotImage.status === Image.Ready || title || price
30− height: row.height > 0 ? row.height + row.spacing * 2 : 0
30+ height: row.height > 0 ? row.height + row.margins * 2 : 0
31
31
32 Row {
32 Row {
33 id: row
33 id: row
34 objectName: "outerRow"
34 objectName: "outerRow"
35
35
36− anchors { top: parent.top; left: parent.left; right: parent.right; margins: spacing }
36+ property real margins: units.gu(1)
37− spacing: units.gu(1)
37+
38+ anchors {
39+ top: parent.top; left: parent.left; right: parent.right
40+ margins: margins
41+ leftMargin: spacing
42+ rightMargin: spacing
43+ }
44+ spacing: mascotShape.visible ? margins : 0
38
45
39 UbuntuShape {
46 UbuntuShape {
40 id: mascotShape
47 id: mascotShape
@@ -53,6 +60,7 @@ Item {
53 Column {
60 Column {
54 objectName: "column"
61 objectName: "column"
55 width: parent.width - x
62 width: parent.width - x
63+ spacing: units.gu(0.5)
56
64
57 Label {
65 Label {
58 id: titleLabel
66 id: titleLabel
@@ -62,6 +70,7 @@ Item {
62 font.weight: Font.DemiBold
70 font.weight: Font.DemiBold
63 wrapMode: Text.Wrap
71 wrapMode: Text.Wrap
64 maximumLineCount: 2
72 maximumLineCount: 2
73+ fontSize: "small"
65 }
74 }
66
75
67 Label {
76 Label {
@@ -69,7 +78,9 @@ Item {
69 objectName: "subtitleLabel"
78 objectName: "subtitleLabel"
70 anchors { left: parent.left; right: parent.right }
79 anchors { left: parent.left; right: parent.right }
71 elide: Text.ElideRight
80 elide: Text.ElideRight
81+ font.weight: Font.Light
72 visible: titleLabel.text && text
82 visible: titleLabel.text && text
83+ fontSize: "x-small"
73 }
84 }
74
85
75 Row {
86 Row {
tests/qmltests/Dash/tst_Card.qml+22−5
@@ -110,6 +110,10 @@ Rectangle {
110 "name": "Art, header - vertical",
110 "name": "Art, header - vertical",
111 "layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "summary": undefined }) }
111 "layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "summary": undefined }) }
112 },
112 },
113+ {
114+ "name": "Art, summary - vertical",
115+ "layout": { "components": { "art": "art", "summary": "summary" } }
116+ },
113 {
117 {
114 "name": "Header title only - horizontal",
118 "name": "Header title only - horizontal",
115 "layout": { "template": { "card-layout": "horizontal" },
119 "layout": { "template": { "card-layout": "horizontal" },
@@ -365,13 +369,26 @@ Rectangle {
365 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
369 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
366 }
370 }
367
371
372+ function test_summary_layout_data() {
373+ return [
374+ { tag: "With header", top: function() { return header.y + header.height }, index: 0 },
375+ { tag: "Without header", top: function() { return art.y + art.height }, index: 7 },
376+ ]
377+ }
378+
379+ function test_summary_layout(data) {
380+ selector.selectedIndex = data.index;
381+
382+ tryCompareFunction(function() { return testCase.summary.y === data.top() }, true);
383+ }
384+
368 function test_art_visibility() {
385 function test_art_visibility() {
369− selector.selectedIndex = 7
386+ selector.selectedIndex = 8;
370
387
371− tryCompare(testCase.artImage, "source", "")
388+ tryCompare(testCase.artImage, "source", "");
372− compare(testCase.art.visible, false)
389+ compare(testCase.art.visible, false);
373− compare(testCase.art.height, 0)
390+ compare(testCase.art.height, 0);
374− compare(testCase.art.width, 0)
391+ compare(testCase.art.width, 0);
375 }
392 }
376 }
393 }
377}
394}
tests/qmltests/Dash/tst_CardHeader.qml+3−3
@@ -120,9 +120,9 @@ Rectangle {
120
120
121 function test_dimensions_data() {
121 function test_dimensions_data() {
122 return [
122 return [
123− { tag: "Column width", object: column, width: cardHeader.width - testCase.outerRow.spacing * 2 },
123+ { tag: "Column width", object: column, width: cardHeader.width },
124− { tag: "Column width", object: column, width: cardHeader.width - mascot.width - testCase.outerRow.spacing * 3, mascot: "artwork/avatar.png" },
124+ { tag: "Column width with mascot", object: column, width: cardHeader.width - mascot.width - outerRow.margins * 3, mascot: "artwork/avatar.png" },
125− { tag: "Header height", object: cardHeader, height: function() { return subtitleLabel.y + subtitleLabel.height + outerRow.spacing * 2 } },
125+ { tag: "Header height", object: cardHeader, height: function() { return subtitleLabel.y + subtitleLabel.height + outerRow.margins * 2 } },
126 ]
126 ]
127 }
127 }
128
128