﻿<!--  Copyright (c) 2023 Files Community. Licensed under the MIT License. See the LICENSE.  -->
<Page
	x:Class="Files.App.Views.Settings.FoldersPage"
	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:helpers="using:Files.App.Helpers"
	xmlns:local="using:Files.App.UserControls.Settings"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:vm="using:Files.App.ViewModels.Settings"
	mc:Ignorable="d">

	<Page.Resources>
		<ResourceDictionary Source="/ResourceDictionaries/RightAlignedToggleSwitchStyle.xaml" />
	</Page.Resources>

	<Page.DataContext>
		<vm:FoldersViewModel x:Name="ViewModel" />
	</Page.DataContext>

	<Grid>
		<StackPanel
			HorizontalAlignment="Stretch"
			VerticalAlignment="Stretch"
			Spacing="4">
			<StackPanel.ChildrenTransitions>
				<TransitionCollection>
					<EntranceThemeTransition />
				</TransitionCollection>
			</StackPanel.ChildrenTransitions>

			<!--  Title  -->
			<TextBlock
				Padding="0,0,0,12"
				FontSize="24"
				FontWeight="Medium"
				Text="{helpers:ResourceString Name=Folders}" />

			<!--  Folder Overrides  -->
			<local:SettingsBlockControl
				Title="{helpers:ResourceString Name=SyncFolderPreferencesAcrossDirectories}"
				HorizontalAlignment="Stretch"
				IsExpanded="True">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE621;" />
				</local:SettingsBlockControl.Icon>

				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=SyncFolderPreferencesAcrossDirectories}"
					IsOn="{x:Bind ViewModel.SyncFolderPreferencesAcrossDirectories, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
			</local:SettingsBlockControl>

			<!--  Details layout columns  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=DetailsLayoutColumns}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE71D;" />
				</local:SettingsBlockControl.Icon>
				<local:SettingsBlockControl.ExpandableContent>
					<StackPanel>
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=TagColumn}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=TagColumn}"
								IsOn="{x:Bind ViewModel.ShowFileTagColumn, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=SizeColumn}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=SizeColumn}"
								IsOn="{x:Bind ViewModel.ShowSizeColumn, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=TypeColumn}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=TypeColumn}"
								IsOn="{x:Bind ViewModel.ShowTypeColumn, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=DateColumn}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=DateColumn}"
								IsOn="{x:Bind ViewModel.ShowDateColumn, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=DateCreatedColumn}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=DateCreatedColumn}"
								IsOn="{x:Bind ViewModel.ShowDateCreatedColumn, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>
					</StackPanel>
				</local:SettingsBlockControl.ExpandableContent>
			</local:SettingsBlockControl>

			<!--  Default sorting and grouping options  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=SortingAndGrouping}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE8CB;" />
				</local:SettingsBlockControl.Icon>
				<local:SettingsBlockControl.ExpandableContent>
					<StackPanel>
						<!--  Sorting Options  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=SortBy}" HorizontalAlignment="Stretch">
							<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=SortBy}" SelectedIndex="{x:Bind ViewModel.SelectedDefaultSortingIndex, Mode=TwoWay}">
								<ComboBoxItem Content="{helpers:ResourceString Name=Name}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=DateModifiedLowerCase}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=DateCreated}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Size}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Type}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Tag}" />
							</ComboBox>
						</local:SettingsBlockControl>

						<!--  Sort in Descending order  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=SortInDescendingOrder}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=SortInDescendingOrder}"
								IsOn="{x:Bind ViewModel.SortInDescendingOrder, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>

						<!--  Grouping Options  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=GroupBy}" HorizontalAlignment="Stretch">
							<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=GroupBy}" SelectedIndex="{x:Bind ViewModel.SelectedDefaultGroupingIndex, Mode=TwoWay}">
								<ComboBoxItem Content="{helpers:ResourceString Name=None}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Name}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=DateModifiedLowerCase}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=DateCreated}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Size}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Type}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Tag}" />
							</ComboBox>
						</local:SettingsBlockControl>

						<!--  Group in Descending order  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=GroupInDescendingOrder}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=GroupInDescendingOrder}"
								IsEnabled="{x:Bind ViewModel.IsDefaultGrouped, Mode=OneWay}"
								IsOn="{x:Bind ViewModel.GroupInDescendingOrder, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>

						<!--  Group by date unit  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=GroupByDateUnit}" HorizontalAlignment="Stretch">
							<ComboBox
								AutomationProperties.Name="{helpers:ResourceString Name=GroupByDateUnit}"
								IsEnabled="{x:Bind ViewModel.IsGroupByDate, Mode=OneWay}"
								SelectedIndex="{x:Bind ViewModel.SelectedDefaultGroupByDateUnitIndex, Mode=TwoWay}">
								<ComboBoxItem Content="{helpers:ResourceString Name=Year}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Month}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=Day}" />
							</ComboBox>
						</local:SettingsBlockControl>

						<!--  Sort Priority  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=SortPriority}" HorizontalAlignment="Stretch">
							<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=SortPriority}" SelectedIndex="{x:Bind ViewModel.SelectedDefaultSortPriorityIndex, Mode=TwoWay}">
								<ComboBoxItem Content="{helpers:ResourceString Name=SortFoldersFirst}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=SortFilesFirst}" />
								<ComboBoxItem Content="{helpers:ResourceString Name=SortFilesAndFoldersTogether}" />
							</ComboBox>
						</local:SettingsBlockControl>
					</StackPanel>
				</local:SettingsBlockControl.ExpandableContent>
			</local:SettingsBlockControl>

			<!--  Layout mode  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=LayoutMode}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE8A9;" />
				</local:SettingsBlockControl.Icon>

				<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=LayoutMode}" SelectedIndex="{x:Bind ViewModel.SelectedDefaultLayoutModeIndex, Mode=TwoWay}">
					<ComboBoxItem Content="{helpers:ResourceString Name=Details}" />
					<ComboBoxItem Content="{helpers:ResourceString Name=Tiles}" />
					<ComboBoxItem Content="{helpers:ResourceString Name=Columns}" />
					<ComboBoxItem Content="{helpers:ResourceString Name=IconGrid}" />
					<ComboBoxItem Content="{helpers:ResourceString Name=Adaptive}" />
				</ComboBox>
			</local:SettingsBlockControl>


			<!--  Display  -->
			<TextBlock
				Padding="0,16,0,4"
				FontSize="16"
				FontWeight="Medium"
				Text="{helpers:ResourceString Name=Display}" />

			<!--  Hidden Items  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=HiddenItems}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xED1A;" />
				</local:SettingsBlockControl.Icon>
				<local:SettingsBlockControl.ExpandableContent>
					<StackPanel>
						<!--  Hidden Files  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=SettingsFilesAndFoldersShowHiddenItems}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=SettingsFilesAndFoldersShowHiddenItems}"
								IsOn="{x:Bind ViewModel.ShowHiddenItems, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>

						<!--  Dots Files  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowDotFiles}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=ShowDotFiles}"
								IsOn="{x:Bind ViewModel.ShowDotFiles, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>

						<!--  System Files  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowProtectedSystemFiles}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=ShowProtectedSystemFiles}"
								IsOn="{x:Bind ViewModel.ShowProtectedSystemFiles, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>

						<!--  Alternate Data Streams  -->
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowAlternateStreams}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=ShowAlternateStreams}"
								IsOn="{x:Bind ViewModel.AreAlternateStreamsVisible, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>
					</StackPanel>
				</local:SettingsBlockControl.ExpandableContent>
			</local:SettingsBlockControl>

			<!--  File Extensions  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=SettingsFilesAndFoldersShowFileExtensions}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE8F9;" />
				</local:SettingsBlockControl.Icon>
				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=SettingsFilesAndFoldersShowFileExtensions}"
					IsOn="{x:Bind ViewModel.ShowFileExtensions, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
			</local:SettingsBlockControl>

			<!--  Show Thumbnails  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=SettingsFilesAndFoldersShowThumbnails}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE91B;" />
				</local:SettingsBlockControl.Icon>
				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=SettingsFilesAndFoldersShowThumbnails}"
					IsOn="{x:Bind ViewModel.ShowThumbnails, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
			</local:SettingsBlockControl>

			<!--  Show Checkboxes When Selecting Items  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowCheckboxesWhenSelectingItems}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE73A;" />
				</local:SettingsBlockControl.Icon>
				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=ShowCheckboxesWhenSelectingItems}"
					IsOn="{x:Bind ViewModel.ShowCheckboxesWhenSelectingItems, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
			</local:SettingsBlockControl>

			<!--  Behaviors  -->
			<TextBlock
				Padding="0,16,0,4"
				FontSize="16"
				FontWeight="Medium"
				Text="{helpers:ResourceString Name=Behaviors}" />

			<!--  Opening items  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=OpeningItems}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xED25;" />
				</local:SettingsBlockControl.Icon>
				<local:SettingsBlockControl.ExpandableContent>
					<StackPanel>
						<local:SettingsBlockControl Title="{helpers:ResourceString Name=SettingsOpenItemsWithOneClick}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=SettingsOpenItemsWithOneClick}"
								IsOn="{x:Bind ViewModel.OpenItemsWithOneClick, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>

						<local:SettingsBlockControl Title="{helpers:ResourceString Name=OpenFolderWithOneClickColumnsLayout}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								AutomationProperties.Name="{helpers:ResourceString Name=OpenFolderWithOneClickColumnsLayout}"
								IsOn="{x:Bind ViewModel.ColumnLayoutOpenFoldersWithOneClick, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>

						<local:SettingsBlockControl Title="{helpers:ResourceString Name=OpenFoldersInNewTab}" HorizontalAlignment="Stretch">
							<ToggleSwitch
								x:Name="OpenFoldersNewTab"
								AutomationProperties.Name="{helpers:ResourceString Name=OpenFoldersInNewTab}"
								IsOn="{x:Bind ViewModel.OpenFoldersNewTab, Mode=TwoWay}"
								Style="{StaticResource RightAlignedToggleSwitchStyle}" />
						</local:SettingsBlockControl>
					</StackPanel>
				</local:SettingsBlockControl.ExpandableContent>
			</local:SettingsBlockControl>

			<!--  Confirm Delete  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowConfirmationWhenDeletingItems}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE74D;" />
				</local:SettingsBlockControl.Icon>

				<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=ShowConfirmationWhenDeletingItems}" SelectedIndex="{x:Bind ViewModel.SelectedDeleteConfirmationPolicyIndex, Mode=TwoWay}">
					<ComboBoxItem Content="{helpers:ResourceString Name=Always}" />
					<ComboBoxItem Content="{helpers:ResourceString Name=PermanentDeletionOnly}" />
					<ComboBoxItem Content="{helpers:ResourceString Name=Never}" />
				</ComboBox>
			</local:SettingsBlockControl>

			<!--  File Extension Warning  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowFileExtensionWarning}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE8AC;" />
				</local:SettingsBlockControl.Icon>

				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=ShowFileExtensionWarning}"
					IsOn="{x:Bind ViewModel.ShowFileExtensionWarning, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
			</local:SettingsBlockControl>

			<!--  Select On Hover  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=SelectFilesAndFoldersOnHover}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE8B3;" />
				</local:SettingsBlockControl.Icon>

				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=SelectFilesAndFoldersOnHover}"
					IsOn="{x:Bind ViewModel.SelectFilesOnHover, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
			</local:SettingsBlockControl>

			<!--  Double click to go up  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=DoubleClickBlankSpaceToGoUp}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xE8B0;" />
				</local:SettingsBlockControl.Icon>

				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=DoubleClickBlankSpaceToGoUp}"
					IsOn="{x:Bind ViewModel.DoubleClickToGoUp, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
			</local:SettingsBlockControl>

			<!--  Scroll to parent folder when navigating up  -->
			<local:SettingsBlockControl Title="{helpers:ResourceString Name=ScrollToParentFolderWhenNavigatingUp}" HorizontalAlignment="Stretch">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xECE7;" />
				</local:SettingsBlockControl.Icon>

				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=ScrollToParentFolderWhenNavigatingUp}"
					IsOn="{x:Bind ViewModel.ScrollToParentFolderWhenNavigatingUp, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
			</local:SettingsBlockControl>

			<!--  Calculate folder sizes  -->
			<local:SettingsBlockControl
				Title="{helpers:ResourceString Name=CalculateFolderSizes}"
				HorizontalAlignment="Stretch"
				IsExpanded="True">
				<local:SettingsBlockControl.Icon>
					<FontIcon Glyph="&#xEE40;" />
				</local:SettingsBlockControl.Icon>
				<ToggleSwitch
					AutomationProperties.Name="{helpers:ResourceString Name=CalculateFolderSizes}"
					IsOn="{x:Bind ViewModel.CalculateFolderSizes, Mode=TwoWay}"
					Style="{StaticResource RightAlignedToggleSwitchStyle}" />
				<local:SettingsBlockControl.ExpandableContent>
					<InfoBar
						CornerRadius="0,0,2,2"
						IsClosable="False"
						IsIconVisible="True"
						IsOpen="True"
						Message="{helpers:ResourceString Name=ShowFolderSizesWarning}"
						Severity="Warning" />
				</local:SettingsBlockControl.ExpandableContent>
			</local:SettingsBlockControl>
		</StackPanel>
	</Grid>
</Page>
