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

Add "new" labels to navigation #36939

Merged
merged 13 commits into from
Jan 22, 2025
1 change: 1 addition & 0 deletions src/settings-ui/Settings.UI/SettingsXAML/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ResourceDictionary Source="/SettingsXAML/Controls/KeyVisual/KeyVisual.xaml" />
<ResourceDictionary Source="/SettingsXAML/Styles/TextBlock.xaml" />
<ResourceDictionary Source="/SettingsXAML/Styles/Button.xaml" />
<ResourceDictionary Source="/SettingsXAML/Styles/InfoBadge.xaml" />
<ResourceDictionary Source="/SettingsXAML/Themes/Colors.xaml" />
<ResourceDictionary Source="/SettingsXAML/Themes/Generic.xaml" />
<!-- Other merged dictionaries here -->
Expand Down
23 changes: 23 additions & 0 deletions src/settings-ui/Settings.UI/SettingsXAML/Styles/InfoBadge.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="NewInfoBadge" TargetType="InfoBadge">
<Setter Property="Padding" Value="5,1,5,2" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="InfoBadge">
<Border
x:Name="RootGrid"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.InfoBadgeCornerRadius}">
<TextBlock
x:Uid="SettingsPage_NewInfoBadge"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="10" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
39 changes: 29 additions & 10 deletions src/settings-ui/Settings.UI/SettingsXAML/Views/DashboardPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,28 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Width="20" Margin="0,0,0,0">
<Image
Grid.Column="0"
Width="20"
Margin="0,0,0,0">
<Image.Source>
<BitmapImage UriSource="{x:Bind Icon, Mode=OneWay}" />
</Image.Source>
</Image>
<TextBlock
<StackPanel
Grid.Column="1"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="{x:Bind Label, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="{x:Bind Label, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<InfoBadge
Margin="4,0,0,0"
Style="{StaticResource NewInfoBadge}"
Visibility="{x:Bind IsNew, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Copy link
Collaborator

@Jay-o-Way Jay-o-Way Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BoolToVisibilityConverter is embedded, so may be omitted :) Mode=OneWay may be removed too, this value is not going to change. (default for x:Bind is OneTime)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should prefer as explicit as possible :) Makes intent easier to read when going through the code if one doesn't know the defaults.

</StackPanel>
<FontIcon
Grid.Column="2"
Width="20"
Expand Down Expand Up @@ -440,17 +451,25 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Width="20">
<Image Grid.Column="0" Width="20">
<Image.Source>
<BitmapImage UriSource="{x:Bind Icon, Mode=OneWay}" />
</Image.Source>
</Image>
<TextBlock
<StackPanel
Grid.Column="1"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="{x:Bind Label, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="{x:Bind Label, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<InfoBadge
Margin="4,0,0,0"
Style="{StaticResource NewInfoBadge}"
Visibility="{x:Bind IsNew, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
</StackPanel>
<FontIcon
Grid.Column="2"
Width="20"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
x:Uid="Shell_TopLevelSystemTools"
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/SystemTools.png}"
SelectsOnInvoked="False">
<NavigationViewItem.InfoBadge>
<InfoBadge Style="{StaticResource NewInfoBadge}" />
</NavigationViewItem.InfoBadge>
<NavigationViewItem.MenuItems>
<NavigationViewItem
x:Uid="Shell_AdvancedPaste"
Expand Down Expand Up @@ -142,7 +145,11 @@
<NavigationViewItem
x:Uid="Shell_ZoomIt"
helpers:NavHelper.NavigateTo="views:ZoomItPage"
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ZoomIt.png}" />
Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/ZoomIt.png}">
<NavigationViewItem.InfoBadge>
<InfoBadge Style="{StaticResource NewInfoBadge}" />
</NavigationViewItem.InfoBadge>
</NavigationViewItem>
</NavigationViewItem.MenuItems>
</NavigationViewItem>

Expand Down
4 changes: 4 additions & 0 deletions src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -4880,4 +4880,8 @@ To record a specific window, enter the hotkey with the Alt key in the opposite m
<data name="PowerLauncher_PluginWebsite.Text" xml:space="preserve">
<value>Project website</value>
</data>
<data name="SettingsPage_NewInfoBadge.Text" xml:space="preserve">
<value>NEW</value>
<comment>Must be all caps</comment>
</data>
</root>
2 changes: 2 additions & 0 deletions src/settings-ui/Settings.UI/ViewModels/DashboardListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class DashboardListItem : INotifyPropertyChanged

public string Label { get; set; }

public bool IsNew { get; set; }

public string Icon { get; set; }

public string ToolTip { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private void AddDashboardListItem(ModuleType moduleType)
{
Tag = moduleType,
Label = resourceLoader.GetString(ModuleHelper.GetModuleLabelResourceName(moduleType)),
IsNew = moduleType == ModuleType.ZoomIt,
IsEnabled = gpo == GpoRuleConfigured.Enabled || (gpo != GpoRuleConfigured.Disabled && ModuleHelper.GetIsModuleEnabled(generalSettingsConfig, moduleType)),
IsLocked = gpo == GpoRuleConfigured.Enabled || gpo == GpoRuleConfigured.Disabled,
Icon = ModuleHelper.GetModuleTypeFluentIconName(moduleType),
Expand Down
Loading