@@ -31,39 +31,44 @@ AbstractButton {
3131 property bool showHeader: true
3232
3333 implicitWidth: childrenRect.width
34− implicitHeight: summary.y + summary.height + (summary.text && background.visible ? units.gu(1) : 0)
34+ implicitHeight: summary.y + summary.height + (summary.text && backgroundLoader.active ? units.gu(1) : 0)
3535
36− UbuntuShape {
37− id: background
38− objectName: "background"
39− radius: "medium"
40− visible: template["card-layout"] !== "horizontal" && (template["card-background"] || components["background"]
41− || artAndSummary)
42− property bool artAndSummary: components["art"]["field"] && components["summary"] || false
43− color: getColor(0) || "white"
44− gradientColor: getColor(1) || color
45− anchors.fill: parent
46− image: backgroundImage.source ? backgroundImage : null
36+ Loader {
37+ id: backgroundLoader
38+ objectName: "backgroundLoader"
4739
48− property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b
40+ readonly property bool artAndSummary: components["art"]["field"] && components["summary"] || false
41+ active: template["card-layout"] !== "horizontal" && (template["card-background"] || components["background"] || artAndSummary)
42+ anchors.fill: parent
4943
50− property Image backgroundImage: Image {
51− objectName: "backgroundImage"
52− source: {
53− if (cardData && typeof cardData["background"] === "string") return cardData["background"]
54− else if (template && typeof template["card-background"] === "string") return template["card-background"]
55− else return ""
44+ sourceComponent: UbuntuShape {
45+ objectName: "background"
46+ radius: "medium"
47+ color: getColor(0) || "white"
48+ gradientColor: getColor(1) || color
49+ anchors.fill: parent
50+ image: backgroundImage.source ? backgroundImage : null
51+
52+ property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b
53+
54+ property Image backgroundImage: Image {
55+ objectName: "backgroundImage"
56+ source: {
57+ if (cardData && typeof cardData["background"] === "string") return cardData["background"]
58+ else if (template && typeof template["card-background"] === "string") return template["card-background"]
59+ else return ""
60+ }
5661 }
57− }
5862
59− function getColor(index) {
60− if (cardData && typeof cardData["background"] === "object"
61− && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
62− return cardData["background"]["elements"][index];
63− } else if (template && typeof template["card-background"] === "object"
64− && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
65− return template["card-background"]["elements"][index];
66− } else return undefined;
63+ function getColor(index) {
64+ if (cardData && typeof cardData["background"] === "object"
65+ && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
66+ return cardData["background"]["elements"][index];
67+ } else if (template && typeof template["card-background"] === "object"
68+ && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
69+ return template["card-background"]["elements"][index];
70+ } else return undefined;
71+ }
6772 }
6873 }
6974
@@ -187,7 +192,7 @@ AbstractButton {
187192 opacity: showHeader ? 1 : 0
188193 inOverlay: root.template && root.template["overlay"] === true
189194 fontColor: inOverlay ? "white" : summary.color
190− useMascotShape: !background.visible && !inOverlay
195+ useMascotShape: !backgroundLoader.active && !inOverlay
191196
192197 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
193198 }
@@ -199,7 +204,7 @@ AbstractButton {
199204 top: header.visible ? header.bottom : artShape.bottom
200205 left: parent.left
201206 right: parent.right
202− margins: background.visible ? units.gu(1) : 0
207+ margins: backgroundLoader.active ? units.gu(1) : 0
203208 topMargin: 0
204209 }
205210 wrapMode: Text.Wrap
@@ -209,6 +214,6 @@ AbstractButton {
209214 height: text ? implicitHeight : 0
210215 fontSize: "small"
211216 // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
212− color: background.visible && background.luminance < 0.7 ? "white" : "grey"
217+ color: backgroundLoader.active && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"
213218 }
214219}