<Page
    x:Class="FoxTube.Search"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FoxTube"
    xmlns:pages="using:FoxTube.Pages"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:FoxTube.Controls"
    xmlns:classes="using:FoxTube.Classes"
    mc:Ignorable="d">

    <Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <ScrollViewer>
            <StackPanel Margin="10">
                <TextBlock Name="searchTerm" Text="Search results for: [searchTerm]" FontSize="28"/>
                <TextBlock Name="resultsCount" Text="Found: [resultCount] item(s)" FontSize="14" Foreground="Gray"/>

                <HyperlinkButton x:Uid="/Search/filters" Name="toggleFilters" Click="ToggleFilters_Click" Content="Show filters &#xE71C;" FontFamily="Default, Segoe MDL2 Assets" Visibility="Visible"/>
                <StackPanel Name="filters" Visibility="Collapsed">
                    <GridView Padding="5" SelectionMode="None">
                        <ComboBox x:Uid="/Search/order" Name="order" Header="Sort by" Width="150" SelectedIndex="0">
                            <ComboBoxItem x:Uid="/Search/relevance" Content="Relevance"/>
                            <ComboBoxItem x:Uid="/Search/update" Content="Upload date"/>
                            <ComboBoxItem x:Uid="/Search/views" Content="View count"/>
                            <ComboBoxItem x:Uid="/Search/rating" Content="Rating"/>
                            <ComboBoxItem x:Uid="/Search/title" Content="Title"/>
                        </ComboBox>
                        <ComboBox x:Uid="/Search/type" Name="type" Header="Type" Width="150" SelectedIndex="0" SelectionChanged="Type_SelectionChanged">
                            <ComboBoxItem x:Uid="/Search/all" Content="All"/>
                            <ComboBoxItem x:Uid="/Search/video" Content="Video"/>
                            <ComboBoxItem x:Uid="/Search/channel" Content="Channel"/>
                            <ComboBoxItem x:Uid="/Search/playlist" Content="Playlist"/>
                        </ComboBox>
                        <ComboBox x:Uid="/Search/updateHeader" Name="date" Header="Upload date" Width="150" SelectedIndex="0">
                            <ComboBoxItem x:Uid="/Search/anytime" Content="Anytime"/>
                            <ComboBoxItem x:Uid="/Search/lasthr" Content="Last hour"/>
                            <ComboBoxItem x:Uid="/Search/today" Content="Today"/>
                            <ComboBoxItem x:Uid="/Search/week" Content="This week"/>
                            <ComboBoxItem x:Uid="/Search/month" Content="This month"/>
                            <ComboBoxItem x:Uid="/Search/year" Content="This year"/>
                        </ComboBox>
                        <ComboBox x:Uid="/Search/duration" Visibility="Collapsed" Name="duration" Header="Duration" Width="150" SelectedIndex="0">
                            <ComboBoxItem x:Uid="/Search/any" Content="Any"/>
                            <ComboBoxItem x:Uid="/Search/long" Content="Long (&#x3E; 20 minutes)"/>
                            <ComboBoxItem x:Uid="/Search/medium" Content="Medium"/>
                            <ComboBoxItem x:Uid="/Search/short" Content="Short (&#x3C; 4 minutes)"/>
                        </ComboBox>
                    </GridView>
                    <StackPanel Orientation="Horizontal">
                        <Button x:Uid="/Search/features" Visibility="Collapsed" Content="Features" Name="featBtn" Margin="10,0,0,10">
                            <Button.Flyout>
                                <Flyout>
                                    <ListView x:Uid="/Search/featuresHeader" Name="features" SelectionMode="Multiple" Header="Features">
                                        <TextBlock Text="HD"/>
                                        <TextBlock Text="3D"/>
                                        <TextBlock x:Uid="/Search/subs" Text="Subtitles/CC"/>
                                        <TextBlock x:Uid="/Search/live" Text="Live"/>
                                        <TextBlock x:Uid="/Search/cc" Text="Creative Commons"/>
                                    </ListView>
                                </Flyout>
                            </Button.Flyout>
                        </Button>
                        <Button x:Uid="/Search/apply" Content="Apply" Margin="10,0,0,10" Name="apply" Click="Apply_Click"/>
                    </StackPanel>
                </StackPanel>
                <pages:VideoGrid x:Name="list"/>
                <controls:ShowMore x:Name="more" Clicked="More_Clicked"/>
            </StackPanel>
        </ScrollViewer>

        <classes:AdaptiveCommandBar Grid.Row="1">
            <AppBarButton Label="Open in browser" Icon="Globe" Name="inBrowser" Click="InBrowser_Click"/>
            <AppBarButton Label="Refresh" Icon="Refresh" Click="AppBarButton_Click"/>
        </classes:AdaptiveCommandBar>
    </Grid>
</Page>
