on xenial help sign in
Hide private properites. Don't break sumamry when inOverlay.
f501f03Michał Karnicki
qml/Dash/Card.qml+14−16
@@ -28,9 +28,7 @@ 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
31+ readonly property bool inOverlay: template["overlay"] === true
32− property bool useMascotShape: !(template && template["card-background"] !== undefined)
33− property color fontColor: getFontColor(background.color)
34
32
35 implicitWidth: childrenRect.width
33 implicitWidth: childrenRect.width
36 implicitHeight: summary.y + summary.height + (summary.text && background.visible ? units.gu(1) : 0)
34 implicitHeight: summary.y + summary.height + (summary.text && background.visible ? units.gu(1) : 0)
@@ -142,6 +140,7 @@ Item {
142 CardHeader {
140 CardHeader {
143 id: header
141 id: header
144 objectName: "cardHeader"
142 objectName: "cardHeader"
143+
145 anchors {
144 anchors {
146 top: {
145 top: {
147 if (template) {
146 if (template) {
@@ -164,8 +163,8 @@ Item {
164 subtitle: cardData && cardData["subtitle"] || ""
163 subtitle: cardData && cardData["subtitle"] || ""
165
164
166 opacity: showHeader ? 1 : 0
165 opacity: showHeader ? 1 : 0
167− fontColor: root.fontColor
166+ fontColor: inOverlay ? "white" : summary.getFontColor(background.color)
168− useMascotShape: root.useMascotShape
167+ useMascotShape: background.visible
169
168
170 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
169 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
171 }
170 }
@@ -186,18 +185,17 @@ Item {
186 text: cardData && cardData["summary"] || ""
185 text: cardData && cardData["summary"] || ""
187 height: text ? implicitHeight : 0
186 height: text ? implicitHeight : 0
188 fontSize: "small"
187 fontSize: "small"
189− color: fontColor
188+ color: getFontColor(background.color)
190− }
191
189
192− function getLuminance(color) {
190+ function getLuminance(color) {
193− return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
191+ return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
194− }
192+ }
195
193
196− // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
194+ // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
197− function getFontColor(backgroundColor) {
195+ function getFontColor(backgroundColor) {
198− if (inOverlay) return "white";
199− if (backgroundColor === undefined) return "grey";
196+ if (backgroundColor === undefined) return "grey";
200− var luminance = getLuminance(backgroundColor);
197+ var luminance = getLuminance(backgroundColor);
201− return luminance < 0.7 ? "white" : "grey"
198+ return luminance < 0.7 ? "white" : "grey"
199+ }
202 }
200 }
203}
201}