Skip to content
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

Code Quality: Replaced BoolToVisibilityConverter with implicit conversion expression #16723

Merged
merged 4 commits into from
Jan 28, 2025
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
1 change: 0 additions & 1 deletion src/Files.App/Styles/StatusCenterStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
SuccessfulForegroundBrush="{ThemeResource SystemFillColorSuccessBrush}" />

<wctconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
<wctconverters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<wctconverters:BoolToObjectConverter
x:Key="NegateBoolToVisibilityConverter"
FalseValue="Visible"
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/UserControls/StatusCenter/StatusCenter.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
Grid.Row="1"
Margin="0,8,0,8"
ColumnSpacing="4"
Visibility="{x:Bind IsInProgress, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
Visibility="{x:Bind IsInProgress, Mode=OneWay}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
Expand Down Expand Up @@ -233,7 +233,7 @@
BorderBrush="{ThemeResource ControlStrongStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="4"
Visibility="{x:Bind IsExpanded, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
Visibility="{x:Bind IsExpanded, Mode=OneWay}">

<Grid Padding="-2,-2,-2,-2">
<local:SpeedGraph Points="{x:Bind SpeedGraphValues, Mode=OneWay}" />
Expand Down Expand Up @@ -284,7 +284,7 @@
Visibility="{x:Bind IsExpanded, Converter={StaticResource NegateBoolToVisibilityConverter}, Mode=OneWay}" />

<!-- Detailed Info (Displayed When Graph Expanded) -->
<StackPanel Spacing="2" Visibility="{x:Bind IsExpanded, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<StackPanel Spacing="2" Visibility="{x:Bind IsExpanded, Mode=OneWay}">

<TextBlock
x:Name="StatusCenterItemCurrentProcessingItemNameTextBlock"
Expand Down Expand Up @@ -329,7 +329,7 @@
DataContext="{x:Bind}"
IsEnabled="{x:Bind IsCancelable, Mode=OneWay}"
ToolTipService.ToolTip="{helpers:ResourceString Name=Cancel}"
Visibility="{x:Bind IsInProgress, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
Visibility="{x:Bind IsInProgress, Mode=OneWay}">
<Button.Content>
<FontIcon FontSize="16" Glyph="&#xE711;" />
</Button.Content>
Expand Down
4 changes: 1 addition & 3 deletions src/Files.App/UserControls/TabBar/TabBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>

<wctconverters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />

</ResourceDictionary>
</local:BaseTabBar.Resources>

Expand Down Expand Up @@ -106,7 +104,7 @@
Background="Transparent"
BorderThickness="0"
ToolTipService.ToolTip="{helpers:ResourceString Name=TabActions}"
Visibility="{x:Bind ShowTabActionsButton, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
Visibility="{x:Bind ShowTabActionsButton, Mode=OneWay}">

<controls:ThemedIcon
Width="16"
Expand Down
14 changes: 5 additions & 9 deletions src/Files.App/Views/Layouts/ColumnLayoutPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright (c) Files Community. Licensed under the MIT License. -->
<!-- Copyright (c) Files Community. Licensed under the MIT License. -->
<local:BaseGroupableLayoutPage
x:Class="Files.App.Views.Layouts.ColumnLayoutPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Expand Down Expand Up @@ -27,10 +27,6 @@
x:Key="NegatedBoolToVisibilityConverter"
FalseValue="Visible"
TrueValue="Collapsed" />
<wctconverters:BoolToVisibilityConverter
x:Key="BoolToVisibilityConverter"
FalseValue="Collapsed"
TrueValue="Visible" />
<wctconverters:EmptyObjectToObjectConverter
x:Key="EmptyObjectToObjectConverter"
EmptyValue="Collapsed"
Expand Down Expand Up @@ -383,15 +379,15 @@
FontSize="14"
Style="{StaticResource SubheaderTextBlockStyle}"
Text="{x:Bind Model.Subtext, Mode=OneWay}"
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay}" />

</StackPanel>

<TextBlock
Margin="0,2,0,0"
Style="{StaticResource App.Theme.BodyTextBlockStyle}"
Text="{x:Bind Model.CountText, Mode=OneWay}"
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay}" />

</StackPanel>
</DataTemplate>
Expand Down Expand Up @@ -460,15 +456,15 @@
Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
Style="{StaticResource SubheaderTextBlockStyle}"
Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Subtext, Mode=OneWay}"
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay}" />

</StackPanel>

<TextBlock
Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
Style="{StaticResource App.Theme.BodyTextBlockStyle}"
Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}"
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay}" />

</StackPanel>

Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/Views/Layouts/DetailsLayoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1416,14 +1416,14 @@
FontSize="14"
Style="{StaticResource SubheaderTextBlockStyle}"
Text="{x:Bind Model.Subtext, Mode=OneWay}"
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay}" />
</StackPanel>

<TextBlock
Margin="0,2,0,0"
Style="{StaticResource App.Theme.BodyTextBlockStyle}"
Text="{x:Bind Model.CountText, Mode=OneWay}"
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay}" />

</StackPanel>
</DataTemplate>
Expand Down Expand Up @@ -1492,13 +1492,13 @@
Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
Style="{StaticResource SubheaderTextBlockStyle}"
Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Subtext, Mode=OneWay}"
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay}" />
</StackPanel>
<TextBlock
Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
Style="{StaticResource App.Theme.BodyTextBlockStyle}"
Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}"
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay}" />
</StackPanel>
</StackPanel>
</DataTemplate>
Expand Down
12 changes: 4 additions & 8 deletions src/Files.App/Views/Layouts/GridLayoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@
x:Key="NegatedBoolToOpacityConverter"
FalseValue="1"
TrueValue="0" />
<wctconverters:BoolToVisibilityConverter
x:Key="BoolToVisibilityConverter"
FalseValue="Collapsed"
TrueValue="Visible" />
<converters:BoolToSelectionModeConverter x:Key="BoolToSelectionModeConverter" />

<!-- Grid View -->
Expand Down Expand Up @@ -1076,14 +1072,14 @@
FontSize="14"
Style="{StaticResource SubheaderTextBlockStyle}"
Text="{x:Bind Model.Subtext, Mode=OneWay}"
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay}" />

<TextBlock
Grid.Row="1"
Grid.ColumnSpan="3"
Style="{StaticResource App.Theme.BodyTextBlockStyle}"
Text="{x:Bind Model.CountText, Mode=OneWay}"
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind Model.ShowCountTextBelow, Mode=OneWay}" />

</Grid>
</DataTemplate>
Expand Down Expand Up @@ -1165,7 +1161,7 @@
Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
Style="{StaticResource SubheaderTextBlockStyle}"
Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Subtext, Mode=OneWay}"
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay}" />

<TextBlock
Grid.Row="1"
Expand All @@ -1174,7 +1170,7 @@
Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
Style="{StaticResource App.Theme.BodyTextBlockStyle}"
Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}"
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay}" />

</Grid>
</DataTemplate>
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Properties/LibraryPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<ColumnDefinition Width="36" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<FontIcon Glyph="&#xE73E;" Visibility="{x:Bind IsDefault, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
<FontIcon Glyph="&#xE73E;" Visibility="{x:Bind IsDefault, Mode=OneWay}" />
<TextBlock
Grid.Column="2"
Margin="0,0,0,2"
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Views/Properties/MainPropertiesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
</ResourceDictionary.MergedDictionaries>

<wctconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
<wctconverters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<wctconverters:BoolToVisibilityConverter
x:Key="BoolToVisibilityInverseConverter"
FalseValue="Visible"
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Views/Shells/ColumnShellPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<local:BaseShellPage.Resources>
<ResourceDictionary>
<wctconverters:BoolToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<wctconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
</ResourceDictionary>
</local:BaseShellPage.Resources>
Expand Down