on xenial help sign in
Review fixes.
c7c5a1fMichał Karnicki
qml/Dash/Card.qml+18
@@ -28,6 +28,9 @@ Item {
28 readonly property alias headerHeight: header.height
28 readonly property alias headerHeight: header.height
29
29
30 property bool showHeader: true
30 property bool showHeader: true
31+ property bool inOverlay: template["overlay"] === true
32+ property bool useMascotShape: !(template && template["card-background"] !== undefined)
33+ property color fontColor: getFontColor(background.color)
31
34
32 implicitWidth: childrenRect.width
35 implicitWidth: childrenRect.width
33 implicitHeight: summary.y + summary.height + (summary.text && background.visible ? units.gu(1) : 0)
36 implicitHeight: summary.y + summary.height + (summary.text && background.visible ? units.gu(1) : 0)
@@ -161,6 +164,8 @@ Item {
161 subtitle: cardData && cardData["subtitle"] || ""
164 subtitle: cardData && cardData["subtitle"] || ""
162
165
163 opacity: showHeader ? 1 : 0
166 opacity: showHeader ? 1 : 0
167+ fontColor: root.fontColor
168+ useMascotShape: root.useMascotShape
164
169
165 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
170 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
166 }
171 }
@@ -181,5 +186,18 @@ Item {
181 text: cardData && cardData["summary"] || ""
186 text: cardData && cardData["summary"] || ""
182 height: text ? implicitHeight : 0
187 height: text ? implicitHeight : 0
183 fontSize: "small"
188 fontSize: "small"
189+ color: fontColor
190+ }
191+
192+ function getLuminance(color) {
193+ return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
194+ }
195+
196+ // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
197+ function getFontColor(backgroundColor) {
198+ if (inOverlay) return "white";
199+ if (backgroundColor === undefined) return "grey";
200+ var luminance = getLuminance(backgroundColor);
201+ return luminance < 0.7 ? "white" : "grey"
184 }
202 }
185}
203}
qml/Dash/CardHeader.qml+6−19
@@ -30,9 +30,8 @@ Item {
30 property real fontScale: 1.0
30 property real fontScale: 1.0
31
31
32 property alias headerAlignment: titleLabel.horizontalAlignment
32 property alias headerAlignment: titleLabel.horizontalAlignment
33− property bool inOverlay: template["overlay"] === true
33+ property bool useMascotShape: true
34− property bool hasBackground: template && template["card-background"] !== undefined
34+ property color fontColor: "grey"
35− property color fontColor: getFontColor(background.color)
36
35
37 visible: mascotImage.status === Image.Ready || title || price
36 visible: mascotImage.status === Image.Ready || title || price
38 height: row.height > 0 ? row.height + row.margins * 2 : 0
37 height: row.height > 0 ? row.height + row.margins * 2 : 0
@@ -43,7 +42,7 @@ Item {
43
42
44 property real margins: units.gu(1)
43 property real margins: units.gu(1)
45
44
46− spacing: mascotShape.visible || mascotImage.visible || inOverlay ? units.gu(0.5) : 0
45+ spacing: mascotShape.visible || mascotImage.visible || inOverlay ? margins : 0
47 anchors {
46 anchors {
48 top: parent.top; left: parent.left; right: parent.right
47 top: parent.top; left: parent.left; right: parent.right
49 margins: margins
48 margins: margins
@@ -58,10 +57,10 @@ Item {
58 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
57 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
59 width: units.gu(6)
58 width: units.gu(6)
60 height: units.gu(5.625)
59 height: units.gu(5.625)
61− visible: !hasBackground && image && image.status === Image.Ready
60+ visible: useMascotShape && image && image.status === Image.Ready
62 readonly property int maxSize: Math.max(width, height)
61 readonly property int maxSize: Math.max(width, height)
63
62
64− image: hasBackground ? null : mascotImage
63+ image: useMascotShape ? mascotImage : null
65 }
64 }
66
65
67 Image {
66 Image {
@@ -69,7 +68,7 @@ Item {
69
68
70 width: source ? mascotShape.width : 0
69 width: source ? mascotShape.width : 0
71 height: mascotShape.height
70 height: mascotShape.height
72− visible: hasBackground && status === Image.Ready
71+ visible: !useMascotShape && status === Image.Ready
73
72
74 sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
73 sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
75 fillMode: Image.PreserveAspectCrop
74 fillMode: Image.PreserveAspectCrop
@@ -151,16 +150,4 @@ Item {
151 }
150 }
152 }
151 }
153 }
152 }
154−
155− function getLuminance(color) {
156− return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
157− }
158−
159− // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
160− function getFontColor(backgroundColor) {
161− if (inOverlay) return "white";
162− if (backgroundColor === undefined) return "grey";
163− var luminance = getLuminance(backgroundColor);
164− return luminance < 0.7 ? "white" : "grey"
165− }
166}
153}