<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.UpdateBanner"
             x:DataType="vm:UpdateViewModel">

  <!--
    The strip that says a newer build has been fetched, and asks when.

    ── WHERE IT LIVES, WHICH IS THE WHOLE DESIGN ──────────────────────────────────────────────────────────

    A row of MainWindow's root grid, between the content and the status bar. Not an overlay, and that is not
    a preference: NativeWebView hosts a real Win32 child window that composites above everything Avalonia
    paints in the same rectangle, so anything drawn over the terminal is sliced at its left edge with its
    buttons unreachable — a defect this window has shipped once. See the occlusion rule in MainWindow.axaml
    and docs/platform-flags.md.

    A sibling row is the arrangement that is already proven here twice over: TitleBar sits above the
    terminal and StatusBar below it, and both draw and take clicks correctly. Taking height from the row the
    WebView is in moves its bounds rather than covering it, which is what NativeControlHost re-pushes on
    layout.

    The cost, stated rather than discovered: the terminal gets 48 fewer pixels while this is up, so the grid
    reflows and the remote is told it has fewer rows. That is the same reflow any window resize causes and
    the renderer already handles it — and the alternative is the arrangement that does not work at all.

    ── WHY IT IS ITS OWN FILE ─────────────────────────────────────────────────────────────────────────────

    Nothing inside MainWindow can be laid out by a test — WebView2's adapter refuses the headless session's
    thread, see LayoutHarnessTests.WhyTheWindowItselfIsNeverShown — so markup left there is markup nobody can
    measure. This control has two buttons and a version string of unknown length in one fixed-height row,
    which is exactly the shape that arranges something off the right edge. UpdateBannerTests measures it.

    ── ONE LINE HIGH ──────────────────────────────────────────────────────────────────────────────────────

    Fixed height and trimmed rather than wrapped, for the reason StatusBar gives about itself and with more
    force: a message that grew this row would shrink the terminal further, and it would do it while somebody
    is reading it.
  -->

  <Border Height="48" Background="{StaticResource AccentWash}"
          BorderBrush="{StaticResource Border}" BorderThickness="0,1,0,0">

    <Grid ColumnDefinitions="Auto,*,Auto" Margin="14,0">

      <Border Grid.Column="0" Classes="chip" BorderBrush="{StaticResource Accent}">
        <TextBlock Classes="mono" Text="UPDATE" FontSize="10" FontWeight="SemiBold"
                   LetterSpacing="1" Foreground="{StaticResource Accent}" />
      </Border>

      <TextBlock Grid.Column="1" Margin="12,0,16,0" VerticalAlignment="Center"
                 FontSize="13" Foreground="{StaticResource Text}"
                 TextTrimming="CharacterEllipsis"
                 Text="{Binding ReadyHeadline}" />

      <StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">

        <!--
          LATER is honest, which is what makes it safe to offer at all. The dismissal lasts this run, the
          preferences row goes on offering the restart, and the build that has already been fetched is what
          starts next time regardless — so nothing is given up by pressing it, and the tooltip says so
          rather than leaving somebody to wonder whether they have just refused the update.
        -->
        <Button Classes="ghost" Content="LATER" Command="{Binding DismissBannerCommand}"
                ToolTip.Tip="Hides this until the next launch. The update is already downloaded and will be running the next time you start DodoSSH, so nothing is lost by waiting." />

        <!--
          The warning is on the tooltip rather than in the strip because it is a sentence and this is one
          line — and because its whole job is to be read before the button is pressed, not after. The long
          form is on the preferences screen, which scrolls.
        -->
        <Button x:Name="RestartNowButton" Classes="accent" Content="RESTART NOW"
                Command="{Binding RestartNowCommand}"
                ToolTip.Tip="{Binding RestartWarning}" />

      </StackPanel>

    </Grid>

  </Border>

</UserControl>
