on xenial help sign in
Review fixes.
commitc7c5a1fa665ba45af19b0f290aca69a8f2e92171 authorMichał Karnicki <michal.karnicki@canonical.com> dateThu 20 Feb 2014, 12:12 (13 years ago) parenta6c34be
2 files changed+24−19
qml/Dash/Card.qml+18 qml/Dash/CardHeader.qml+6−19
qml/Dash/Card.qml+18
@@ -28,6 +28,9 @@ Item {
2828 readonly property alias headerHeight: header.height
2929
3030 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)
3134
3235 implicitWidth: childrenRect.width
3336 implicitHeight: summary.y + summary.height + (summary.text && background.visible ? units.gu(1) : 0)
@@ -161,6 +164,8 @@ Item {
161164 subtitle: cardData && cardData["subtitle"] || ""
162165
163166 opacity: showHeader ? 1 : 0
167+ fontColor: root.fontColor
168+ useMascotShape: root.useMascotShape
164169
165170 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
166171 }
@@ -181,5 +186,18 @@ Item {
181186 text: cardData && cardData["summary"] || ""
182187 height: text ? implicitHeight : 0
183188 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"
184202 }
185203}
qml/Dash/CardHeader.qml+6−19
@@ -30,9 +30,8 @@ Item {
3030 property real fontScale: 1.0
3131
3232 property alias headerAlignment: titleLabel.horizontalAlignment
33− property bool inOverlay: template["overlay"] === true
34− property bool hasBackground: template && template["card-background"] !== undefined
35− property color fontColor: getFontColor(background.color)
33+ property bool useMascotShape: true
34+ property color fontColor: "grey"
3635
3736 visible: mascotImage.status === Image.Ready || title || price
3837 height: row.height > 0 ? row.height + row.margins * 2 : 0
@@ -43,7 +42,7 @@ Item {
4342
4443 property real margins: units.gu(1)
4544
46− spacing: mascotShape.visible || mascotImage.visible || inOverlay ? units.gu(0.5) : 0
45+ spacing: mascotShape.visible || mascotImage.visible || inOverlay ? margins : 0
4746 anchors {
4847 top: parent.top; left: parent.left; right: parent.right
4948 margins: margins
@@ -58,10 +57,10 @@ Item {
5857 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
5958 width: units.gu(6)
6059 height: units.gu(5.625)
61− visible: !hasBackground && image && image.status === Image.Ready
60+ visible: useMascotShape && image && image.status === Image.Ready
6261 readonly property int maxSize: Math.max(width, height)
6362
64− image: hasBackground ? null : mascotImage
63+ image: useMascotShape ? mascotImage : null
6564 }
6665
6766 Image {
@@ -69,7 +68,7 @@ Item {
6968
7069 width: source ? mascotShape.width : 0
7170 height: mascotShape.height
72− visible: hasBackground && status === Image.Ready
71+ visible: !useMascotShape && status === Image.Ready
7372
7473 sourceSize { width: mascotShape.maxSize; height: mascotShape.maxSize }
7574 fillMode: Image.PreserveAspectCrop
@@ -151,16 +150,4 @@ Item {
151150 }
152151 }
153152 }
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− }
166153}