Skip to content

Commit ed318ca

Browse files
authored
Feature: Improved contrast for selected items in the Grid View layout (#16743)
1 parent 6de2ff5 commit ed318ca

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

src/Files.App/Views/Layouts/GridLayoutPage.xaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@
436436
Padding="0"
437437
HorizontalAlignment="Left"
438438
VerticalAlignment="Stretch"
439-
Background="Transparent"
439+
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
440440
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
441441
BorderThickness="1"
442442
CornerRadius="8"
@@ -553,15 +553,15 @@
553553
x:Name="ItemName"
554554
MaxLines="{Binding ElementName=PageRoot, Path=CardsViewItemNameMaxLines, Mode=OneWay}"
555555
Opacity="{x:Bind Opacity, Mode=OneWay}"
556-
Style="{ThemeResource BodyStrongTextBlockStyle}"
556+
Style="{ThemeResource App.Theme.BodyStrongTextBlockStyle}"
557557
Text="{x:Bind Name, Mode=OneWay}"
558558
TextTrimming="CharacterEllipsis"
559559
TextWrapping="Wrap" />
560560

561561
<!-- Item Type -->
562562
<TextBlock
563563
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
564-
Style="{ThemeResource CaptionTextBlockStyle}"
564+
Style="{ThemeResource App.Theme.CaptionTextBlockStyle}"
565565
Text="{x:Bind ItemType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
566566
TextTrimming="CharacterEllipsis"
567567
TextWrapping="NoWrap" />
@@ -781,8 +781,9 @@
781781
</Setter>
782782
</Style>
783783

784+
<!-- Regular List Container Style -->
784785
<Style
785-
x:Name="DefaultItemContainerStyle"
786+
x:Name="LocalListItemContainerStyle"
786787
BasedOn="{StaticResource DefaultGridViewItemStyle}"
787788
TargetType="GridViewItem">
788789
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
@@ -849,8 +850,9 @@
849850
</Setter>
850851
</Style>
851852

853+
<!-- Compact List Container Style -->
852854
<Style
853-
x:Name="CompactListItemContainerStyle"
855+
x:Name="LocalCompactListItemContainerStyle"
854856
BasedOn="{StaticResource DefaultGridViewItemStyle}"
855857
TargetType="GridViewItem">
856858
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
@@ -918,11 +920,12 @@
918920
</Setter>
919921
</Style>
920922

923+
<!-- Regular Container Style -->
921924
<Style
922-
x:Name="CardsItemContainerStyle"
925+
x:Name="LocalRegularItemContainerStyle"
923926
BasedOn="{StaticResource DefaultGridViewItemStyle}"
924927
TargetType="GridViewItem">
925-
<Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
928+
<Setter Property="Background" Value="Transparent" />
926929
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
927930
<Setter Property="HorizontalAlignment" Value="Stretch" />
928931
<Setter Property="MinHeight" Value="1" />

src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public sealed partial class GridLayoutPage : BaseGroupableLayoutPage
135135
LayoutSettingsService.CardsViewSize != CardsViewSizeKind.Small;
136136

137137
/// <summary>
138-
/// Gets the icon size for item names in the Cards View layout.
138+
/// Gets the icon size for items in the Cards View layout.
139139
/// </summary>
140140
public int CardsViewIconSize =>
141141
(int)LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.CardsView);
@@ -247,8 +247,6 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang
247247
}
248248
if (e.PropertyName == nameof(ILayoutSettingsService.GridViewSize))
249249
{
250-
NotifyPropertyChanged(nameof(ItemWidthGridView));
251-
252250
// Update the container style to match the item size
253251
SetItemContainerStyle();
254252
FolderSettings_IconSizeChanged();
@@ -306,29 +304,32 @@ private void SetItemTemplate()
306304

307305
private void SetItemContainerStyle()
308306
{
309-
if (FolderSettings?.LayoutMode == FolderLayoutModes.CardsView)
307+
if (FolderSettings?.LayoutMode == FolderLayoutModes.CardsView || FolderSettings?.LayoutMode == FolderLayoutModes.GridView)
310308
{
311309
// Toggle style to force item size to update
312-
FileList.ItemContainerStyle = DefaultItemContainerStyle;
310+
FileList.ItemContainerStyle = LocalListItemContainerStyle;
313311

314312
// Set correct style
315-
FileList.ItemContainerStyle = CardsItemContainerStyle;
313+
FileList.ItemContainerStyle = LocalRegularItemContainerStyle;
316314
}
317-
else if (FolderSettings?.LayoutMode == FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact)
315+
else if (FolderSettings?.LayoutMode == FolderLayoutModes.ListView)
318316
{
319-
// Toggle style to force item size to update
320-
FileList.ItemContainerStyle = DefaultItemContainerStyle;
317+
if (UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact)
318+
{
319+
// Toggle style to force item size to update
320+
FileList.ItemContainerStyle = LocalRegularItemContainerStyle;
321321

322-
// Set correct style
323-
FileList.ItemContainerStyle = CompactListItemContainerStyle;
324-
}
325-
else
326-
{
327-
// Toggle style to force item size to update
328-
FileList.ItemContainerStyle = CompactListItemContainerStyle;
322+
// Set correct style
323+
FileList.ItemContainerStyle = LocalCompactListItemContainerStyle;
324+
}
325+
else
326+
{
327+
// Toggle style to force item size to update
328+
FileList.ItemContainerStyle = LocalCompactListItemContainerStyle;
329329

330-
// Set correct style
331-
FileList.ItemContainerStyle = DefaultItemContainerStyle;
330+
// Set correct style
331+
FileList.ItemContainerStyle = LocalRegularItemContainerStyle;
332+
}
332333
}
333334
}
334335

0 commit comments

Comments
 (0)