﻿<common:PageBase
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FeedbackApp.UIF.Views"
    xmlns:common="using:FeedbackApp.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:conv="using:FeedbackApp.Converters"
    x:Class="FeedbackApp.UIF.Views.PlusOneCandidatesPage"
    x:Name="pageRoot"
    mc:Ignorable="d"
    xmlns:sampleData="using:FeedbackApp.UIF.SampleData"
    d:DataContext="{d:DesignInstance 
        Type=sampleData:MockPlusOneCandidatesVM, 
        IsDesignTimeCreatable=True}">

    <common:PageBase.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="UIFStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <DataTemplate x:Key="IssuesItemTemplate">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="45"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding CountInstances}" HorizontalAlignment="Right" VerticalAlignment="Top" Padding="0,3,0,3"/>
                    <TextBlock Text="{Binding Text, Converter={StaticResource TextLineReduceConverter}}" Margin="35,0,0,0" Grid.Column="1" 
                               TextWrapping="Wrap" TextTrimming="WordEllipsis" VerticalAlignment="Top" Padding="0,3,0,3"/>
                </Grid>
            </DataTemplate>

            <conv:LoadingStateToBooleanConverter x:Key="LoadingStateToBooleanConverter"/>
            <conv:LoadingStateToVisibilityConverter x:Key="LoadingStateToVisibilityConverter"/>
            <conv:TextLineReduceConverter x:Key="TextLineReduceConverter"/>
        </ResourceDictionary>
    </common:PageBase.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid Margin="120,0">
            <!--Header-->
            <!--Main Content-->
            <Grid x:Name="ContentRoot" Margin="0,20,40,5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="130"/>
                </Grid.RowDefinitions>
                <Grid VerticalAlignment="Bottom" Height="40" Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" MaxWidth="{StaticResource UIFContentMaxWidth}"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBox Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                		x:Uid="/FeedbackApp.Resources/UIF_PlusOneCandidatesPage_Search"
                		TextWrapping="Wrap"
                		VerticalAlignment="Stretch" PlaceholderText="Tell us what happened"/>
                </Grid>
                <!--Error Status-->
                <Grid Style="{StaticResource ErrorBox}" Grid.Row="1"
                            Visibility="{Binding PageState, ConverterParameter=Error, Converter={StaticResource LoadingStateToVisibilityConverter}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="100"/>
                    </Grid.ColumnDefinitions>
                        <TextBlock Style="{StaticResource ErrorLabel}"
                               x:Uid="/FeedbackApp.Resources/UIF_Shared_ConnectionError"
                               Text="Error Message"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"/>
                        <Button Command="{Binding ReInitializeCommand}" Grid.Column="1" HorizontalAlignment="Left"
                				x:Uid="/FeedbackApp.Resources/UIF_Shared_Reload" VerticalAlignment="Center"
                            Margin="5,3,10,3" FontSize="13"/>
                </Grid>
                <TextBlock Text="[Placeholder] Breadcrumb" Grid.Row="2"/>
                <Grid Grid.Row="2" HorizontalAlignment="Left">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Style="{StaticResource BaseTextBlockStyle}"
                           x:Uid="/FeedbackApp.Resources/UIF_PlusOneCandidatesPage_SortResultLabel"
                           Grid.Column="0"
                           Text="Sort results by"
                           HorizontalAlignment="Left"
                           Margin="0,15,0,0"/>
                    <ComboBox ItemsSource="{Binding SortCategoryItems}" x:Name="SortResultsCombo" Grid.Column="0" Width="150"
                          HorizontalAlignment="Left" Margin="120, 15, 0, 0"
                          SelectedValue="{Binding SortCategorySelectedValue, Mode=TwoWay}"/>
                    <TextBlock Style="{StaticResource BaseTextBlockStyle}"
                           x:Uid="/FeedbackApp.Resources/UIF_PlusOneCandidatesPage_FilterResultLabel" 
                           Grid.Column="1"
                           Text="Filter results by"
                           HorizontalAlignment="Left"
                           Margin="15,15,0,0"/>
                    <ComboBox ItemsSource="{Binding FilterCategoryItems}" x:Name="FilterResultsCombo" Grid.Column="1" Width="150"
                          HorizontalAlignment="Left" Margin="140, 15, 0, 0"
                          SelectedValue="{Binding FilterCategorySelectedValue, Mode=TwoWay}"/>
                </Grid>
                
                <!--Headers for Search Result Table-->
                <Grid Grid.Row="4" Margin="0, 10, 0, 0" HorizontalAlignment="Left">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="45"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Style="{StaticResource PageLabel}" x:Uid="/FeedbackApp.Resources/UIF_PlusOneCandidatesPage_MeTooLabel" Text="Me too"  HorizontalAlignment="Right" Margin="0,0,-2,0" VerticalAlignment="Top"/>
                    <TextBlock Style="{StaticResource PageLabel}" x:Uid="/FeedbackApp.Resources/UIF_PlusOneCandidatesPage_FeedbackDescriptionLabel" Text="Feedback Description" MaxHeight="100" Margin="39,0,0,0" Grid.Column="1" 
                                VerticalAlignment="Top" />
                </Grid>                
                <ListView ItemsSource="{Binding FeedbackItems}"
                          common:SelectionBehavior.Command="{Binding FeedbackSelectedCommand}"
                          IsItemClickEnabled="True"
                          IsRightTapEnabled="False"
                          ItemTemplate="{StaticResource IssuesItemTemplate}"
                          Margin="0,16,0,20"
                          Grid.Row="5"
                          SelectionMode="Single"/>
                <StackPanel Grid.Row="5" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <!--Progress-->
                    <ProgressRing HorizontalAlignment="Left"
                		VerticalAlignment="Center" 
                		Margin="10,5" 
                		Visibility="{Binding PageState, ConverterParameter=Loading, Converter={StaticResource LoadingStateToVisibilityConverter}}"
                		IsActive="{Binding PageState, ConverterParameter=Loading, Converter={StaticResource LoadingStateToBooleanConverter}}" Width="100" Height="100" />
                </StackPanel>
                <!-- No results found -->
                <TextBlock Grid.Row="5" Margin="20,20,0,0" Style="{StaticResource BaseTextBlockStyle}" 
                    x:Uid="/FeedbackApp.Resources/UIF_PlusOneCandidatesPage_NoSearchResults"
                    Text="No matching feedback" Visibility="Collapsed"/>                
                <Grid Grid.Row="6" Margin="0,20,20,40">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" MaxWidth="{StaticResource UIFContentMaxWidth}"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Column="1">
                        <TextBlock Style="{StaticResource PageLabel}" 
                                   x:Uid="/FeedbackApp.Resources/UIF_PlusOneCandidatesPage_NewIssueLabel"
                        Text="New Feedback label" />
                        <Button Command="{Binding NewIssueCommand}"
                                x:Uid="/FeedbackApp.Resources/UIF_PlusOneCandidatesPage_NewIssueButton"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Bottom"
                                Margin="10, 10, 0, 0"
                                Content="New feedback"/>
                    </StackPanel>
                </Grid>             
            </Grid>
        </Grid>
    </Grid>
</common:PageBase>

