<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.ServerScreen"
             x:DataType="vm:MainWindowViewModel"
             Background="{StaticResource Canvas}">

  <!--
    Not in the design, which starts at an enrolled phone — but it is ShellState.NeedsServer and the only
    state that requires a network, so a head without it cannot be used on a phone that has never signed in.

    One field and one button. Everything about the identity provider comes from the server's own
    /.well-known/dodossh-configuration, so there is no authority, client id or scope to type — which is the
    whole reason this screen is one box on a phone rather than a form.
  -->

  <ScrollViewer>
    <StackPanel Margin="24,0" VerticalAlignment="Center" Spacing="0">

      <StackPanel Spacing="10" HorizontalAlignment="Center" Margin="0,48,0,36">
        <!--
          Filled rather than outlined since v2, the same mark the header, the desktop titlebar and the
          launcher icon carry. The radius is not picked: the mark runs 6 at 20 and 8 at 26, which is a
          third of a unit per unit of tile and lands on 14 at 44 — and 14 is a rung of Phone.axaml's
          ladder, the one for a block of monospaced output, which is what this is.
        -->
        <Border Width="44" Height="44" CornerRadius="14" Background="{StaticResource Accent}"
                HorizontalAlignment="Center">
          <TextBlock Text="&gt;_" Foreground="{StaticResource AccentInk}" FontFamily="{StaticResource MonoFont}"
                     FontSize="16" FontWeight="Bold"
                     HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Border>
        <TextBlock Classes="title" Text="DodoSSH" HorizontalAlignment="Center" />
      </StackPanel>

      <TextBlock Classes="label" Text="SERVER" />

      <TextBox Classes="field" Margin="0,6,0,0" Text="{Binding ServerUrl}"
               PlaceholderText="https://dodossh.example.com"
               IsEnabled="{Binding !IsBusy}">
        <TextBox.KeyBindings>
          <KeyBinding Gesture="Enter" Command="{Binding SignInCommand}" />
        </TextBox.KeyBindings>
      </TextBox>

      <Button Classes="primary" Content="SIGN IN" Margin="0,10,0,0"
              Command="{Binding SignInCommand}" IsEnabled="{Binding !IsBusy}" />

      <!--
        Said before the browser opens rather than after. RFC 8252 §8.12 requires the system browser and not
        an embedded one, which means the user is about to be handed to another application — and an SSH
        client that bounces you out to Chrome with no warning looks like it has crashed.
      -->
      <TextBlock Classes="detail" Margin="0,14,0,0" TextWrapping="Wrap" TextAlignment="Center"
                 Text="opens your browser to sign in · DodoSSH never sees your password" />

      <TextBlock Classes="body" Margin="0,16,0,0" TextAlignment="Center" Text="{Binding StatusMessage}" />

    </StackPanel>
  </ScrollViewer>

</UserControl>
