using Avalonia.Controls;
using Avalonia.Input;

namespace DodoSSH.Client.App.Views;

/// <summary>
/// The hosts screen: the host list, and an overview of the one that is selected.
/// </summary>
/// <remarks>
/// Its data context is the shell rather than the vault, unlike <see cref="HostSidebar"/> and
/// <see cref="VaultScreen"/>. The sidebar is handed the vault from inside the markup; everything else here
/// reaches it through <c>Vault.*</c>. That split is not tidiness — this element's visibility is the shell's
/// business and the sidebar's bindings are the vault's, and an element carrying both resolves the first
/// against the second, where it does not exist.
/// </remarks>
internal sealed partial class HostsScreen : UserControl
{
    public HostsScreen() => InitializeComponent();

    /// <summary>Where the keyboard lands when this screen is the one showing.</summary>
    /// <remarks>
    /// Forwarded to the sidebar, which answers for itself: the host list can be folded away, and
    /// <c>Focus()</c> on a collapsed control is measurably a no-op that is not replayed when the control is
    /// revealed. Nothing in the right column can take the keyboard — it is a heading and three sentences.
    /// </remarks>
    internal IInputElement KeyboardTarget => Sidebar.KeyboardTarget;
}
