<?xml version="1.0" encoding="utf-8" ?>
<Page
    x:Class="BetterLyrics.WinUI3.Views.SettingsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:CommunityToolkit.WinUI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:local="using:BetterLyrics.WinUI3.Views"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:models="using:BetterLyrics.WinUI3.Models"
    xmlns:scontrols="using:ShadowViewer.Controls"
    xmlns:uc="using:BetterLyrics.WinUI3.Controls"
    xmlns:ui="using:CommunityToolkit.WinUI"
    xmlns:vm="using:BetterLyrics.WinUI3.ViewModels"
    mc:Ignorable="d">

    <Grid x:Name="RootGrid">

        <NavigationView
            x:Name="NavView"
            IsBackButtonVisible="Collapsed"
            IsSettingsVisible="False"
            SelectionChanged="NavView_SelectionChanged">
            <NavigationView.MenuItems>

                <NavigationViewItem
                    x:Uid="SettingsPageApp"
                    Icon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                       Glyph=&#xECAA;}"
                    IsSelected="True"
                    Tag="App" />

                <NavigationViewItem
                    x:Uid="SettingsPageAlbumStyle"
                    Icon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                       Glyph=&#xE93C;}"
                    Tag="AlbumArtStyle" />

                <NavigationViewItem
                    x:Uid="SettingsPageMediaLib"
                    Icon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                       Glyph=&#xE8B7;}"
                    Tag="MediaLib" />

                <NavigationViewItem
                    x:Uid="SettingsPagePlaybackLib"
                    Icon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                       Glyph=&#xEA69;}"
                    Tag="PlaybackLib" />

                <NavigationViewItem
                    x:Uid="SettingsPageBackgroundOverlay"
                    Icon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                       Glyph=&#xF5EF;}"
                    Tag="Background" />

                <NavigationViewItem
                    x:Uid="SettingsPageLyrics"
                    Icon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                       Glyph=&#xEDC6;}"
                    Tag="Lyrics" />

                <NavigationViewItem
                    x:Uid="SettingsPageAbout"
                    Icon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                       Glyph=&#xE946;}"
                    Tag="About" />

                <NavigationViewItem
                    x:Uid="SettingsPageDev"
                    Icon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                       Glyph=&#xEC7A;}"
                    Tag="Dev" />

            </NavigationView.MenuItems>

            <controls:SwitchPresenter Value="{x:Bind ViewModel.NavViewSelectedItemTag, Mode=OneWay}">
                <controls:SwitchPresenter.ContentTransitions>
                    <TransitionCollection>
                        <PopupThemeTransition />
                    </TransitionCollection>
                </controls:SwitchPresenter.ContentTransitions>

                <!--  App appearance and behavior  -->
                <controls:Case Value="App">
                    <uc:AppSettingsControl />
                </controls:Case>

                <!--  Lyrics background  -->
                <controls:Case Value="Background">
                    <uc:LyricsBackgroundSettingsControl />
                </controls:Case>

                <!--  Album art area style  -->
                <controls:Case Value="AlbumArtStyle">
                    <uc:AlbumArtLayoutSettingsControl />
                </controls:Case>

                <!--  Playback sources  -->
                <controls:Case Value="PlaybackLib">
                    <uc:PlaybackSettingsControl />
                </controls:Case>

                <!--  Media lib  -->
                <controls:Case Value="MediaLib">
                    <uc:MediaSettingsControl />
                </controls:Case>

                <!--  Lyrics style and effect  -->
                <controls:Case Value="Lyrics">
                    <uc:AllLyricsSettingsControl />
                </controls:Case>

                <!--  About  -->
                <controls:Case Value="About">
                    <ScrollViewer Style="{StaticResource SettingsScrollViewerStyle}">
                        <Grid Style="{StaticResource SettingsGridStyle}">
                            <StackPanel Spacing="{StaticResource SettingsCardSpacing}">

                                <TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" />

                                <controls:SettingsCard Header="BetterLyrics" HeaderIcon="{ui:BitmapIcon Source=ms-appx:///Assets/Logo.png}">
                                    <controls:SettingsCard.Description>
                                        <RichTextBlock>
                                            <Paragraph>
                                                <Run x:Uid="SettingsPageVersion" />
                                                <Run Text="{x:Bind ViewModel.Version, Mode=OneWay}" />
                                            </Paragraph>
                                        </RichTextBlock>
                                    </controls:SettingsCard.Description>
                                </controls:SettingsCard>

                                <controls:SettingsCard
                                    x:Uid="SettingsPageGitHub"
                                    ActionIcon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                                             Glyph=&#xE8A7;}"
                                    Command="{x:Bind ViewModel.LaunchProjectGitHubPageCommand}"
                                    HeaderIcon="{ui:FontIcon FontFamily={StaticResource IconFontFamily},
                                                             Glyph=&#xE943;}"
                                    IsClickEnabled="True" />

                                <controls:SettingsCard x:Uid="SettingsPageFAQ" HeaderIcon="{ui:FontIcon FontFamily={StaticResource IconFontFamily}, Glyph=&#xE897;}">
                                    <HyperlinkButton Content="https://github.com/jayfunc/BetterLyrics/blob/dev/FAQ/FAQ.md" NavigateUri="https://github.com/jayfunc/BetterLyrics/blob/dev/FAQ/FAQ.md" />
                                </controls:SettingsCard>

                                <controls:SettingsCard x:Uid="SettingsPageQQGroup" HeaderIcon="{ui:BitmapIcon Source=ms-appx:///Assets/QQ.png}">
                                    <Button x:Uid="SettingsPageJoinNowButton" Click="QQGroupButton_Click" />
                                </controls:SettingsCard>

                                <controls:SettingsCard x:Uid="SettingsPageDiscord" HeaderIcon="{ui:BitmapIcon Source=ms-appx:///Assets/Discord.png}">
                                    <Button x:Uid="SettingsPageJoinNowButton" Click="DiscodGroupButton_Click" />
                                </controls:SettingsCard>

                                <controls:SettingsCard x:Uid="SettingsPageTelegram" HeaderIcon="{ui:BitmapIcon Source=ms-appx:///Assets/Telegram.png}">
                                    <Button x:Uid="SettingsPageJoinNowButton" Click="TelegramGroupButton_Click" />
                                </controls:SettingsCard>

                            </StackPanel>
                        </Grid>
                    </ScrollViewer>
                </controls:Case>

                <!--  Dev  -->
                <controls:Case Value="Dev">
                    <ScrollViewer Style="{StaticResource SettingsScrollViewerStyle}">
                        <Grid Style="{StaticResource SettingsGridStyle}">
                            <StackPanel Spacing="{StaticResource SettingsCardSpacing}">

                                <TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" />

                                <controls:SettingsCard x:Uid="SettingsPageMockMusicPlaying">
                                    <HyperlinkButton x:Uid="SettingsPagePlayingMockMusicButton" NavigateUri="https://soundcloud.com/carlyraejepsen/cut-to-the-feeling" />
                                </controls:SettingsCard>

                                <controls:SettingsCard x:Uid="SettingsPageCache">
                                    <Button x:Uid="SettingsPageOpenLogFolderButton" Command="{x:Bind ViewModel.OpenCacheFolderCommand}" />
                                </controls:SettingsCard>

                                <controls:SettingsExpander x:Uid="SettingsPageSettingsManager" IsExpanded="True">
                                    <StackPanel Orientation="Horizontal" Spacing="6">
                                        <Button x:Uid="SettingsPageImportSettingsButton" Command="{x:Bind ViewModel.ImportSettingsCommand}" />
                                        <Button x:Uid="SettingsPageExportSettingsButton" Command="{x:Bind ViewModel.ExportSettingsCommand}" />
                                    </StackPanel>
                                    <controls:SettingsExpander.ItemsHeader>
                                        <InfoBar
                                            x:Uid="SettingsPageImportSettingsInfo"
                                            BorderThickness="0"
                                            CornerRadius="0"
                                            IsClosable="False"
                                            IsOpen="True"
                                            Severity="Warning" />
                                    </controls:SettingsExpander.ItemsHeader>
                                </controls:SettingsExpander>

                                <controls:SettingsCard x:Uid="SettingsPageDebugOverlay">
                                    <ToggleSwitch IsOn="{x:Bind ViewModel.IsDebugOverlayEnabled, Mode=TwoWay}" />
                                </controls:SettingsCard>

                                <controls:SettingsCard x:Uid="SettingsPageFixedTimeStep" Visibility="Collapsed">
                                    <ToggleSwitch IsOn="{x:Bind ViewModel.AppSettings.AdvancedSettings.IsFixedTimeStep, Mode=TwoWay}" />
                                </controls:SettingsCard>

                                <controls:SettingsCard x:Uid="SettingsPageFPS" Visibility="Collapsed">
                                    <uc:ExtendedSlider
                                        Default="60"
                                        Frequency="10"
                                        Maximum="240"
                                        Minimum="30"
                                        Value="{x:Bind ViewModel.AppSettings.AdvancedSettings.FPS, Mode=TwoWay}" />
                                </controls:SettingsCard>

                            </StackPanel>
                        </Grid>
                    </ScrollViewer>
                </controls:Case>

            </controls:SwitchPresenter>
        </NavigationView>

    </Grid>
</Page>
