Notification
TsgcHTMLComponent_Notification — renderizza un centro notifiche a discesa con icona campanello e badge dei non letti, costruito da una collezione di elementi di notifica, in Delphi, C++ Builder e .NET.
TsgcHTMLComponent_Notification — renderizza un centro notifiche a discesa con icona campanello e badge dei non letti, costruito da una collezione di elementi di notifica, in Delphi, C++ Builder e .NET.
Un componente centro notifiche che emette un dropdown Bootstrap 5. Aggiungi gli elementi alla sua collezione Items (oppure chiama AddNotification), quindi leggi la proprietà HTML — il valore UnreadCount dei non letti determina il badge.
TsgcHTMLComponent_Notification
Bootstrap 5 dropdown markup
Delphi, C++ Builder, .NET
Imposta Title e MaxVisible, chiama AddNotification(title, message, color, timestamp) per ogni voce, quindi leggi HTML. Il conteggio dei non letti popola il badge automaticamente.
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;
I membri che utilizzerai più spesso.
Items è una collezione TsgcHTMLNotificationItems; ogni TsgcHTMLNotificationItem ha Title, Message, Timestamp, Color, Icon, Href e Read.
AddNotification(title, message, color, timestamp) aggiunge un elemento e imposta il timestamp all’ora corrente quando omesso.
UnreadCount conta gli elementi il cui Read è False; ShowBadge attiva/disattiva la pillola rossa e GetBadgeHTML restituisce solo il markup del badge.
Title imposta l’intestazione del dropdown, EmptyText il testo segnaposto quando non ci sono elementi e BellIcon il glifo dell’attivatore.
MaxVisible limita quanti elementi vengono renderizzati (predefinito 5), con un link "Vedi tutto" quando ne esistono altri; NotificationID assegna l’id dell’elemento.
HTML restituisce il dropdown completo con icona campanello e il suo CSS dedicato — servilo, oppure assegnalo al BodyContent di un template di pagina.