Skip to content

Compact spacing for the details layout #8751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ public interface IAppearanceSettingsService : IBaseSettingsService, INotifyPrope
/// Gets or sets a value indicating whether or not recycle bin should be pinned to the sidebar.
/// </summary>
bool PinRecycleBinToSidebar { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to use the compact styles.
/// </summary>
bool UseCompactStyles { get; set; }
}
}
2 changes: 2 additions & 0 deletions src/Files.Uwp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<FontFamily x:Key="RecycleBinIcons">/Assets/Custom Glyphs/recyclebin-fabric-glyph.ttf#Fabric MDL2 Assets</FontFamily>
<FontFamily x:Key="ColoredIconFontFamily">/Assets/Custom Glyphs/Colored-Icons.ttf#Untitled1</FontFamily>

<!-- Default list view item height -->
<x:Double x:Key="ListItemHeight">36</x:Double>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" ControlsResourcesVersion="Version2" />
<ResourceDictionary>
Expand Down
3 changes: 3 additions & 0 deletions src/Files.Uwp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
using Files.Shared.Extensions;
using Files.Backend.Services;
using Files.Uwp.ServicesImplementation;
using Files.ViewModels.SettingsViewModels;

namespace Files
{
Expand All @@ -57,6 +58,7 @@ sealed partial class App : Application
public static JumpListManager JumpList { get; private set; }
public static SidebarPinnedController SidebarPinnedController { get; private set; }
public static TerminalController TerminalController { get; private set; }
public static AppearanceViewModel AppearanceViewModel { get; private set; }
public static CloudDrivesManager CloudDrivesManager { get; private set; }
public static NetworkDrivesManager NetworkDrivesManager { get; private set; }
public static DrivesManager DrivesManager { get; private set; }
Expand Down Expand Up @@ -150,6 +152,7 @@ private static async Task EnsureSettingsAndConfigurationAreBootstrapped()
FileTagsManager ??= new FileTagsManager();
SidebarPinnedController ??= new SidebarPinnedController();
TerminalController ??= new TerminalController();
AppearanceViewModel ??= new AppearanceViewModel();
}

private static async Task StartAppCenter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public bool MoveOverflowMenuItemsToSubMenu
set => Set(value);
}

public bool UseCompactStyles
{
get => Get(false);
set => Set(value);
}

protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
Expand All @@ -92,6 +98,7 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(ShowWslSection):
case nameof(ShowFileTagsSection):
case nameof(PinRecycleBinToSidebar):
case nameof(UseCompactStyles):
Analytics.TrackEvent($"{e.SettingName} {e.NewValue}");
break;
}
Expand All @@ -109,6 +116,7 @@ public void ReportToAppCenter()
Analytics.TrackEvent($"{nameof(ShowWslSection)}, {ShowWslSection}");
Analytics.TrackEvent($"{nameof(ShowFileTagsSection)}, {ShowFileTagsSection}");
Analytics.TrackEvent($"{nameof(PinRecycleBinToSidebar)}, {PinRecycleBinToSidebar}");
Analytics.TrackEvent($"{nameof(UseCompactStyles)}, {UseCompactStyles}");
}
}
}
3 changes: 3 additions & 0 deletions src/Files.Uwp/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2750,4 +2750,7 @@ We use App Center to track which settings are being used, find bugs, and fix cra
<data name="SettingsShowFileTagsSectionSwitch.AutomationProperties.Name" xml:space="preserve">
<value>Show Tags section</value>
</data>
<data name="UseCompactStyles" xml:space="preserve">
<value>Use compact styles in the details layout</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/Files.Uwp/UserControls/Widgets/RecentFilesWidget.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
ItemContainerTransitions="{x:Null}"
ItemsSource="{x:Bind recentItemsCollection}"
SelectionMode="None">
<ListView.ItemContainerStyle>
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="ListViewItem">
<Setter Property="MinHeight" Value="1" />
<Setter Property="Height" Value="{ThemeResource ListItemHeight}" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:RecentItem">
<Grid
Expand Down
36 changes: 36 additions & 0 deletions src/Files.Uwp/ViewModels/SettingsViewModels/AppearanceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ public AppearanceViewModel()
"LightTheme".GetLocalized(),
"DarkTheme".GetLocalized()
};

SetCompactStyles();
}

/// <summary>
/// Forces the application to use the correct styles if compact mode is turned on
/// </summary>
private void SetCompactStyles()
{
if (UseCompactStyles)
{
Application.Current.Resources["ListItemHeight"] = 28;
}
else
{
Application.Current.Resources["ListItemHeight"] = 36;
}

UpdateTheme();
}

public List<string> Themes { get; set; }
Expand Down Expand Up @@ -134,6 +153,23 @@ public bool PinRecycleBinToSideBar
}
}

public bool UseCompactStyles
{
get => UserSettingsService.AppearanceSettingsService.UseCompactStyles;
set
{
if (value != UserSettingsService.AppearanceSettingsService.UseCompactStyles)
{
UserSettingsService.AppearanceSettingsService.UseCompactStyles = value;

//Apply the correct styles
SetCompactStyles();

OnPropertyChanged();
}
}
}

public bool ShowLibrarySection
{
get => UserSettingsService.AppearanceSettingsService.ShowLibrarySection;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.Uwp/Views/LayoutModes/ColumnViewBase.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@
<ListView.ItemContainerStyle>
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Height" Value="36" />
<Setter Property="MinHeight" Value="1" />
<Setter Property="Height" Value="{ThemeResource ListItemHeight}" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
Expand Down
2 changes: 1 addition & 1 deletion src/Files.Uwp/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="MinHeight" Value="1" />
<Setter Property="Height" Value="36" />
<Setter Property="Height" Value="{ThemeResource ListItemHeight}" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected override void HookEvents()
private void ItemManipulationModel_ScrollIntoViewInvoked(object sender, ListedItem e)
{
FileList.ScrollIntoView(e);
ContentScroller?.ChangeView(null, FileList.Items.IndexOf(e) * 36, null, true); // Scroll to index * item height
ContentScroller?.ChangeView(null, FileList.Items.IndexOf(e) * Convert.ToInt32(Application.Current.Resources["ListItemHeight"]), null, true); // Scroll to index * item height
}

private void ItemManipulationModel_StartRenameItemInvoked(object sender, EventArgs e)
Expand Down
12 changes: 12 additions & 0 deletions src/Files.Uwp/Views/SettingsPages/Appearance.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Files.Helpers"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:icore="using:Microsoft.Xaml.Interactions.Core"
xmlns:local="using:Files.UserControls.Settings"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
Expand Down Expand Up @@ -203,6 +205,16 @@
</local:SettingsBlockControl.ExpandableContent>
</local:SettingsBlockControl>

<local:SettingsBlockControl Title="{helpers:ResourceString Name=UseCompactStyles}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE14C;" />
</local:SettingsBlockControl.Icon>
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=UseCompactStyles}"
IsOn="{Binding UseCompactStyles, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<TextBlock
x:Uid="SettingsContextMenu"
Padding="0,12,0,4"
Expand Down