using Avalonia.Controls;
using Avalonia.Input;

using DodoSSH.Client.Shell.ViewModels;

namespace DodoSSH.Client.App.Views;

/// <summary>
/// What has been connected to, and what has been changed.
/// </summary>
/// <remarks>
/// Its data context is a <c>LogsViewModel</c>, a screen-scoped wrapper over the open session. Both logs are
/// ordinary synced keychain items; nothing about them is local.
/// </remarks>
internal sealed partial class LogsScreen : UserControl
{
    public LogsScreen() => InitializeComponent();

    /// <summary>Where the keyboard lands when this screen is the one showing.</summary>
    /// <remarks>
    /// Whichever list is on screen, because this screen has no filter box and a collapsed control cannot
    /// take focus — <c>Focus()</c> on one is a no-op that nothing replays when it is revealed. The lists are
    /// focusable explicitly for the same reason the host list is: Avalonia leaves focus to the items, and an
    /// empty list has none.
    /// </remarks>
    internal IInputElement KeyboardTarget =>
        DataContext is LogsViewModel { ShowsActivity: true } ? ActivityList : ConnectionList;
}
