Toast: ensure all toasts have a title and a description for a more unified look.

This commit is contained in:
Lemmy
2026-01-01 10:26:06 -05:00
parent 7068275a58
commit 1fcf51eaf0
22 changed files with 169 additions and 149 deletions
+12 -6
View File
@@ -7,7 +7,7 @@ import qs.Widgets
Item {
id: root
property string message: ""
property string title: ""
property string description: ""
property string icon: ""
property string type: "notice"
@@ -146,7 +146,7 @@ Item {
NText {
Layout.fillWidth: true
text: root.message
text: root.title
color: Color.mOnSurface
pointSize: Style.fontSizeL
font.weight: Style.fontWeightBold
@@ -168,6 +168,12 @@ Item {
text: root.actionLabel
visible: root.actionLabel.length > 0 && root.actionCallback !== null
Layout.topMargin: Style.marginXS
fontSize: Style.fontSizeS
backgroundColor: Color.mPrimary
textColor: hovered ? Color.mOnHover : Color.mOnPrimary
hoverColor: Color.mHover
outlined: false
implicitHeight: 24
onClicked: {
if (root.actionCallback) {
root.actionCallback();
@@ -178,13 +184,13 @@ Item {
}
}
function show(msg, desc, msgIcon, msgType, msgDuration, msgActionLabel, msgActionCallback) {
function show(msgTitle, msgDescription, msgIcon, msgType, msgDuration, msgActionLabel, msgActionCallback) {
// Stop all timers first
hideTimer.stop();
hideAnimation.stop();
message = msg;
description = desc || "";
title = msgTitle;
description = msgDescription || "";
icon = msgIcon || "";
type = msgType || "notice";
duration = msgDuration || 3000;
@@ -192,7 +198,7 @@ Item {
actionCallback = msgActionCallback || null;
visible = true;
opacity = 1;
opacity = 1.0;
scale = 1.0;
hideTimer.restart();
+6 -6
View File
@@ -20,9 +20,9 @@ Item {
Connections {
target: ToastService
function onNotify(message, description, icon, type, duration, actionLabel, actionCallback) {
function onNotify(title, description, icon, type, duration, actionLabel, actionCallback) {
root.enqueueToast({
"message": message,
"title": title,
"description": description,
"icon": icon,
"type": type,
@@ -45,7 +45,7 @@ Item {
function enqueueToast(toastData) {
// Safe logging - fix the substring bug
var descPreview = (toastData.description || "").substring(0, 100).replace(/\n/g, " ");
Logger.d("ToastScreen", "Queuing", toastData.type, ":", toastData.message, descPreview);
Logger.d("ToastScreen", "Queuing", toastData.type, ":", toastData.title, descPreview);
// Bounded queue to prevent unbounded memory growth
if (messageQueue.length >= maxQueueSize) {
@@ -123,7 +123,7 @@ Item {
onStatusChanged: {
// When loader becomes ready, show the pending toast
if (status === Loader.Ready && pendingToast !== null) {
item.showToast(pendingToast.message, pendingToast.description, pendingToast.icon, pendingToast.type, pendingToast.duration, pendingToast.actionLabel, pendingToast.actionCallback);
item.showToast(pendingToast.title, pendingToast.description, pendingToast.icon, pendingToast.type, pendingToast.duration, pendingToast.actionLabel, pendingToast.actionCallback);
pendingToast = null;
}
}
@@ -217,8 +217,8 @@ Item {
}
}
function showToast(message, description, icon, type, duration, actionLabel, actionCallback) {
toastItem.show(message, description, icon, type, duration, actionLabel, actionCallback);
function showToast(title, description, icon, type, duration, actionLabel, actionCallback) {
toastItem.show(title, description, icon, type, duration, actionLabel, actionCallback);
}
function hideToast() {