commits
tags
import QtQuick
import TvLauncher
Rectangle {
id: toast
property bool isError: true
function show(msg, error) {
isError = error !== false
label.text = msg
opacity = 1
hideTimer.restart()
}
anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: Theme.dp(90) }
width: Math.min(label.implicitWidth + Theme.dp(60), parent.width - Theme.dp(160))
height: label.implicitHeight + Theme.dp(30)
radius: Theme.r(12)
color: Theme.alpha(Theme.surface, 0.92)
border.color: isError ? Theme.danger : Theme.accent
border.width: Theme.dp(2)
opacity: 0
visible: opacity > 0
z: 1000
Behavior on opacity { NumberAnimation { duration: 250 } }
Text {
id: label
anchors.centerIn: parent
width: parent.width - Theme.dp(60)
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
color: Theme.text
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(24)
}
Timer { id: hideTimer; interval: 5000; onTriggered: toast.opacity = 0 }
}