using Titano.Ui.Controls;
using Titano.Ui.Mvvm;
namespace Titano.App.Shell;
public enum SectionKey
{
Library,
Import,
/// One sequence analysed, edited and rendered step by step (owner review 1, R7; formerly Sequence).
Edit,
Archive,
Jobs,
Server,
Settings,
About,
}
/// A top-level destination of the navigation rail.
public abstract class SectionViewModel(SectionKey key, string iconKey) : LocalizedViewModel
{
private bool _isSelected;
private int _badge;
private bool _inCollapsedRail;
public SectionKey Key { get; } = key;
/// Resource key of the rail icon (e.g. "Icon.Library").
public string IconKey { get; } = iconKey;
public IconData? Glyph => System.Windows.Application.Current?.TryFindResource(IconKey) as IconData;
/// Rail label ("Library").
public string Label => Core.Localization.Loc.L("Shell.Nav." + Key);
/// Rail tooltip: what the section is for.
public string ToolTip => Core.Localization.Loc.L("Tooltips.Nav." + Key);
///
/// The rail button's tooltip: , after the section's name while the rail shows icons alone (owner
/// review 1).
///
public string RailToolTip => _inCollapsedRail ? Core.Localization.Loc.L("Tooltips.Nav.Collapsed", Label, ToolTip) : ToolTip;
/// The rail shows icons alone ().
internal bool InCollapsedRail
{
get => _inCollapsedRail;
set
{
if (Set(ref _inCollapsedRail, value)) OnPropertyChanged(nameof(RailToolTip));
}
}
/// Window title suffix ("Titano — Import").
public virtual string Title => Label;
public bool IsSelected
{
get => _isSelected;
set
{
if (Set(ref _isSelected, value) && value) OnActivated();
}
}
/// Count of items needing attention, shown as a rail badge.
public int Badge
{
get => _badge;
protected set => Set(ref _badge, value);
}
protected virtual void OnActivated()
{
}
}