import QtQuick 2.2 import Sailfish.Silica 1.0 // Self-hiding toast-like banner (Silica has no Toast; Notices is not // instantiable on Sailfish 5.1). Anchored to the bottom of the parent page. Item { id: banner property string text: "" property bool error: false anchors.horizontalCenter: parent.horizontalCenter // Anchored at the TOP: at the bottom the toast could be clipped by the // screen edge / pulley peek area. anchors.top: parent.top anchors.topMargin: Theme.paddingLarge width: parent.width - 2 * Theme.paddingLarge z: 20 visible: false function show(message, isError) { text = message error = isError !== false visible = true fadeIn.start() hideTimer.restart() } Rectangle { id: bannerRect anchors.horizontalCenter: parent.horizontalCenter width: parent.width height: bannerLabel.height + 2 * Theme.paddingSmall radius: Theme.paddingSmall color: banner.error ? "#8b2e2e" : "#1f3a5f" opacity: 0 Label { id: bannerLabel anchors.centerIn: parent width: parent.width - 2 * Theme.paddingMedium horizontalAlignment: Text.AlignHCenter color: "#ffffff" wrapMode: Text.Wrap text: banner.text } } NumberAnimation { id: fadeIn target: bannerRect property: "opacity" to: 0.95 duration: 200 } Timer { id: hideTimer interval: 3500 onTriggered: { banner.visible = false bannerRect.opacity = 0 } } }