aboutsummaryrefslogtreecommitdiff
path: root/src/Toast.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/Toast.qml')
-rw-r--r--src/Toast.qml26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/Toast.qml b/src/Toast.qml
index 0de53a9..7a18dc8 100644
--- a/src/Toast.qml
+++ b/src/Toast.qml
@@ -27,6 +27,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.3
+import rwa.toast.type 1.0
/**
* adapted from StackOverflow:
@@ -50,8 +51,11 @@ Control {
*
* @param {string} text Text to show
* @param {real} duration Duration to show in milliseconds, defaults to 3000
+ * @param {enum} type Type of toast. Available is:
+ * ToastType.Standard, ToastType.Info, ToastType.Warning
+ * ToastType.Success, ToastType.Error
*/
- function show(text, duration) {
+ function show(text, duration, type) {
message.text = text;
// checks if parameter was passed
@@ -60,6 +64,23 @@ Control {
} else {
time = defaultTime;
}
+
+ if (typeof type !== "undefined" ) {
+ if (type === ToastType.ToastStandard) {
+ selectedColor = "#dcdedc";
+ } else if (type === ToastType.ToastInfo) {
+ selectedColor = "#0d5eaf";
+ } else if (type === ToastType.ToastSuccess) {
+ selectedColor = "#0daf36";
+ } else if (type === ToastType.ToastWarning) {
+ selectedColor = "#efef2a";
+ } else if (type === ToastType.ToastError) {
+ selectedColor = "#ed1212";
+ }
+ } else {
+ selectedColor = "#dcdedc";
+ }
+
animation.start();
}
@@ -72,6 +93,7 @@ Control {
id: root
+ property color selectedColor: "#dcdedc"
readonly property real defaultTime: 3000
property real time: defaultTime
readonly property real fadeTime: 300
@@ -88,6 +110,8 @@ Control {
background: Rectangle {
color: (Material.theme == Material.Dark) ? "#212121" : "#dcdedc"
+ border.color: selectedColor
+ border.width: 1.5
radius: margin
}