Notification
TsgcHTMLComponent_Notification — renderiza un centro de notificaciones desplegable con icono de campana y una insignia de no leídas, construido a partir de una colección de elementos de notificación, en Delphi, C++ Builder y .NET.
TsgcHTMLComponent_Notification — renderiza un centro de notificaciones desplegable con icono de campana y una insignia de no leídas, construido a partir de una colección de elementos de notificación, en Delphi, C++ Builder y .NET.
Un componente de centro de notificaciones que emite un desplegable de Bootstrap 5. Añade elementos a su colección Items (o llama a AddNotification), y luego lee la propiedad HTML — el contador de no leídas UnreadCount alimenta la insignia.
TsgcHTMLComponent_Notification
Marcado de desplegable de Bootstrap 5
Delphi, C++ Builder, .NET
Define Title y MaxVisible, llama a AddNotification(title, message, color, timestamp) por cada entrada, y luego lee HTML. El contador de no leídas rellena la insignia automáticamente.
uses
sgcHTML_Enums, sgcHTML_Component_Notification;
var
oNotif: TsgcHTMLComponent_Notification;
begin
oNotif := TsgcHTMLComponent_Notification.Create(nil);
try
oNotif.Title := 'Notifications';
oNotif.MaxVisible := 5;
oNotif.ShowBadge := True;
oNotif.AddNotification('New order',
'Order #1042 was placed.', hcSuccess, '2 min ago');
oNotif.AddNotification('Payment failed',
'Invoice #88 could not be charged.', hcDanger, '10 min ago');
WebModule.Response := oNotif.HTML; // bell dropdown + badge
finally
oNotif.Free;
end;
end;
// Or add items via the Items collection directly:
with oNotif.Items.Add do
begin
Title := 'Welcome';
Message := 'Your account is ready.';
Color := hcInfo;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Notification.hpp
TsgcHTMLComponent_Notification *oNotif = new TsgcHTMLComponent_Notification(NULL);
try
{
oNotif->Title = "Notifications";
oNotif->MaxVisible = 5;
oNotif->ShowBadge = true;
oNotif->AddNotification("New order",
"Order #1042 was placed.", hcSuccess, "2 min ago");
oNotif->AddNotification("Payment failed",
"Invoice #88 could not be charged.", hcDanger, "10 min ago");
String html = oNotif->HTML; // bell dropdown + badge
}
__finally
{
delete oNotif;
}
// Or add items via the Items collection directly:
TsgcHTMLNotificationItem *item = oNotif->Items->Add();
item->Title = "Welcome";
item->Message = "Your account is ready.";
item->Color = hcInfo;
using esegece.sgcWebSockets;
var notif = new TsgcHTMLComponent_Notification();
notif.Title = "Notifications";
notif.MaxVisible = 5;
notif.ShowBadge = true;
notif.AddNotification("New order",
"Order #1042 was placed.", TsgcHTMLColor.hcSuccess, "2 min ago");
notif.AddNotification("Payment failed",
"Invoice #88 could not be charged.", TsgcHTMLColor.hcDanger, "10 min ago");
string html = notif.HTML; // bell dropdown + badge
// Or add items via the Items collection directly:
var item = notif.Items.Add();
item.Title = "Welcome";
item.Message = "Your account is ready.";
item.Color = TsgcHTMLColor.hcInfo;
Los miembros que más vas a usar.
Items es una colección TsgcHTMLNotificationItems; cada TsgcHTMLNotificationItem tiene Title, Message, Timestamp, Color, Icon, Href y Read.
AddNotification(title, message, color, timestamp) añade un elemento y usa la hora actual como valor por defecto del timestamp cuando se omite.
UnreadCount cuenta los elementos cuyo Read es False; ShowBadge activa o desactiva la píldora roja y GetBadgeHTML devuelve solo el marcado de la insignia.
Title define el encabezado del desplegable, EmptyText el texto de relleno cuando no hay elementos y BellIcon el glifo del disparador.
MaxVisible limita cuántos elementos se renderizan (por defecto 5), con un enlace "View all" cuando hay más; NotificationID asigna el id del elemento.
HTML devuelve el desplegable completo con icono de campana junto con su CSS con ámbito — sírvelo, o asígnalo al BodyContent de una plantilla de página.