feat(Immortal) Added a back button
This commit is contained in:
@@ -26,10 +26,13 @@ public interface IEntityDialogService
|
||||
|
||||
public void AddDialog(string entityId);
|
||||
public void CloseDialog();
|
||||
|
||||
public void BackDialog();
|
||||
|
||||
public string? GetEntityId();
|
||||
|
||||
public bool HasDialog();
|
||||
public bool HasHistory();
|
||||
}
|
||||
|
||||
public interface IWebsiteService {
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
namespace Services.Website;
|
||||
|
||||
//TODO Move to a database folder, with EntityService, EntityFilterService
|
||||
public class EntityDialogService : IEntityDialogService
|
||||
{
|
||||
private string? entityId = null;
|
||||
|
||||
private List<string> history = new List<string>();
|
||||
|
||||
private event Action _onChange;
|
||||
|
||||
@@ -23,6 +26,7 @@ public class EntityDialogService : IEntityDialogService
|
||||
public void AddDialog(string id)
|
||||
{
|
||||
entityId = id;
|
||||
history.Add(id);
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
@@ -30,9 +34,29 @@ public class EntityDialogService : IEntityDialogService
|
||||
public void CloseDialog()
|
||||
{
|
||||
entityId = null;
|
||||
history.Clear();
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
public void BackDialog()
|
||||
{
|
||||
if (history.Count > 1)
|
||||
{
|
||||
history.RemoveAt(history.Count - 1);
|
||||
|
||||
if (history.Count == 0)
|
||||
{
|
||||
entityId = null;
|
||||
NotifyDataChanged();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
entityId = history.Last();
|
||||
NotifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool HasDialog()
|
||||
@@ -40,6 +64,11 @@ public class EntityDialogService : IEntityDialogService
|
||||
return entityId != null;
|
||||
}
|
||||
|
||||
public bool HasHistory()
|
||||
{
|
||||
return history.Count > 1;
|
||||
}
|
||||
|
||||
public string? GetEntityId()
|
||||
{
|
||||
return entityId;
|
||||
|
||||
Reference in New Issue
Block a user