[Settings] Using SettingsControls (#1964)

* Adding SettingsControls package

* Using new SettingsControls

* Tweaks

* Version bump

* Replacing Button with HyperlinkButton per design spec

* Update Settings.xaml

* Fix top spacing
This commit is contained in:
Niels Laute 2023-03-16 11:06:40 +01:00 committed by GitHub
commit 47f314bb10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 123 additions and 184 deletions

View file

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<packageSources> <packageSources>
<clear /> <clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="Toolkit Labs" value="https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json" />
</packageSources> </packageSources>
<disabledPackageSources> <disabledPackageSources>
<clear /> <clear />

View file

@ -791,6 +791,9 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.Labs.Uwp.SettingsControls">
<Version>0.0.16</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform"> <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.14</Version> <Version>6.2.14</Version>
</PackageReference> </PackageReference>

View file

@ -4706,11 +4706,11 @@
<value>Appearance</value> <value>Appearance</value>
<comment>Subtitle of appearance setting on Settings page</comment> <comment>Subtitle of appearance setting on Settings page</comment>
</data> </data>
<data name="SettingsAppThemeTitle.Text" xml:space="preserve"> <data name="AppThemeExpander.Header" xml:space="preserve">
<value>App theme</value> <value>App theme</value>
<comment>Title of App theme expander</comment> <comment>Title of App theme expander</comment>
</data> </data>
<data name="SettingsAppThemeDescription.Text" xml:space="preserve"> <data name="AppThemeExpander.Description" xml:space="preserve">
<value>Select which app theme to display</value> <value>Select which app theme to display</value>
<comment>Description of App theme expander</comment> <comment>Description of App theme expander</comment>
</data> </data>

View file

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation" xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:labs="using:CommunityToolkit.Labs.WinUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
Loaded="OnLoaded" Loaded="OnLoaded"
@ -13,7 +14,7 @@
<ResourceDictionary> <ResourceDictionary>
<Style x:Key="SettingsContentScrollViewStyle" TargetType="ScrollViewer"> <Style x:Key="SettingsContentScrollViewStyle" TargetType="ScrollViewer">
<Setter Property="HorizontalAlignment" Value="Stretch"/> <Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Top"/> <Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/> <Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="HorizontalScrollMode" Value="Disabled"/> <Setter Property="HorizontalScrollMode" Value="Disabled"/>
<Setter Property="IsHorizontalRailEnabled" Value="False"/> <Setter Property="IsHorizontalRailEnabled" Value="False"/>
@ -30,11 +31,19 @@
<Setter Property="TextWrapping" Value="Wrap"/> <Setter Property="TextWrapping" Value="Wrap"/>
</Style> </Style>
<Style x:Key="SettingsCategoryTitleTextBlockStyle"
BasedOn="{StaticResource BodyStrongTextBlockStyle}"
TargetType="TextBlock">
<Setter Property="Margin" Value="0,29,0,5"/>
</Style>
<automation:NarratorNotifier x:Name="NarratorNotifier"/> <automation:NarratorNotifier x:Name="NarratorNotifier"/>
<!-- Override default hyperlink button background color --> <!-- Override default hyperlink button background color -->
<StaticResource x:Key="HyperlinkButtonBackgroundPointerOver" ResourceKey="SubtleFillColorTransparentBrush"/> <StaticResource x:Key="HyperlinkButtonBackgroundPointerOver" ResourceKey="SubtleFillColorTransparentBrush"/>
<StaticResource x:Key="HyperlinkButtonBackgroundPressed" ResourceKey="SubtleFillColorTransparentBrush"/> <StaticResource x:Key="HyperlinkButtonBackgroundPressed" ResourceKey="SubtleFillColorTransparentBrush"/>
<x:Double x:Key="SettingsCardSpacing">3</x:Double>
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
@ -43,42 +52,6 @@
<RowDefinition Height="{x:Bind TitleBarHeight, Mode=OneWay}"/> <RowDefinition Height="{x:Bind TitleBarHeight, Mode=OneWay}"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="LargeWideView">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="0" MinWindowWidth="690"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ColumnAbout.Width" Value="324"/>
<Setter Target="AboutContentGrid.(Grid.Row)" Value="0"/>
<Setter Target="AboutContentGrid.(Grid.RowSpan)" Value="3"/>
<Setter Target="AboutContentGrid.(Grid.Column)" Value="1"/>
<Setter Target="AboutGroupTitle.Margin" Value="0"/>
<Setter Target="AboutContentGrid.Margin" Value="60,0,0,0"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="SideVisible">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="0" MinWindowWidth="632"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ColumnMain.Width" Value="*"/>
<Setter Target="ColumnAbout.Width" Value="*"/>
<Setter Target="AboutContentGrid.(Grid.Row)" Value="0"/>
<Setter Target="AboutContentGrid.(Grid.RowSpan)" Value="3"/>
<Setter Target="AboutContentGrid.(Grid.Column)" Value="1"/>
<Setter Target="AboutGroupTitle.Margin" Value="0"/>
<Setter Target="AboutContentGrid.Margin" Value="60,0,0,0"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="DefaultLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="0" MinWindowWidth="0"/>
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Button x:Name="BackButton" <Button x:Name="BackButton"
x:Uid="TitleBarBackButton" x:Uid="TitleBarBackButton"
@ -103,62 +76,28 @@
</Grid> </Grid>
<ScrollViewer Grid.Row="1" <ScrollViewer Grid.Row="1"
Margin="0,60,0,0" Margin="0,30,0,0"
Padding="24,0,24,16" Padding="24,0,24,16"
Style="{StaticResource SettingsContentScrollViewStyle}"> Style="{StaticResource SettingsContentScrollViewStyle}">
<Grid x:Name="ContentGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnMain" Width="*"/>
<ColumnDefinition x:Name="ColumnAbout" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="AppearanceTitleRow" Height="Auto"/>
<RowDefinition x:Name="AppearanceExpanderRow" Height="Auto"/>
<RowDefinition x:Name="AboutTitleContentRow" Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Spacing="{StaticResource SettingsCardSpacing}">
<StackPanel.ChildrenTransitions>
<EntranceThemeTransition FromVerticalOffset="50" IsStaggeringEnabled="True"/>
<RepositionThemeTransition IsStaggeringEnabled="False"/>
</StackPanel.ChildrenTransitions>
<TextBlock x:Uid="SettingsAppearance" <TextBlock x:Uid="SettingsAppearance"
Style="{StaticResource BodyStrongTextBlockStyle}" Style="{StaticResource SettingsCategoryTitleTextBlockStyle}"
AutomationProperties.HeadingLevel="Level1"/> AutomationProperties.HeadingLevel="Level1"/>
<labs:SettingsExpander x:Name="AppThemeExpander"
<muxc:Expander x:Name="AppThemeExpander" Description="Select which app theme to display"
x:Uid="AppThemeExpander" Header="App theme">
Grid.Row="1" <labs:SettingsExpander.HeaderIcon>
Margin="0,8,0,0" <FontIcon Glyph="&#xE790;"/>
HorizontalAlignment="Stretch" </labs:SettingsExpander.HeaderIcon>
VerticalAlignment="Top" <labs:SettingsExpander.Items>
HorizontalContentAlignment="Left" <labs:SettingsCard ContentAlignment="Left">
ExpandDirection="Down"
IsExpanded="False">
<muxc:Expander.Header>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<FontIcon Margin="0,0,12,0"
VerticalAlignment="Center"
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
FontFamily="{ThemeResource CalculatorFontFamily}"
FontSize="16"
Glyph="&#xE790;"/>
<StackPanel Grid.Column="1"
Margin="0,12"
Orientation="Vertical">
<TextBlock x:Uid="SettingsAppThemeTitle" Style="{StaticResource BodyTextBlockStyle}"/>
<TextBlock x:Uid="SettingsAppThemeDescription"
Style="{StaticResource CaptionTextBlockStyle}"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
TextWrapping="WrapWholeWords"/>
</StackPanel>
</Grid>
</muxc:Expander.Header>
<muxc:Expander.Content>
<muxc:RadioButtons x:Name="ThemeRadioButtons" <muxc:RadioButtons x:Name="ThemeRadioButtons"
Margin="32,0,0,0" Margin="0,-8,0,0"
SelectionChanged="OnThemeSelectionChanged"> SelectionChanged="OnThemeSelectionChanged">
<RadioButton x:Name="LightThemeRadioButton" <RadioButton x:Name="LightThemeRadioButton"
x:Uid="LightThemeRadioButton" x:Uid="LightThemeRadioButton"
@ -170,34 +109,28 @@
x:Uid="SystemThemeRadioButton" x:Uid="SystemThemeRadioButton"
Tag="Default"/> Tag="Default"/>
</muxc:RadioButtons> </muxc:RadioButtons>
</muxc:Expander.Content> </labs:SettingsCard>
</muxc:Expander> </labs:SettingsExpander.Items>
</labs:SettingsExpander>
<Grid x:Name="AboutContentGrid" Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="AboutGroupTitle" <TextBlock x:Name="AboutGroupTitle"
x:Uid="AboutGroupTitle" x:Uid="AboutGroupTitle"
Margin="0,20,0,0" Style="{ThemeResource SettingsCategoryTitleTextBlockStyle}"
Style="{ThemeResource BodyStrongTextBlockStyle}"
AutomationProperties.HeadingLevel="Level1"/> AutomationProperties.HeadingLevel="Level1"/>
<StackPanel Grid.Row="1" <labs:SettingsExpander x:Name="AboutExpander">
Margin="0,8,0,0" <labs:SettingsExpander.HeaderIcon>
Orientation="Vertical"> <BitmapIcon AutomationProperties.AccessibilityView="Raw" UriSource="ms-appx:///Assets/CalculatorAppList.png"/>
<RichTextBlock x:Name="AboutContentBody" Style="{StaticResource SettingsRichTextBlockStyle}"> </labs:SettingsExpander.HeaderIcon>
<Paragraph> <TextBlock x:Name="AboutBuildVersion"
<Run x:Name="AboutBuildVersion"/> Foreground="{ThemeResource TextFillColorSecondaryBrush}"
<LineBreak/> IsTextSelectionEnabled="True"/>
<Run x:Name="AboutControlCopyrightRun"/> <labs:SettingsExpander.Items>
</Paragraph> <labs:SettingsCard ContentAlignment="Left">
</RichTextBlock> <StackPanel Margin="0,4,0,6"
Orientation="Vertical"
Spacing="12">
<HyperlinkButton x:Name="AboutEULA" <HyperlinkButton x:Name="AboutEULA"
Margin="0,16,0,0"
Padding="0" Padding="0"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=529064" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=529064"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=529064"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=529064">
@ -207,7 +140,6 @@
</HyperlinkButton> </HyperlinkButton>
<HyperlinkButton x:Name="AboutControlServicesAgreement" <HyperlinkButton x:Name="AboutControlServicesAgreement"
Margin="0,16,0,0"
Padding="0" Padding="0"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=822631" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=822631"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=822631"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=822631">
@ -217,7 +149,6 @@
</HyperlinkButton> </HyperlinkButton>
<HyperlinkButton x:Name="AboutControlPrivacyStatement" <HyperlinkButton x:Name="AboutControlPrivacyStatement"
Margin="0,16,0,0"
Padding="0" Padding="0"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=521839" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=521839"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=521839"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=521839">
@ -225,19 +156,23 @@
FontSize="{ThemeResource BodyFontSize}" FontSize="{ThemeResource BodyFontSize}"
TextWrapping="Wrap"/> TextWrapping="Wrap"/>
</HyperlinkButton> </HyperlinkButton>
</StackPanel>
</labs:SettingsCard>
</labs:SettingsExpander.Items>
</labs:SettingsExpander>
<Button x:Name="FeedbackButton" <HyperlinkButton x:Name="FeedbackButton"
x:Uid="FeedbackButton" x:Uid="FeedbackButton"
MinWidth="120" MinWidth="120"
Margin="0,24,0,0" Margin="-12,4,0,0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
FontSize="{StaticResource BodyFontSize}" FontSize="{StaticResource BodyFontSize}"
Click="FeedbackButton_Click"/> Click="FeedbackButton_Click"/>
</StackPanel>
<RichTextBlock x:Name="AboutContribute" <RichTextBlock x:Name="AboutContribute"
Grid.Row="2" Grid.Row="2"
Margin="0,16,0,0" Margin="1,9,0,0"
Style="{StaticResource SettingsRichTextBlockStyle}"> Style="{StaticResource SettingsRichTextBlockStyle}">
<Paragraph> <Paragraph>
<!-- <!--
@ -253,8 +188,8 @@
</Hyperlink><Run x:Name="ContributeRunAfterLink"/> </Hyperlink><Run x:Name="ContributeRunAfterLink"/>
</Paragraph> </Paragraph>
</RichTextBlock> </RichTextBlock>
</Grid>
</Grid> </StackPanel>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -45,7 +45,7 @@ namespace CalculatorApp
var copyrightText = var copyrightText =
LocalizationStringUtil.GetLocalizedString(resourceLoader.GetResourceString("AboutControlCopyright"), BUILD_YEAR); LocalizationStringUtil.GetLocalizedString(resourceLoader.GetResourceString("AboutControlCopyright"), BUILD_YEAR);
AboutControlCopyrightRun.Text = copyrightText; AboutExpander.Description = copyrightText;
InitializeContributeTextBlock(); InitializeContributeTextBlock();
} }
@ -108,8 +108,8 @@ namespace CalculatorApp
private void SetVersionString() private void SetVersionString()
{ {
PackageVersion version = Package.Current.Id.Version; PackageVersion version = Package.Current.Id.Version;
string appName = AppResourceProvider.GetInstance().GetResourceString("AppName"); AboutExpander.Header = AppResourceProvider.GetInstance().GetResourceString("AppName");
AboutBuildVersion.Text = appName + " " + version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision; AboutBuildVersion.Text = version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision;
} }
private void InitializeContributeTextBlock() private void InitializeContributeTextBlock()