Skip to content

Commit c33f01a

Browse files
authored
Merge branch 'main' into niels9001/titlebar-improvements
2 parents 20d4d5f + a852f23 commit c33f01a

23 files changed

+97
-71
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

CommunityToolkit.App.Shared/CommunityToolkit.App.Shared.projitems

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<Compile Include="$(MSBuildThisFileDirectory)Behaviors\NavigateToUriAction.cs" />
2626
<Compile Include="$(MSBuildThisFileDirectory)Controls\TitleBar\TitleBar.cs" />
2727
<Compile Include="$(MSBuildThisFileDirectory)Controls\TitleBar\TitleBar.Properties.cs" />
28-
<Compile Include="$(MSBuildThisFileDirectory)Converters\SubcategoryToIconConverter.cs" />
28+
<Compile Include="$(MSBuildThisFileDirectory)Converters\StringToUriConverter.cs" />
2929
<Compile Include="$(MSBuildThisFileDirectory)DocOrSampleTemplateSelector.cs" />
3030
<Compile Include="$(MSBuildThisFileDirectory)Helpers\BackgroundHelper.cs" />
3131
<Compile Include="$(MSBuildThisFileDirectory)Helpers\IconHelper.cs" />
@@ -110,11 +110,6 @@
110110
</Page>
111111
</ItemGroup>
112112
<ItemGroup>
113-
<Content Include="$(MSBuildThisFileDirectory)Assets\ControlIcons\Control.png" />
114-
<Content Include="$(MSBuildThisFileDirectory)Assets\ControlIcons\Empty.png" />
115-
<Content Include="$(MSBuildThisFileDirectory)Assets\ControlIcons\Input.png" />
116-
<Content Include="$(MSBuildThisFileDirectory)Assets\ControlIcons\Status.png" />
117-
<Content Include="$(MSBuildThisFileDirectory)Assets\ControlIcons\Layout.png" />
118113
<Content Include="$(MSBuildThisFileDirectory)Assets\AppTitleBar.scale-100.png" />
119114
<Content Include="$(MSBuildThisFileDirectory)Assets\AppTitleBar.scale-125.png" />
120115
<Content Include="$(MSBuildThisFileDirectory)Assets\AppTitleBar.scale-150.png" />

CommunityToolkit.App.Shared/Converters/SubcategoryToIconConverter.cs renamed to CommunityToolkit.App.Shared/Converters/StringToUriConverter.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,18 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using CommunityToolkit.Tooling.SampleGen;
65
using CommunityToolkit.App.Shared.Helpers;
7-
using System;
8-
using System.Collections.Generic;
9-
using System.Text;
106

117
namespace CommunityToolkit.App.Shared.Converters;
128

13-
public sealed class SubcategoryToIconConverter : IValueConverter
9+
public class StringToUriConverter : IValueConverter
1410
{
1511
public object Convert(object value, Type targetType, object parameter, string language)
1612
{
17-
ToolkitSampleSubcategory subcategory = (ToolkitSampleSubcategory)value;
18-
return new Uri(IconHelper.GetSubcategoryIcon(subcategory));
13+
return new Uri(IconHelper.GetIconPath((string)value));
1914
}
2015

21-
public object ConvertBack(object value, Type targetType, object parameter, string language)
16+
public object ConvertBack(object value, Type targetType, object parameter, string language)
2217
{
2318
return value;
2419
}

CommunityToolkit.App.Shared/Helpers/IconHelper.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ namespace CommunityToolkit.App.Shared.Helpers;
88

99
public static class IconHelper
1010
{
11+
internal const string SourceAssetsPrefix = "ms-appx:///SourceAssets/";
12+
internal const string FallBackControlIconPath = "ms-appx:///Assets/DefaultControlIcon.png";
13+
1114
public static IconElement? GetCategoryIcon(ToolkitSampleCategory category)
1215
{
1316
IconElement? iconElement = null;
1417
switch (category)
1518
{
19+
case ToolkitSampleCategory.Layouts: iconElement = new FontIcon() { Glyph = "\uF58C" }; break;
1620
case ToolkitSampleCategory.Controls: iconElement = new FontIcon() { Glyph = "\ue73a" }; break;
1721
case ToolkitSampleCategory.Animations: iconElement = new FontIcon() { Glyph = "\ue945" }; break;
1822
case ToolkitSampleCategory.Extensions: iconElement = new FontIcon() { Glyph = "\ue95f" }; break;
@@ -22,23 +26,15 @@ public static class IconHelper
2226
return iconElement;
2327
}
2428

25-
public static string GetSubcategoryIcon(ToolkitSampleSubcategory subcategory)
29+
public static string GetIconPath(string? IconPath)
2630
{
27-
string imagePath = string.Empty;
28-
switch (subcategory)
31+
if (!string.IsNullOrEmpty(IconPath))
32+
{
33+
return SourceAssetsPrefix + IconPath;
34+
}
35+
else
2936
{
30-
case ToolkitSampleSubcategory.None: imagePath = "ms-appx:///Assets/ControlIcons/Control.png"; break;
31-
case ToolkitSampleSubcategory.Behaviors: imagePath = "ms-appx:///Assets/ControlIcons/Input.png"; break;
32-
case ToolkitSampleSubcategory.Controls: imagePath = "ms-appx:///Assets/ControlIcons/Control.png"; break;
33-
case ToolkitSampleSubcategory.Converters: imagePath = "ms-appx:///Assets/ControlIcons/Input.png"; break;
34-
case ToolkitSampleSubcategory.Input: imagePath = "ms-appx:///Assets/ControlIcons/Input.png"; break;
35-
case ToolkitSampleSubcategory.Layout: imagePath = "ms-appx:///Assets/ControlIcons/Layout.png"; break;
36-
case ToolkitSampleSubcategory.Markup: imagePath = "ms-appx:///Assets/ControlIcons/Input.png"; break;
37-
case ToolkitSampleSubcategory.Math: imagePath = "ms-appx:///Assets/ControlIcons/Control.png"; break;
38-
case ToolkitSampleSubcategory.Media: imagePath = "ms-appx:///Assets/ControlIcons/Control.png"; break;
39-
case ToolkitSampleSubcategory.StatusAndInfo: imagePath = "ms-appx:///Assets/ControlIcons/Status.png"; break;
40-
case ToolkitSampleSubcategory.Triggers: imagePath = "ms-appx:///Assets/ControlIcons/Input.png"; break;
37+
return FallBackControlIconPath;
4138
}
42-
return imagePath;
4339
}
4440
}

CommunityToolkit.App.Shared/Helpers/NavigationViewHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public static class NavigationViewHelper
2929
}
3030

3131
// Add subcategory to category
32-
3332
navData.NavItem.MenuItems.Add(subcategoryItemData.NavItem);
3433
}
3534

@@ -45,7 +44,7 @@ public static class NavigationViewHelper
4544
yield return new MUXC.NavigationViewItem
4645
{
4746
Content = metadata.Title,
48-
Icon = new BitmapIcon() { ShowAsMonochrome = false, UriSource = new Uri(IconHelper.GetSubcategoryIcon(metadata.Subcategory)) }, // TO DO: This is probably a property we need to add to ToolkitFrontMatter?
47+
Icon = new BitmapIcon() { ShowAsMonochrome = false, UriSource = new Uri(IconHelper.GetIconPath(metadata.Icon)) },
4948
Tag = metadata,
5049
};
5150
}
@@ -61,6 +60,7 @@ private static IEnumerable<GroupNavigationItemData> GenerateSubcategoryNavItems(
6160
{
6261
Content = subcategoryGroup.Key,
6362
SelectsOnInvoked = false,
63+
IsExpanded = true,
6464
Style = (Style)App.Current.Resources["SubcategoryNavigationViewItemStyle"],
6565
}, subcategoryGroup.ToArray());
6666
}

CommunityToolkit.App.Shared/Pages/GettingStartedPage.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
1+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
22
<Page x:Class="CommunityToolkit.App.Shared.Pages.GettingStartedPage"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -36,7 +36,6 @@
3636
</Page.Resources>
3737
<Grid BorderBrush="{ThemeResource NavigationViewContentGridBorderBrush}"
3838
CornerRadius="8,0,0,0">
39-
4039
<Grid.RowDefinitions>
4140
<RowDefinition Height="Auto" />
4241
<RowDefinition Height="*" />

0 commit comments

Comments
 (0)