<!--
    Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
    the MIT License. See LICENSE in the project root for license information.
-->
<Page x:Class="Microsoft.Terminal.Settings.Editor.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:Microsoft.Terminal.Settings.Editor"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
      xmlns:tsm="using:Microsoft.Terminal.Settings.Model"
      mc:Ignorable="d">

    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="CommonResources.xaml" />

                <ResourceDictionary>
                    <ResourceDictionary.ThemeDictionaries>

                        <!--
                            These two values are "SolidBackgroundFillColorTertiary".
                            We can't just put those here though as
                            StaticResources, because XAML will evaluate their
                            values when the App is first loaded, and we'll
                            always use the value from the OS theme, regardless
                            of the requested theme. Kinda the same thing we've
                            had to do with TabViewBackground in the past.
                        -->

                        <ResourceDictionary x:Key="Dark">
                            <Color x:Key="SettingsPageBackground">#282828</Color>
                            <Color x:Key="SettingsPageMicaBackground">#00000000</Color>
                        </ResourceDictionary>

                        <ResourceDictionary x:Key="Light">
                            <Color x:Key="SettingsPageBackground">#F9F9F9</Color>
                            <Color x:Key="SettingsPageMicaBackground">#00000000</Color>
                        </ResourceDictionary>

                        <ResourceDictionary x:Key="HighContrast">
                            <!--  Define resources for HighContrast mode here  -->
                            <StaticResource x:Key="SettingsPageBackground"
                                            ResourceKey="SystemColorWindowColorBrush" />
                            <StaticResource x:Key="SettingsPageMicaBackground"
                                            ResourceKey="SystemColorWindowColorBrush" />
                        </ResourceDictionary>

                    </ResourceDictionary.ThemeDictionaries>
                </ResourceDictionary>

            </ResourceDictionary.MergedDictionaries>

            <SolidColorBrush x:Key="NavigationViewExpandedPaneBackground"
                             Color="Transparent" />
            <SolidColorBrush x:Key="NavigationViewContentBackground"
                             Color="Transparent" />

            <Thickness x:Key="NavigationViewContentGridBorderThickness">0</Thickness>
            <Thickness x:Key="NavigationViewMinimalContentGridBorderThickness">0</Thickness>

        </ResourceDictionary>
    </Page.Resources>

    <muxc:NavigationView x:Name="SettingsNav"
                         Background="{ThemeResource SettingsPageBackground}"
                         IsBackButtonVisible="Collapsed"
                         IsSettingsVisible="False"
                         ItemInvoked="SettingsNav_ItemInvoked"
                         Loaded="SettingsNav_Loaded"
                         TabFocusNavigation="Cycle">
        <muxc:NavigationView.Resources>
            <ResourceDictionary>
                <Thickness x:Key="NavigationViewHeaderMargin">15,0,0,0</Thickness>
            </ResourceDictionary>
        </muxc:NavigationView.Resources>
        <muxc:NavigationView.Header>
            <muxc:BreadcrumbBar x:Name="NavigationBreadcrumbBar"
                                MaxWidth="{StaticResource StandardControlMaxWidth}"
                                ItemClicked="BreadcrumbBar_ItemClicked"
                                ItemsSource="{x:Bind Breadcrumbs}">
                <muxc:BreadcrumbBar.ItemTemplate>
                    <DataTemplate x:DataType="local:Breadcrumb">
                        <TextBlock Text="{x:Bind Label}" />
                    </DataTemplate>
                </muxc:BreadcrumbBar.ItemTemplate>
                <muxc:BreadcrumbBar.Resources>
                    <ResourceDictionary>
                        <x:Double x:Key="BreadcrumbBarItemThemeFontSize">28</x:Double>
                        <Thickness x:Key="BreadcrumbBarChevronPadding">11,4,12,0</Thickness>
                        <FontWeight x:Key="BreadcrumbBarItemFontWeight">SemiBold</FontWeight>
                        <x:Double x:Key="BreadcrumbBarChevronFontSize">16</x:Double>
                    </ResourceDictionary>
                </muxc:BreadcrumbBar.Resources>
            </muxc:BreadcrumbBar>
        </muxc:NavigationView.Header>

        <muxc:NavigationView.MenuItems>

            <muxc:NavigationViewItem x:Uid="Nav_Launch"
                                     Tag="Launch_Nav">
                <muxc:NavigationViewItem.Icon>
                    <FontIcon Glyph="&#xE7B5;" />
                </muxc:NavigationViewItem.Icon>
            </muxc:NavigationViewItem>

            <muxc:NavigationViewItem x:Uid="Nav_Interaction"
                                     Tag="Interaction_Nav">
                <muxc:NavigationViewItem.Icon>
                    <FontIcon Glyph="&#xE7C9;" />
                </muxc:NavigationViewItem.Icon>
            </muxc:NavigationViewItem>

            <muxc:NavigationViewItem x:Uid="Nav_Appearance"
                                     Tag="GlobalAppearance_Nav">
                <muxc:NavigationViewItem.Icon>
                    <FontIcon Glyph="&#xE771;" />
                </muxc:NavigationViewItem.Icon>
            </muxc:NavigationViewItem>

            <muxc:NavigationViewItem x:Uid="Nav_ColorSchemes"
                                     Tag="ColorSchemes_Nav">
                <muxc:NavigationViewItem.Icon>
                    <FontIcon Glyph="&#xE790;" />
                </muxc:NavigationViewItem.Icon>
            </muxc:NavigationViewItem>

            <muxc:NavigationViewItem x:Uid="Nav_Rendering"
                                     Tag="Rendering_Nav">
                <muxc:NavigationViewItem.Icon>
                    <FontIcon Glyph="&#xE7F8;" />
                </muxc:NavigationViewItem.Icon>
            </muxc:NavigationViewItem>

            <muxc:NavigationViewItem x:Uid="Nav_Actions"
                                     Tag="Actions_Nav">
                <muxc:NavigationViewItem.Icon>
                    <FontIcon Glyph="&#xE765;" />
                </muxc:NavigationViewItem.Icon>
            </muxc:NavigationViewItem>

            <muxc:NavigationViewItemHeader x:Uid="Nav_Profiles" />

            <muxc:NavigationViewItem x:Name="BaseLayerMenuItem"
                                     x:Uid="Nav_ProfileDefaults"
                                     Tag="GlobalProfile_Nav">
                <muxc:NavigationViewItem.Icon>
                    <FontIcon Glyph="&#xE81E;" />
                </muxc:NavigationViewItem.Icon>
            </muxc:NavigationViewItem>

        </muxc:NavigationView.MenuItems>

        <muxc:NavigationView.FooterMenuItems>
            <!--  The OpenJson item needs both Tapped and KeyDown handler  -->
            <muxc:NavigationViewItem x:Name="OpenJsonNavItem"
                                     x:Uid="Nav_OpenJSON"
                                     KeyDown="OpenJsonKeyDown"
                                     Tapped="OpenJsonTapped">
                <muxc:NavigationViewItem.Icon>
                    <FontIcon Glyph="&#xE713;" />
                </muxc:NavigationViewItem.Icon>
            </muxc:NavigationViewItem>
        </muxc:NavigationView.FooterMenuItems>

        <Grid Margin="0,0,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Frame x:Name="contentFrame"
                   Grid.Row="0">
                <Frame.ContentTransitions>
                    <TransitionCollection>
                        <NavigationThemeTransition>
                            <NavigationThemeTransition.DefaultNavigationTransitionInfo>
                                <DrillInNavigationTransitionInfo />
                            </NavigationThemeTransition.DefaultNavigationTransitionInfo>
                        </NavigationThemeTransition>
                    </TransitionCollection>
                </Frame.ContentTransitions>
            </Frame>
            <!--  Explicitly set the background color on grid to prevent the navigation animation from overflowing it  -->
            <Grid Grid.Row="1"
                  Height="55"
                  BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
                  BorderThickness="0,1,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <StackPanel Margin="30,0,0,0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            Orientation="Vertical">
                    <TextBlock x:Uid="Settings_UnsavedSettingsWarning"
                               Foreground="Goldenrod"
                               TextAlignment="Left"
                               Visibility="Collapsed" />
                    <StackPanel VerticalAlignment="Center"
                                Orientation="Horizontal"
                                Spacing="4"
                                Visibility="{x:Bind tsm:CascadiaSettings.IsPortableMode, Mode=OneTime}">
                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}"
                                  Foreground="SlateBlue"
                                  Glyph="&#xE946;" />
                        <TextBlock Foreground="SlateBlue">
                            <Run x:Uid="Settings_PortableModeNote" />
                            <Hyperlink x:Uid="Settings_PortableModeInfoLink">
                                <Run x:Uid="Settings_PortableModeInfoLinkTextRun" />
                            </Hyperlink>
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel Margin="0,0,30,0"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Orientation="Horizontal">
                    <Button x:Name="SaveButton"
                            x:Uid="Settings_SaveSettingsButton"
                            Click="SaveButton_Click"
                            Style="{StaticResource AccentButtonStyle}" />
                    <Button x:Name="ResetButton"
                            x:Uid="Settings_ResetSettingsButton"
                            Margin="10,0,0,0"
                            Click="ResetButton_Click" />
                </StackPanel>
            </Grid>
        </Grid>
    </muxc:NavigationView>
</Page>
