<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Wino.Controls"
    xmlns:local="using:Wino.Mail.WinUI.Controls.ListView">

    <ResourceDictionary.MergedDictionaries>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
        <ResourceDictionary Source="/Styles/WinoExpanderStyle.xaml" />

        <ResourceDictionary>
            <!--  Thread Mail ListViewItem Style  -->
            <Style
                x:Key="DefaultThreadListViewItemStyle"
                BasedOn="{StaticResource DefaultListViewItemStyle}"
                TargetType="local:WinoThreadMailItemViewModelListViewItem">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="local:WinoThreadMailItemViewModelListViewItem">
                            <SwipeControl x:Name="ThreadSwipeControl" Tag="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Item}">
                                <SwipeControl.LeftItems>
                                    <controls:WinoSwipeControlItems
                                        x:Name="LeftSwipeItems"
                                        IsRightSwipe="False"
                                        MailItem="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Item}" />
                                </SwipeControl.LeftItems>
                                <SwipeControl.RightItems>
                                    <controls:WinoSwipeControlItems
                                        x:Name="RightSwipeItems"
                                        IsRightSwipe="True"
                                        MailItem="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Item}" />
                                </SwipeControl.RightItems>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="8" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>

                                    <Grid
                                        x:Name="RootGrid"
                                        Grid.ColumnSpan="2"
                                        Background="{ThemeResource ListViewItemBackground}"
                                        CornerRadius="{ThemeResource ControlCornerRadius}" />
                                    <Border
                                        x:Name="SelectionIndicator"
                                        Width="4"
                                        Margin="0,16"
                                        HorizontalAlignment="Center"
                                        Background="{ThemeResource ListViewItemSelectionIndicatorBrush}"
                                        CornerRadius="4"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Item.IsSelected, Mode=OneWay}" />

                                    <!--  Expandable Content  -->
                                    <ContentPresenter
                                        x:Name="ThreadContent"
                                        Grid.Column="1"
                                        Margin="6,0,0,0"
                                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                        Content="{TemplateBinding Content}"
                                        ContentTemplate="{TemplateBinding ContentTemplate}"
                                        ContentTransitions="{TemplateBinding ContentTransitions}" />


                                </Grid>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal" />
                                        <VisualState x:Name="PointerOver">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundPointerOver}" />
                                                <Setter Target="ThreadContent.Foreground" Value="{ThemeResource ListViewItemForegroundPointerOver}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                        <VisualState x:Name="Selected">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundSelected}" />
                                                <Setter Target="ThreadContent.Foreground" Value="{ThemeResource ListViewItemForegroundSelected}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                        <VisualState x:Name="SelectedPointerOver">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundSelectedPointerOver}" />
                                                <Setter Target="ThreadContent.Foreground" Value="{ThemeResource ListViewItemForegroundSelected}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundPressed}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                        <VisualState x:Name="PressedSelected">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundSelectedPressed}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                            </SwipeControl>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <!--  Default Single Mail List View Item Style.  -->
            <Style
                x:Key="DefaultMailListViewItemStyle"
                BasedOn="{StaticResource DefaultListViewItemStyle}"
                TargetType="local:WinoMailItemViewModelListViewItem">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="local:WinoMailItemViewModelListViewItem">
                            <SwipeControl x:Name="MailSwipeControl" Tag="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Item}">
                                <SwipeControl.LeftItems>
                                    <controls:WinoSwipeControlItems
                                        x:Name="LeftSwipeItems"
                                        IsRightSwipe="False"
                                        MailItem="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Item}" />
                                </SwipeControl.LeftItems>
                                <SwipeControl.RightItems>
                                    <controls:WinoSwipeControlItems
                                        x:Name="RightSwipeItems"
                                        IsRightSwipe="True"
                                        MailItem="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Item}" />
                                </SwipeControl.RightItems>
                                <Grid
                                    x:Name="RootGrid"
                                    Margin="0,2"
                                    Background="{ThemeResource ListViewItemBackground}"
                                    CornerRadius="{ThemeResource ControlCornerRadius}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="8" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Border
                                        x:Name="SelectionIndicator"
                                        Width="4"
                                        Margin="0,16"
                                        HorizontalAlignment="Center"
                                        Background="{ThemeResource ListViewItemSelectionIndicatorBrush}"
                                        CornerRadius="4"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Item.IsSelected, Mode=OneWay}" />

                                    <ContentPresenter
                                        x:Name="MailContent"
                                        Grid.Column="1"
                                        Margin="6,0,0,0"
                                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                        Background="Transparent"
                                        Content="{TemplateBinding Content}"
                                        ContentTemplate="{TemplateBinding ContentTemplate}"
                                        ContentTransitions="{TemplateBinding ContentTransitions}" />


                                </Grid>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal" />
                                        <VisualState x:Name="PointerOver">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundPointerOver}" />
                                                <Setter Target="MailContent.Foreground" Value="{ThemeResource ListViewItemForegroundPointerOver}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                        <VisualState x:Name="Selected">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundSelected}" />
                                                <Setter Target="MailContent.Foreground" Value="{ThemeResource ListViewItemForegroundSelected}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                        <VisualState x:Name="SelectedPointerOver">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundSelectedPointerOver}" />
                                                <Setter Target="MailContent.Foreground" Value="{ThemeResource ListViewItemForegroundSelected}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundPressed}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                        <VisualState x:Name="PressedSelected">
                                            <VisualState.Setters>
                                                <Setter Target="RootGrid.Background" Value="{ThemeResource ListViewItemBackgroundSelectedPressed}" />
                                            </VisualState.Setters>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                            </SwipeControl>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <local:WinoMailItemContainerStyleSelector
                x:Name="WinoMailItemContainerStyleSelector"
                MailItemStyle="{StaticResource DefaultMailListViewItemStyle}"
                ThreadStyle="{StaticResource DefaultThreadListViewItemStyle}" />
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>


</ResourceDictionary>
