<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:DodoSSH.Client.Shell.ViewModels"
             x:Class="DodoSSH.Client.App.Views.NavRail"
             x:DataType="vm:MainWindowViewModel">

  <!--
    The window's destinations, down the left edge.

    Still called NavRail although v2 makes it 190 pixels wide and gives every entry a word: the type is
    named in MainWindow and in the layout suite, and "the list of places this window goes" is what it was
    called when it was 54 pixels and is what it still is. The width is the thing that changed, not the job.

    ── v2 ────────────────────────────────────────────────────────────────────────────────────────────────
    Three things the extra 136 pixels buy, and they are why the design widened it rather than a matter of
    taste. The five-character abbreviations are gone — PINS and SNIPS were a width constraint and are now
    Pins and Snippets. Each entry carries a glyph, so the list can be scanned by shape as well as read. And
    each carries a count, which is the one genuinely new fact: how many hosts, how many keys, how many pins
    is a question you would otherwise have to open the screen to answer.

    A count is drawn only where one is real. Logs and Preferences have none — a log has no total until it is
    read, and preferences are not counted — so those two show nothing rather than a zero. The design draws a
    number on every row; a zero beside Logs would be a fact this application never computed.

    ── SFTP AND S3 ARE NOT HERE, and that is the tab strip's doing. ──────────────────────────────────────
    Both were rail entries until the strip grew fixed tabs for them. They are the two destinations that are
    not about the keychain — they are a place you leave the keychain to work in, and you stay there while a
    transfer runs — which is exactly what a tab is for and what a rail entry is not. The rail is drawn only
    under the Vaults tab now, so an entry here for either of them would be a route out of the tab it lives
    in. See MainWindowViewModel.IsVaultsTab.

    What this costs is that the S3 count has nowhere to go: the strip's tabs are one word each, and the rail
    was where "how many buckets" was printed. It is on the S3 screen itself, which is where somebody
    counting buckets is going anyway.

    One of the destinations — TEAM — reaches a screen that says it is not built. It is in the list anyway
    rather than dropped, and the reasoning is in ShellScreen: the milestones are public, the screen behind it
    says plainly what is missing, and a list that quietly had fewer entries would make sharing look like a
    change of product rather than the next milestone. FILES was the other one until M2 built it.

    Buttons rather than a TabStrip or a ListBox, for the same reason the vault's category rail is: all three
    of those hold the selection themselves, so a click moves the highlight before the shell can decide
    anything. Buttons carry no state and cannot disagree with the screen that is showing.

    Lit from IsXShowing and not from IsXScreen, which are different questions now that the tab strip spans
    every screen. A terminal opened from here leaves Screen on Hosts — deliberately, so closing the tab comes
    back — and an entry lit while a terminal filled the window would be pointing at a screen that is not
    showing. So nothing here is lit at all while a terminal is up: the selected tab already carries that
    mark, in the strip, and two "you are here" marks is one too many.

    The design pins a "Team vault" card to the foot of this list, beside a Team entry in the list itself.
    Two routes to one screen, one of them carrying a seat count nothing here can produce, so what sits at
    the foot is Preferences — which is where it already was, and which is the one entry that is about the
    machine rather than about the keychain.
  -->

  <Border Width="190" Background="{StaticResource Sidebar}"
          BorderBrush="{StaticResource Border}" BorderThickness="0,0,1,0">
    <DockPanel LastChildFill="False">

      <StackPanel DockPanel.Dock="Top" Margin="8,10,8,0" Spacing="2">

        <Button Classes="flat nav" Classes.active="{Binding IsHostsShowing}"
                Command="{Binding ShowScreenCommand}"
                CommandParameter="{x:Static vm:ShellScreen.Hosts}"
                ToolTip.Tip="Your hosts, and what is known about the one you have selected">
          <Grid ColumnDefinitions="Auto,*,Auto">
            <TextBlock Grid.Column="0" Classes="navicon" Text="▤" />
            <TextBlock Grid.Column="1" Classes="navlabel" Text="Hosts" />
            <TextBlock Grid.Column="2" Classes="navcount" Text="{Binding Vault.Hosts.Count}" />
          </Grid>
        </Button>

        <!--
          TotalItemCount is keys plus passwords and deliberately excludes buckets, which used to disagree
          with the list under it. It no longer does: buckets have their own entry above, so this number and
          this screen now count the same things.
        -->
        <Button Classes="flat nav" Classes.active="{Binding IsVaultShowing}"
                Command="{Binding ShowScreenCommand}"
                CommandParameter="{x:Static vm:ShellScreen.Vault}"
                ToolTip.Tip="Your keychain: SSH keys and stored passwords">
          <Grid ColumnDefinitions="Auto,*,Auto">
            <TextBlock Grid.Column="0" Classes="navicon" Text="⚿" />
            <TextBlock Grid.Column="1" Classes="navlabel" Text="Keychain" />
            <TextBlock Grid.Column="2" Classes="navcount" Text="{Binding Vault.TotalItemCount}" />
          </Grid>
        </Button>

        <Button Classes="flat nav" Classes.active="{Binding IsKnownHostsShowing}"
                Command="{Binding ShowScreenCommand}"
                CommandParameter="{x:Static vm:ShellScreen.KnownHosts}"
                ToolTip.Tip="Host keys you have approved, and how to withdraw one">
          <Grid ColumnDefinitions="Auto,*,Auto">
            <TextBlock Grid.Column="0" Classes="navicon" Text="◈" />
            <TextBlock Grid.Column="1" Classes="navlabel" Text="Pins" />
            <!--
              The vault's pins, not the screen's VisiblePins — that one is the filtered list, so a sidebar
              bound to it would count what the Pins screen's own filter box happens to match and would
              change as somebody typed in it. Every other count here is a total; this one has to be too.
            -->
            <TextBlock Grid.Column="2" Classes="navcount"
                       Text="{Binding Vault.KnownHostPins.Count}" />
          </Grid>
        </Button>

        <Button Classes="flat nav" Classes.active="{Binding IsSnippetsShowing}"
                Command="{Binding ShowScreenCommand}"
                CommandParameter="{x:Static vm:ShellScreen.Snippets}"
                ToolTip.Tip="Commands you have saved, and how to put one into a terminal">
          <Grid ColumnDefinitions="Auto,*,Auto">
            <TextBlock Grid.Column="0" Classes="navicon" Text="❯" />
            <TextBlock Grid.Column="1" Classes="navlabel" Text="Snippets" />
            <TextBlock Grid.Column="2" Classes="navcount" Text="{Binding Vault.Snippets.Count}" />
          </Grid>
        </Button>

        <Button Classes="flat nav" Classes.active="{Binding IsLogsShowing}"
                Command="{Binding ShowScreenCommand}"
                CommandParameter="{x:Static vm:ShellScreen.Logs}"
                ToolTip.Tip="What has been connected to, and what has been changed in this keychain">
          <Grid ColumnDefinitions="Auto,*,Auto">
            <TextBlock Grid.Column="0" Classes="navicon" Text="≡" />
            <TextBlock Grid.Column="1" Classes="navlabel" Text="Logs" />
          </Grid>
        </Button>

        <Button Classes="flat nav" Classes.active="{Binding IsTeamShowing}"
                Command="{Binding ShowScreenCommand}"
                CommandParameter="{x:Static vm:ShellScreen.Team}"
                ToolTip.Tip="Shared keychains and the people in them">
          <Grid ColumnDefinitions="Auto,*,Auto">
            <TextBlock Grid.Column="0" Classes="navicon" Text="◎" />
            <!--
              No count. Teams are read from the server when the screen is opened, not on unlock, so this
              would read 0 until somebody had already been there — which is the one number on this list
              that would be a statement rather than a blank.
            -->
            <TextBlock Grid.Column="1" Classes="navlabel" Text="Teams" />
          </Grid>
        </Button>

      </StackPanel>

      <Button DockPanel.Dock="Bottom" Classes="flat nav" Margin="8,0,8,10"
              Classes.active="{Binding IsPreferencesShowing}"
              Command="{Binding ShowScreenCommand}"
              CommandParameter="{x:Static vm:ShellScreen.Preferences}"
              ToolTip.Tip="Preferences, and this machine's device key">
        <Grid ColumnDefinitions="Auto,*,Auto">
          <TextBlock Grid.Column="0" Classes="navicon" Text="⚙" />
          <TextBlock Grid.Column="1" Classes="navlabel" Text="Preferences" />
        </Grid>
      </Button>

    </DockPanel>
  </Border>

</UserControl>
