<controls:PageBase
    x:Class="JumpPoint.Uwp.Hosted.HashToolPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:JumpPoint.Uwp.Hosted"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:JumpPoint.Uwp.Controls"
    xmlns:nguwp="using:NittyGritty.Uwp"
    xmlns:winui="using:Microsoft.UI.Xaml.Controls"
    xmlns:hosted="using:JumpPoint.ViewModels.Hosted"
    mc:Ignorable="d"
    winui:BackdropMaterial.ApplyToRootOrPageBackground="True"
    d:DesignWidth="500"
    d:DesignHeight="500">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <TextBlock FontSize="16"
                   Text="HASH TOOL"
                   FontWeight="SemiBold"
                   Margin="20,12,20,4"/>
        <Border Grid.Row="1"
                HorizontalAlignment="Left"
                CornerRadius="8"
                Padding="12,4"
                Margin="20,0"
                Background="{ThemeResource BorderPlateBackground}">
            <TextBlock Text="{x:Bind ViewModel.HashFunction, Converter={StaticResource HumanizerConverter}, Mode=OneWay}"
                       FontWeight="SemiBold" />
        </Border>
        <winui:ProgressRing Grid.RowSpan="2"
                            HorizontalAlignment="Right"
                            Margin="20,0"
                            IsActive="{x:Bind ViewModel.IsLoading, Mode=OneWay}"
                            Visibility="{x:Bind ViewModel.IsLoading, Mode=OneWay}"/>
        <ScrollViewer Grid.Row="2"
                      Margin="0,8,0,0"
                      Padding="20,0">
            <winui:ItemsRepeater ItemsSource="{x:Bind ViewModel.HashItems, Mode=OneWay}"
                                 Margin="0,0,0,120">
                <winui:ItemsRepeater.Layout>
                    <winui:StackLayout Orientation="Vertical"
                                       Spacing="4"/>
                </winui:ItemsRepeater.Layout>
                <DataTemplate x:DataType="hosted:HashItem">
                    <StackPanel Padding="0,12">
                        <TextBlock Text="Path:"
                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
                                   Margin="0,0,0,4"/>
                        <TextBlock Text="{x:Bind Payload.Path, Mode=OneWay}"
                                   TextWrapping="WrapWholeWords" />

                        <TextBlock Text="Hash:"
                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
                                   Margin="0,12,0,4"/>
                        <TextBox IsReadOnly="True"
                                 Visibility="{x:Bind Hash, Converter={StaticResource StringVisibilityConverter}, Mode=OneWay}"
                                 Text="{x:Bind Hash, Mode=OneWay}"
                                 Margin="0,0,0,4"/>
                        <Button Content="Copy"
                                Visibility="{x:Bind Hash, Converter={StaticResource StringVisibilityConverter}, Mode=OneWay}"
                                DataContext="{x:Bind Hash, Mode=OneWay}"
                                Click="OnCopy"/>
                        <winui:ProgressBar IsIndeterminate="{x:Bind Progress, Converter={StaticResource IsNullConverter}, Mode=OneWay}"
                                           Visibility="{x:Bind Progress, Converter={StaticResource CollapsedWhenZeroConverter}, Mode=OneWay}"
                                           Maximum="1"
                                           Minimum="0"
                                           Value="{x:Bind Progress, Converter={StaticResource ZeroWhenNullConverter}, Mode=OneWay}" />
                    </StackPanel>
                </DataTemplate>
            </winui:ItemsRepeater>
        </ScrollViewer>
    </Grid>
</controls:PageBase>
