Update NavigationController.cs

- Adding PopToRootAsync method
- small comment change
This commit is contained in:
FlorianDahn 2021-07-25 16:33:05 +02:00
parent 00440a50e8
commit 6f005114bc

View File

@ -22,7 +22,7 @@ namespace TelegramBotBase.Form.Navigation
public int Index { get; set; }
/// <summary>
/// Will replace the controller when poping a form with last last remaining form.
/// Will replace the controller when poping a form to the root form.
/// </summary>
[SaveState]
public bool ForceCleanupOnLastPop { get; set; }
@ -115,6 +115,21 @@ namespace TelegramBotBase.Form.Navigation
}
}
/// <summary>
/// Pop's through all forms back to the root form.
/// </summary>
/// <returns></returns>
public virtual async Task PopToRootAsync()
{
if (Index == 0)
return;
while (History.Count > 1)
{
await PopAsync();
}
}
/// <summary>
/// Pushing the given form to the stack and renders it.
/// </summary>