download notification progress and download bar, chat only option for notifications (idk why you would bother even enabling the lightless nofis then)

This commit is contained in:
choco
2025-11-10 21:59:20 +01:00
parent 41a303dc91
commit 95e7f2daa7
4 changed files with 32 additions and 28 deletions

View File

@@ -90,7 +90,8 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
existing.ShowProgress = updated.ShowProgress;
existing.Title = updated.Title;
if (updated.Type == NotificationType.Download && updated.Progress < 1.0f)
// Reset the duration timer on every update for download notifications
if (updated.Type == NotificationType.Download)
{
existing.CreatedAt = DateTime.UtcNow;
}
@@ -344,6 +345,13 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
DrawBackground(drawList, windowPos, windowSize, bgColor);
DrawAccentBar(drawList, windowPos, windowSize, accentColor);
DrawDurationProgressBar(notification, alpha, windowPos, windowSize, drawList);
// Draw download progress bar above duration bar for download notifications
if (notification.Type == NotificationType.Download && notification.ShowProgress)
{
DrawDownloadProgressBar(notification, alpha, windowPos, windowSize, drawList);
}
DrawNotificationText(notification, alpha);
}
@@ -425,7 +433,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
private void DrawDurationProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList)
{
var progress = CalculateProgress(notification);
var progress = CalculateDurationProgress(notification);
var progressBarColor = UIColors.Get("LightlessBlue");
var progressHeight = 2f;
var progressY = windowPos.Y + windowSize.Y - progressHeight;
@@ -439,13 +447,26 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
}
}
private float CalculateProgress(LightlessNotification notification)
private void DrawDownloadProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList)
{
if (notification.Type == NotificationType.Download && notification.ShowProgress)
{
return Math.Clamp(notification.Progress, 0f, 1f);
}
var progress = Math.Clamp(notification.Progress, 0f, 1f);
var progressBarColor = UIColors.Get("LightlessGreen");
var progressHeight = 3f;
// Position above the duration bar (2px duration bar + 1px spacing)
var progressY = windowPos.Y + windowSize.Y - progressHeight - 3f;
var progressWidth = windowSize.X * progress;
DrawProgressBackground(drawList, windowPos, windowSize, progressY, progressHeight, progressBarColor, alpha);
if (progress > 0)
{
DrawProgressForeground(drawList, windowPos, progressY, progressHeight, progressWidth, progressBarColor, alpha);
}
}
private float CalculateDurationProgress(LightlessNotification notification)
{
// Calculate duration timer progress
var elapsed = DateTime.UtcNow - notification.CreatedAt;
return Math.Min(1.0f, (float)(elapsed.TotalSeconds / notification.Duration.TotalSeconds));
}