feat(Toasts) Adding toasts

This commit is contained in:
2022-04-10 17:32:22 -04:00
parent 8c06fdd120
commit 4322be0053
29 changed files with 478 additions and 100 deletions
+12
View File
@@ -15,11 +15,23 @@ using Model.Notes;
using Model.Website;
using Model.Website.Enums;
using Model.Development.Git;
using Model.Feedback;
using Model.Work.Tasks;
using Services.Immortal;
namespace Services;
public interface IToastService
{
public void Subscribe(Action action);
public void Unsubscribe(Action action);
void AddToast(ToastModel toast);
void RemoveToast(ToastModel toast);
bool HasToasts();
List<ToastModel> GetToasts();
void ClearAllToasts();
}
public interface IEntityDialogService
{
+64
View File
@@ -0,0 +1,64 @@
using Model.Feedback;
namespace Services.Website;
public class ToastService : IToastService
{
private readonly List<ToastModel> toasts = new();
private event Action OnChange = null!;
#if DEBUG
public ToastService()
{
toasts.Add(new ToastModel(){Message = "Example message", SeverityType = SeverityType.Error, Title = "Example Error"});
toasts.Add(new ToastModel(){Message = "Example message", SeverityType = SeverityType.Information, Title = "Example Information"});
toasts.Add(new ToastModel(){Message = "Example message", SeverityType = SeverityType.Success, Title = "Example Success"});
toasts.Add(new ToastModel(){Message = "Example message", SeverityType = SeverityType.Warning, Title = "Example Warning"});
}
#endif
private void NotifyDataChanged() {
OnChange();
}
public void Subscribe(Action action) {
OnChange += action;
}
public void Unsubscribe(Action action) {
OnChange += action;
}
public void AddToast(ToastModel toast)
{
toasts.Add(toast);
NotifyDataChanged();
}
public void RemoveToast(ToastModel toast)
{
toasts.Remove(toast);
NotifyDataChanged();
}
public bool HasToasts()
{
return toasts.Count > 0;
}
public List<ToastModel> GetToasts()
{
return toasts;
}
public void ClearAllToasts()
{
toasts.Clear();
NotifyDataChanged();
}
}