<controls1:EnhancedPage
    x:Class="Pixeval.Pages.Misc.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:controls1="using:Pixeval.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:fluent="using:FluentIcons.WinUI"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:misc="using:Pixeval.Attributes"
    xmlns:misc1="using:Pixeval.Pages.Misc"
    xmlns:pixeval="using:Pixeval"
    Loaded="SettingsPage_OnLoaded"
    Unloaded="SettingsPage_OnUnloaded"
    mc:Ignorable="d">
    <controls1:EnhancedPage.Resources>
        <Style
            x:Key="SettingHeaderStyle"
            BasedOn="{StaticResource BodyStrongTextBlockStyle}"
            TargetType="TextBlock">
            <Style.Setters>
                <Setter Property="Margin" Value="1,28,0,4" />
            </Style.Setters>
        </Style>
    </controls1:EnhancedPage.Resources>
    <controls:DockPanel VerticalSpacing="10">
        <TextBlock
            x:Uid="/SettingsPage/TitleTextBlock"
            Margin="20,40,20,20"
            controls:DockPanel.Dock="Top"
            Style="{StaticResource TitleTextBlockStyle}" />
        <ScrollView x:Name="SettingsPageScrollView">
            <StackPanel x:Name="SettingsPanel" Margin="20,0,20,20">
                <!--  region Header  -->
                <controls:DockPanel
                    HorizontalSpacing="20"
                    LastChildFill="False"
                    VerticalSpacing="10">
                    <controls:ConstrainedBox
                        MaxHeight="160"
                        controls:DockPanel.Dock="Left"
                        AspectRatio="1360:906"
                        CornerRadius="{ThemeResource ControlCornerRadius}">
                        <Image Source="../../Assets/Images/pixeval-mock.png" Stretch="UniformToFill" />
                    </controls:ConstrainedBox>
                    <TextBlock
                        x:Uid="/SettingsPage/AppDescriptionTextBlock"
                        controls:DockPanel.Dock="Top"
                        TextWrapping="Wrap" />
                    <controls:WrapPanel
                        controls:DockPanel.Dock="Bottom"
                        HorizontalSpacing="24"
                        IsTabStop="False"
                        Orientation="Horizontal">
                        <HyperlinkButton x:Uid="/SettingsPage/ViewPixevalWebsiteHyperlinkButton" NavigateUri="https://pixeval.github.io/" />
                        <HyperlinkButton x:Uid="/SettingsPage/GitHubRepositoryHyperlinkButton" NavigateUri="https://github.com/Pixeval/Pixeval" />
                        <HyperlinkButton x:Uid="/SettingsPage/ReportBugHyperlinkButton" NavigateUri="https://github.com/Pixeval/Pixeval/issues/new/choose" />
                        <HyperlinkButton x:Uid="/SettingsPage/FeedbackByEmailHyperlinkButton" NavigateUri="mailto:decem0730@hotmail.com" />
                        <HyperlinkButton x:Uid="/SettingsPage/DonateDeveloperHyperlinkButton" NavigateUri="https://afdian.net/a/dylech30th" />
                        <HyperlinkButton x:Uid="/SettingsPage/JoinFeedbackGroupHyperlinkButton" NavigateUri="https://jq.qq.com/?_wv=1027&amp;k=trDeCrog" />
                    </controls:WrapPanel>
                </controls:DockPanel>
                <!--  endregion  -->
                <!--  region Settings Entries  -->
                <TextBlock
                    x:Uid="/SettingsPage/VersionSettingsGroup"
                    Style="{StaticResource SettingHeaderStyle}"
                    Tag="{x:Bind misc1:SettingsEntryCategory.Version}" />

                <controls:SettingsExpander HeaderIcon="{fluent:SymbolIcon Symbol=ArrowSync}" IsExpanded="{x:Bind _viewModel.ExpandExpander, Mode=OneWay}">
                    <controls:SettingsExpander.Header>
                        <HyperlinkButton
                            Padding="0"
                            Click="ReleaseNotesHyperlink_OnClicked"
                            Content="{x:Bind CurrentVersion}" />
                    </controls:SettingsExpander.Header>
                    <controls:SettingsExpander.Description>
                        <StackPanel Spacing="3">
                            <TextBlock>
                                <Run Text="{x:Bind _viewModel.GetLastUpdateCheckDisplayString(_viewModel.LastCheckedUpdate), Mode=OneWay}" />
                            </TextBlock>
                        </StackPanel>
                    </controls:SettingsExpander.Description>
                    <StackPanel Orientation="Horizontal" Spacing="10">
                        <ProgressRing
                            Width="35"
                            Height="35"
                            IsActive="True"
                            IsIndeterminate="{x:Bind controls1:C.Negation(_viewModel.DownloadingUpdate), Mode=OneWay}"
                            Visibility="{x:Bind controls1:C.ToVisibility(_viewModel.CheckingUpdate), Mode=OneWay}"
                            Value="{x:Bind _viewModel.DownloadingUpdateProgress, Mode=OneWay}" />
                        <TextBlock
                            VerticalAlignment="Center"
                            Text="{x:Bind _viewModel.UpdateMessage, Mode=OneWay}"
                            Visibility="{x:Bind controls1:C.IsNotNullToVisibility(_viewModel.UpdateMessage), Mode=OneWay}" />
                        <Button
                            x:Uid="/SettingsPage/CheckForUpdatesButton"
                            Click="CheckForUpdateButton_OnClicked"
                            IsEnabled="{x:Bind controls1:C.Negation(_viewModel.CheckingUpdate), Mode=OneWay}" />
                    </StackPanel>
                    <controls:SettingsExpander.Items>
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/OpenTempEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="OpenFolder_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=FolderLightning}"
                            IsClickEnabled="True"
                            Tag="Temp" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/MsStoreCheckForUpdatesEntry"
                            Click="OpenLinkViaTag_OnClicked"
                            Description="ms-windows-store://pdp/?ProductId=9P1RZL9Z8454"
                            HeaderIcon="{fluent:SymbolIcon Symbol=StoreMicrosoft}"
                            IsClickEnabled="True"
                            Tag="ms-windows-store://pdp/?ProductId=9P1RZL9Z8454" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/GitHubCheckForUpdatesEntry"
                            Click="OpenLinkViaTag_OnClicked"
                            Description="https://github.com/Pixeval/Pixeval/releases"
                            IsClickEnabled="True"
                            Tag="https://github.com/Pixeval/Pixeval/releases">
                            <controls:SettingsCard.HeaderIcon>
                                <PathIcon Data="{x:Bind pixeval:SvgResources.GitHub}" />
                            </controls:SettingsCard.HeaderIcon>
                        </controls:SettingsCard>
                    </controls:SettingsExpander.Items>
                </controls:SettingsExpander>

                <InfoBar
                    Title="{x:Bind _viewModel.UpdateInfo, Mode=OneWay}"
                    IsClosable="False"
                    IsOpen="True"
                    Message="{x:Bind _viewModel.NewestVersion, Mode=OneWay}"
                    Severity="{x:Bind _viewModel.UpdateInfoSeverity, Mode=OneWay}">
                    <InfoBar.ActionButton>
                        <HyperlinkButton
                            x:Uid="/SettingsPage/ReleaseNotesHyperlinkButton"
                            Click="ReleaseNotesHyperlink_OnClicked"
                            Tag="Newest"
                            Visibility="{x:Bind controls1:C.IsNotNullToVisibility(_viewModel.NewestVersion), Mode=OneWay}" />
                    </InfoBar.ActionButton>
                </InfoBar>

                <controls:SettingsCard
                    x:Uid="/SettingsPage/DownloadUpdateAutomaticallyEntry"
                    HeaderIcon="{fluent:SymbolIcon Symbol=Communication}"
                    IsEnabled="False"
                    Tag="{x:Bind misc:SettingsEntryAttribute.AutoUpdate}">
                    <ToggleSwitch IsOn="{x:Bind _viewModel.DownloadUpdateAutomatically, Mode=TwoWay}" />
                </controls:SettingsCard>

                <controls:SettingsExpander x:Uid="/SettingsPage/BugReportEntry" HeaderIcon="{fluent:SymbolIcon Symbol=Bug}">
                    <controls:SettingsExpander.Items>
                        <controls:SettingsCard x:Uid="/SettingsPage/BugReportEntry" HeaderIcon="{fluent:SymbolIcon Symbol=Send}">
                            <CommandBar OverflowButtonVisibility="Collapsed">
                                <AppBarButton
                                    x:Uid="/SettingsPage/GitHubBugReportEntry"
                                    Click="OpenLinkViaTag_OnClicked"
                                    Tag="https://github.com/Pixeval/Pixeval/issues/new/choose">
                                    <AppBarButton.Icon>
                                        <PathIcon Data="{x:Bind pixeval:SvgResources.GitHub}" />
                                    </AppBarButton.Icon>
                                </AppBarButton>
                                <AppBarButton
                                    x:Uid="/SettingsPage/EMailBugReportEntry"
                                    Click="OpenLinkViaTag_OnClicked"
                                    Icon="{fluent:SymbolIcon Symbol=Mail}"
                                    Tag="mailto:decem0730@hotmail.com" />
                                <AppBarButton
                                    x:Uid="/SettingsPage/QQBugReportEntry"
                                    Click="OpenLinkViaTag_OnClicked"
                                    Tag="https://jq.qq.com/?_wv=1027&amp;k=trDeCrog">
                                    <AppBarButton.Icon>
                                        <PathIcon Data="{x:Bind pixeval:SvgResources.QQ}" />
                                    </AppBarButton.Icon>
                                </AppBarButton>
                            </CommandBar>
                        </controls:SettingsCard>
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/OpenLogEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="OpenFolder_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=FolderList}"
                            IsClickEnabled="True"
                            Tag="Logs" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/OpenTempEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="OpenFolder_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=FolderLightning}"
                            IsClickEnabled="True"
                            Tag="Temp" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/OpenLocalEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="OpenFolder_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=FolderBriefcase}"
                            IsClickEnabled="True"
                            Tag="Local" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/OpenExtensionsEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="OpenFolder_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=FolderAdd}"
                            IsClickEnabled="True"
                            Tag="Extensions" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/OpenSettingsEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="OpenFolder_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=FolderPerson}"
                            IsClickEnabled="True"
                            Tag="Settings" />
                    </controls:SettingsExpander.Items>
                </controls:SettingsExpander>

                <controls:SettingsCard
                    x:Uid="/SettingsPage/RateEntry"
                    ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                    Click="OpenLinkViaTag_OnClicked"
                    HeaderIcon="{fluent:SymbolIcon Symbol=Star}"
                    IsClickEnabled="True"
                    Tag="ms-windows-store://pdp/?ProductId=9P1RZL9Z8454" />

                <TextBlock
                    x:Uid="/SettingsPage/SessionSettingsGroup"
                    Style="{StaticResource SettingHeaderStyle}"
                    Tag="{x:Bind misc1:SettingsEntryCategory.Session}" />

                <controls:SettingsCard
                    x:Uid="/SettingsPage/SignOutEntry"
                    Click="PerformSignOutButton_OnClicked"
                    HeaderIcon="{fluent:SymbolIcon Symbol=SignOut}"
                    IsClickEnabled="True"
                    Tag="{x:Bind misc:SettingsEntryAttribute.SignOut}" />

                <controls:SettingsCard
                    x:Uid="/SettingsPage/ResetDefaultSettingsEntry"
                    ActionIcon="{fluent:SymbolIcon Symbol=ArrowReset}"
                    Click="ResetDefaultSettings_OnClicked"
                    HeaderIcon="{fluent:SymbolIcon Symbol=Apps}"
                    IsClickEnabled="True"
                    Tag="{x:Bind misc:SettingsEntryAttribute.ResetSettings}" />

                <controls:SettingsExpander
                    x:Uid="/SettingsPage/BackupSettingsEntry"
                    HeaderIcon="{fluent:SymbolIcon Symbol=ClipboardSettings}"
                    Tag="{x:Bind misc:SettingsEntryAttribute.ResetSettings}">
                    <controls:SettingsExpander.Items>
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/OpenSettingsEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="OpenFolder_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=FolderPerson}"
                            IsClickEnabled="True"
                            Tag="Settings" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/ExportSettingsPlaintextEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="ExportSettingsPlainText_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=ArrowExport}"
                            IsClickEnabled="True" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/ImportSettingsPlaintextEntry"
                            ActionIcon="{fluent:SymbolIcon Symbol=Open}"
                            Click="ImportSettingsPlaintext_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=ArrowImport}"
                            IsClickEnabled="True" />
                    </controls:SettingsExpander.Items>
                </controls:SettingsExpander>

                <controls:SettingsExpander
                    x:Uid="/SettingsPage/DeleteHistoriesEntry"
                    HeaderIcon="{fluent:SymbolIcon Symbol=HistoryDismiss}"
                    Tag="{x:Bind misc:SettingsEntryAttribute.DeleteHistories}">
                    <controls:SettingsExpander.Items>
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/DeleteFileCacheEntry"
                            Click="DeleteFileCacheEntryButton_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=HistoryDismiss}"
                            IsClickEnabled="True" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/DeleteSearchHistoriesEntry"
                            Click="DeleteSearchHistoriesButton_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=HistoryDismiss}"
                            IsClickEnabled="True" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/DeleteBrowseHistoriesEntry"
                            Click="DeleteBrowseHistoriesButton_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=HistoryDismiss}"
                            IsClickEnabled="True" />
                        <controls:SettingsCard
                            x:Uid="/SettingsPage/DeleteDownloadHistoriesEntry"
                            Click="DeleteDownloadHistoriesButton_OnClicked"
                            HeaderIcon="{fluent:SymbolIcon Symbol=HistoryDismiss}"
                            IsClickEnabled="True" />
                    </controls:SettingsExpander.Items>
                </controls:SettingsExpander>
                <!--  设置项插入处  -->
            </StackPanel>
        </ScrollView>
    </controls:DockPanel>
</controls1:EnhancedPage>
