<?xml version="1.0" encoding="utf-8" ?>
<Application
    x:Class="BetterLyrics.WinUI3.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converter="using:BetterLyrics.WinUI3.Converter"
    xmlns:converters="using:CommunityToolkit.WinUI.Converters"
    xmlns:local="using:BetterLyrics.WinUI3"
    xmlns:media="using:CommunityToolkit.WinUI.Media">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
                <ResourceDictionary Source="ms-appx:///CommunityToolkit.WinUI.Controls.SettingsControls/SettingsExpander/SettingsExpander.xaml" />
                <ResourceDictionary Source="ms-appx:///CommunityToolkit.WinUI.Controls.Segmented/Segmented/Segmented.xaml" />
                <!--  Other merged dictionaries here  -->
            </ResourceDictionary.MergedDictionaries>

            <!--  Theme  -->
            <ResourceDictionary.ThemeDictionaries>
                <ResourceDictionary x:Key="Light" />
                <ResourceDictionary x:Key="Dark" />
            </ResourceDictionary.ThemeDictionaries>

            <!--  Brush  -->
            <LinearGradientBrush x:Key="BaseHighEdgeHorizontalFadeBrush" StartPoint="0,0.5" EndPoint="1,0.5">
                <GradientStop Offset="0" Color="Transparent" />
                <GradientStop Offset="0.02" Color="{ThemeResource SystemBaseHighColor}" />
                <GradientStop Offset="0.98" Color="{ThemeResource SystemBaseHighColor}" />
                <GradientStop Offset="1" Color="Transparent" />
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="BaseHighEdgeVerticalFadeBrush" StartPoint="0.5,0" EndPoint="0.5,1">
                <GradientStop Offset="0" Color="Transparent" />
                <GradientStop Offset="0.15" Color="{ThemeResource SystemBaseHighColor}" />
                <GradientStop Offset="0.85" Color="{ThemeResource SystemBaseHighColor}" />
                <GradientStop Offset="1" Color="Transparent" />
            </LinearGradientBrush>

            <!--  Animation  -->
            <ExponentialEase x:Key="EaseInOut" EasingMode="EaseInOut" />
            <ExponentialEase x:Key="EaseOut" EasingMode="EaseOut" />
            <ExponentialEase x:Key="EaseIn" EasingMode="EaseIn" />

            <!--  Converter  -->
            <converter:EnumToIntConverter x:Key="EnumToIntConverter" />
            <converter:ColorToBrushConverter x:Key="ColorToBrushConverter" />
            <converter:MatchedLocalFilesPathToVisibilityConverter x:Key="MatchedLocalFilesPathToVisibilityConverter" />
            <converter:IntToCornerRadius x:Key="IntToCornerRadius" />
            <converter:CornerRadiusToDoubleConverter x:Key="CornerRadiusToDoubleConverter" />
            <converter:LyricsSearchProviderToDisplayNameConverter x:Key="LyricsSearchProviderToDisplayNameConverter" />
            <converter:TranslationSearchProviderToDisplayNameConverter x:Key="TranslationSearchProviderToDisplayNameConverter" />
            <converter:AlbumArtSearchProviderToDisplayNameConverter x:Key="AlbumArtSearchProviderToDisplayNameConverter" />
            <converter:SecondsToFormattedTimeConverter x:Key="SecondsToFormattedTimeConverter" />
            <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            <converters:BoolNegationConverter x:Key="BoolNegationConverter" />
            <converters:ColorToDisplayNameConverter x:Key="ColorToDisplayNameConverter" />

            <x:Double x:Key="SettingsCardSpacing">4</x:Double>

            <!--  Style  -->
            <Style
                x:Key="SettingsSectionHeaderTextBlockStyle"
                BasedOn="{StaticResource BodyStrongTextBlockStyle}"
                TargetType="TextBlock">
                <Style.Setters>
                    <Setter Property="Margin" Value="1,30,0,6" />
                </Style.Setters>
            </Style>
            <Style x:Key="TitleBarButtonStyle" TargetType="Button">
                <Setter Property="VerticalAlignment" Value="Top" />
                <Setter Property="CornerRadius" Value="4" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Padding" Value="16,9,16,11" />
                <Setter Property="Margin" Value="0" />
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <Style x:Key="GhostButtonStyle" TargetType="Button">
                <Setter Property="VerticalAlignment" Value="Stretch" />
                <Setter Property="Padding" Value="8" />
                <Setter Property="CornerRadius" Value="4" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <Style x:Key="TitleBarToggleButtonStyle" TargetType="ToggleButton">
                <Setter Property="CornerRadius" Value="4" />
                <Setter Property="VerticalAlignment" Value="Stretch" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Padding" Value="16,9,16,11" />
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <Style x:Key="GhostToggleButtonStyle" TargetType="ToggleButton">
                <Setter Property="CornerRadius" Value="4" />
                <Setter Property="VerticalAlignment" Value="Stretch" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Padding" Value="8" />
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <Style x:Key="CardGridStyle" TargetType="Grid">
                <Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
                <Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="CornerRadius" Value="6" />
            </Style>

            <Style x:Key="GhostSliderStyle" TargetType="Slider">
                <Setter Property="Background" Value="{ThemeResource ControlStrokeColorOnAccentDefaultBrush}" />
                <Setter Property="BorderThickness" Value="{ThemeResource SliderBorderThemeThickness}" />
                <Setter Property="Foreground" Value="{ThemeResource TextFillColorPrimaryBrush}" />
                <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
                <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
                <Setter Property="ManipulationMode" Value="None" />
                <Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
                <Setter Property="FocusVisualMargin" Value="-7,0,-7,0" />
                <Setter Property="IsFocusEngagementEnabled" Value="True" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Slider">
                            <Grid Margin="{TemplateBinding Padding}">
                                <Grid.Resources>
                                    <Style x:Key="SliderThumbStyle" TargetType="Thumb">
                                        <Setter Property="BorderThickness" Value="0" />
                                        <Setter Property="Background" Value="{ThemeResource TextFillColorPrimaryBrush}" />
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Thumb">
                                                    <Border
                                                        Background="{TemplateBinding Background}"
                                                        BorderBrush="{TemplateBinding BorderBrush}"
                                                        BorderThickness="{TemplateBinding BorderThickness}"
                                                        CornerRadius="0,1,1,0" />
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Grid.Resources>

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <ContentPresenter
                                    x:Name="HeaderContentPresenter"
                                    Grid.Row="0"
                                    Margin="{ThemeResource SliderTopHeaderMargin}"
                                    x:DeferLoadStrategy="Lazy"
                                    Content="{TemplateBinding Header}"
                                    ContentTemplate="{TemplateBinding HeaderTemplate}"
                                    FontWeight="{ThemeResource SliderHeaderThemeFontWeight}"
                                    Foreground="{ThemeResource SliderHeaderForeground}"
                                    TextWrapping="Wrap"
                                    Visibility="Collapsed" />
                                <Grid
                                    x:Name="SliderContainer"
                                    Grid.Row="1"
                                    Background="{ThemeResource SliderContainerBackground}"
                                    Control.IsTemplateFocusTarget="True">
                                    <Grid x:Name="HorizontalTemplate" MinHeight="{ThemeResource SliderHorizontalHeight}">

                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>

                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="{ThemeResource SliderPreContentMargin}" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="{ThemeResource SliderPostContentMargin}" />
                                        </Grid.RowDefinitions>
                                        <Rectangle
                                            x:Name="HorizontalTrackRect"
                                            Grid.Row="1"
                                            Grid.ColumnSpan="3"
                                            Height="2"
                                            Fill="{TemplateBinding Background}" />
                                        <Rectangle
                                            x:Name="HorizontalDecreaseRect"
                                            Grid.Row="1"
                                            Fill="{TemplateBinding Foreground}" />
                                        <TickBar
                                            x:Name="TopTickBar"
                                            Grid.ColumnSpan="3"
                                            Height="{ThemeResource SliderOutsideTickBarThemeHeight}"
                                            Margin="0,0,0,4"
                                            VerticalAlignment="Bottom"
                                            Fill="{ThemeResource SliderTickBarFill}"
                                            Visibility="Collapsed" />
                                        <TickBar
                                            x:Name="HorizontalInlineTickBar"
                                            Grid.Row="1"
                                            Grid.ColumnSpan="3"
                                            Height="2"
                                            Fill="{ThemeResource SliderInlineTickBarFill}"
                                            Visibility="Collapsed" />
                                        <TickBar
                                            x:Name="BottomTickBar"
                                            Grid.Row="2"
                                            Grid.ColumnSpan="3"
                                            Height="{ThemeResource SliderOutsideTickBarThemeHeight}"
                                            Margin="0,4,0,0"
                                            VerticalAlignment="Top"
                                            Fill="{ThemeResource SliderTickBarFill}"
                                            Visibility="Collapsed" />
                                        <Thumb
                                            x:Name="HorizontalThumb"
                                            Grid.Row="0"
                                            Grid.RowSpan="3"
                                            Grid.Column="1"
                                            Width="2"
                                            Height="2"
                                            AutomationProperties.AccessibilityView="Raw"
                                            DataContext="{TemplateBinding Value}"
                                            FocusVisualMargin="-14,-6,-14,-6"
                                            Style="{StaticResource SliderThumbStyle}" />
                                    </Grid>
                                    <Grid
                                        x:Name="VerticalTemplate"
                                        MinWidth="{ThemeResource SliderVerticalWidth}"
                                        Visibility="Collapsed">

                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>

                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="{ThemeResource SliderPreContentMargin}" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="{ThemeResource SliderPostContentMargin}" />
                                        </Grid.ColumnDefinitions>
                                        <Rectangle
                                            x:Name="VerticalTrackRect"
                                            Grid.RowSpan="3"
                                            Grid.Column="1"
                                            Width="{ThemeResource SliderTrackThemeHeight}"
                                            Fill="{TemplateBinding Background}" />
                                        <Rectangle
                                            x:Name="VerticalDecreaseRect"
                                            Grid.Row="2"
                                            Grid.Column="1"
                                            Fill="{TemplateBinding Foreground}" />
                                        <TickBar
                                            x:Name="LeftTickBar"
                                            Grid.RowSpan="3"
                                            Width="{ThemeResource SliderOutsideTickBarThemeHeight}"
                                            Margin="0,0,4,0"
                                            HorizontalAlignment="Right"
                                            Fill="{ThemeResource SliderTickBarFill}"
                                            Visibility="Collapsed" />
                                        <TickBar
                                            x:Name="VerticalInlineTickBar"
                                            Grid.RowSpan="3"
                                            Grid.Column="1"
                                            Width="{ThemeResource SliderTrackThemeHeight}"
                                            Fill="{ThemeResource SliderInlineTickBarFill}"
                                            Visibility="Collapsed" />
                                        <TickBar
                                            x:Name="RightTickBar"
                                            Grid.RowSpan="3"
                                            Grid.Column="2"
                                            Width="{ThemeResource SliderOutsideTickBarThemeHeight}"
                                            Margin="4,0,0,0"
                                            HorizontalAlignment="Left"
                                            Fill="{ThemeResource SliderTickBarFill}"
                                            Visibility="Collapsed" />
                                        <Thumb
                                            x:Name="VerticalThumb"
                                            Grid.Row="1"
                                            Grid.Column="0"
                                            Grid.ColumnSpan="3"
                                            Width="24"
                                            Height="8"
                                            AutomationProperties.AccessibilityView="Raw"
                                            DataContext="{TemplateBinding Value}"
                                            FocusVisualMargin="-6,-14,-6,-14"
                                            Style="{StaticResource SliderThumbStyle}" />
                                    </Grid>

                                </Grid>

                            </Grid>

                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="ListViewStretchedItemContainerStyle" TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="Margin" Value="0" />
                <Setter Property="Padding" Value="0" />
            </Style>

            <StaticResource x:Key="ToggleButtonBackgroundChecked" ResourceKey="TextFillColorPrimaryBrush" />
            <StaticResource x:Key="ToggleButtonBackgroundCheckedPointerOver" ResourceKey="TextFillColorPrimaryBrush" />
            <StaticResource x:Key="ToggleButtonBackgroundCheckedPressed" ResourceKey="TextFillColorPrimaryBrush" />

            <!--  Dimensions  -->

            <!--  Fonts  -->
            <FontFamily x:Key="IconFontFamily">ms-appx:///Assets/Segoe Fluent Icons.ttf#Segoe Fluent Icons</FontFamily>
        </ResourceDictionary>
    </Application.Resources>
</Application>
