Code/RouterPage.cs
using System;
namespace BetterUI;
/// <summary>
/// A page that is displayed by a Router.
/// </summary>
/// <remarks>
/// This is a panel that is displayed by a Router. It contains a few useful properties and methods
/// for managing the state of the page.
/// </remarks>
public abstract class RouterPage : Panel
{
/// <summary>
/// The router that owns this page.
/// </summary>
/// <remarks>
/// This is set by the router when the page is added to it.
/// </remarks>
[CascadingProperty] protected Router Router { get; set; } = null!;
/// <summary>
/// Gets a value indicating whether this page is open.
/// </summary>
public bool IsOpen { get; private set; }
/// <summary>
/// Shows the page.
/// </summary>
internal void Show()
{
IsOpen = true;
RemoveClass( "hidden" );
}
/// <summary>
/// Hides the page.
/// </summary>
internal void Hide()
{
IsOpen = false;
AddClass( "hidden" );
}
/// <inheritdoc />
protected override int BuildHash() => HashCode.Combine( Router );
}