<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.Android.Views.HostActionBar"
             x:DataType="vm:VaultViewModel">

  <!--
    ◆ THE CONTEXTUAL ACTION BAR, WHICH IS WHAT THE CONNECT CARD BECAME.

    A long press on a host used to raise a card over the bottom of the list: a password box, CONNECT, EDIT,
    MOVE and DELETE. It was a menu drawn as a form, in the one part of the screen a list grows into — so it
    covered rows, it had room for five things and never a sixth, and everything on it was about exactly one
    machine. What replaced it is a selection and this bar.

    It takes the vault header's place rather than sitting under it, which is the arrangement Android has used
    for this since contextual action bars existed and is the reason it can be unambiguous: while it is up, the
    screen is about the ticked hosts and about nothing else. See PhoneShell.ShowsHostSelectionBar, which is
    where the swap happens and why it is computed rather than bound.

    Left to right: the cross that leaves selection mode, the count, then the two controls. The pencil is out
    in front of the menu because editing is the thing people reach for most and is worth not opening a menu
    for; the other six are behind the ⋯, which is a sheet rather than a flyout — see
    VaultViewModel.IsHostActionSheetOpen.

    ── one host or several ──────────────────────────────────────────────────────────────────────────────────
    The pencil is drawn only while exactly one host is ticked, and it is collapsed rather than greyed. Three
    of the seven actions are like that — edit, connect, and browse — and the reason is the same for all
    three: a form, a terminal and a file session are each about one machine, and there is no sensible reading
    of "edit these six". The three that stay are the ones a count makes better rather than worse.
  -->

  <!-- DeepChrome rather than Chrome, since v5: this bar takes the vault header's own place, so it takes
       the vault header's own surface too — see the remark on that header in PhoneShell.axaml. -->
  <Border Background="{StaticResource DeepChrome}" BorderBrush="{StaticResource Border}"
          BorderThickness="0,0,0,1" Padding="6,0" Height="56">
    <Grid ColumnDefinitions="Auto,*,Auto,Auto">

      <!--
        The cross, and it is the first thing on the bar for the reason back arrows are: the way out of a
        mode belongs at the edge the thumb reaches without crossing anything it might press by mistake.
      -->
      <Button Grid.Column="0" Classes="icon" Content="✕"
              Command="{Binding ClearHostChoiceCommand}"
              ToolTip.Tip="Stop choosing hosts" />

      <!--
        The count, and only the count. The bar it sits in is already saying what the number is about, and
        "6 hosts selected" beside a pencil and a menu is the width those two icons need at 360dp.
      -->
      <TextBlock Grid.Column="1" Classes="heading" FontSize="17" Margin="8,0"
                 VerticalAlignment="Center" Text="{Binding ChosenHostsLabel}" />

      <Button Grid.Column="2" Classes="icon" Content="✎" FontSize="15"
              IsVisible="{Binding HasOneChosenHost}"
              Command="{Binding EditChosenHostCommand}"
              ToolTip.Tip="Edit this host" />

      <Button Grid.Column="3" Classes="icon" Content="⋯" FontSize="18"
              Command="{Binding OpenHostActionSheetCommand}"
              ToolTip.Tip="More things to do with these hosts" />

    </Grid>
  </Border>

</UserControl>
