Skip to content

Commit

Permalink
Merge branch 'main' into package-id-as-assembly-name
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlodotexe authored Aug 19, 2024
2 parents 3cf0f05 + 7d5d479 commit 10bc602
Show file tree
Hide file tree
Showing 33 changed files with 283 additions and 162 deletions.
11 changes: 8 additions & 3 deletions Build-Toolkit-Components.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@
#>
Param (
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
[string[]]$MultiTargets = @('all'),
[Alias("mt")]
[string[]]$MultiTargets = @('uwp', 'wasdk', 'wasm'), # default settings

[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
[string[]]$ExcludeMultiTargets = @('wpf', 'linuxgtk', 'macos', 'ios', 'android'),
[string[]]$ExcludeMultiTargets = @(), # default settings

[Alias("c")]
[string[]]$Components = @("all"),

[string[]]$ExcludeComponents,
Expand All @@ -76,10 +78,13 @@ Param (
[Alias("bl")]
[switch]$EnableBinLogs,

[Alias("blo")]
[string]$BinlogOutput,


[Alias("p")]
[hashtable]$AdditionalProperties,

[Alias("winui")]
[int]$WinUIMajorVersion = 2,

[string]$ComponentDir = "src",
Expand Down
22 changes: 13 additions & 9 deletions Build-Toolkit-Gallery.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Specifies the MultiTarget TFM(s) to exclude for building the components. The default value excludes targets that require additional tooling or workloads to build: 'wpf', 'linuxgtk', 'macos', 'ios', and 'android'. Run uno-check to install the required workloads.
.PARAMETER Heads
The heads to include in the build. Default is 'Uwp', 'WinAppSdk', 'Wasm'.
The heads to include in the build. Default is 'Uwp', 'Wasdk', 'Wasm'.
.PARAMETER ExcludeHeads
The heads to exclude from the build. Default is none.
Expand Down Expand Up @@ -47,26 +47,31 @@
#>
Param (
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
[string[]]$MultiTargets = @('all'),
[Alias("mt")]
[string[]]$MultiTargets = @('uwp', 'wasdk', 'wasm'), # default settings

[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
[string[]]$ExcludeMultiTargets = @('wpf', 'linuxgtk', 'macos', 'ios', 'android'),
[string[]]$ExcludeMultiTargets = @() # default settings

[ValidateSet('all', 'Uwp', 'WinAppSdk', 'Wasm', 'Tests.Uwp', 'Tests.WinAppSdk')]
[string[]]$Heads = @('Uwp', 'WinAppSdk', 'Wasm'),
[ValidateSet('all', 'Uwp', 'Wasdk', 'Wasm', 'Tests.Uwp', 'Tests.Wasdk')]
[string[]]$Heads = @('Uwp', 'Wasdk', 'Wasm'),

[ValidateSet('Uwp', 'WinAppSdk', 'Wasm', 'Tests.Uwp', 'Tests.WinAppSdk')]
[ValidateSet('Uwp', 'Wasdk', 'Wasm', 'Tests.Uwp', 'Tests.Wasdk')]
[string[]]$ExcludeHeads,

[Alias("bl")]
[switch]$EnableBinLogs,

[Alias("blo")]
[string]$BinlogOutput,

[Alias("p")]
[hashtable]$AdditionalProperties,

[Alias("winui")]
[int]$WinUIMajorVersion = 2,

[Alias("c")]
[string[]]$Components = @("all"),

[string[]]$ExcludeComponents,
Expand Down Expand Up @@ -94,8 +99,7 @@ if ($ExcludeComponents) {
$Components = $Components | Where-Object { $_ -notin $ExcludeComponents }
}

# Certain Components are required to build the gallery app.
# Add them if not already included.
# Certain ProjectReferences should always be generated (are required to build gallery) if csproj is available.
if ($Components -notcontains 'SettingsControls') {
$Components += 'SettingsControls'
}
Expand All @@ -113,7 +117,7 @@ if ($Components -notcontains 'Converters') {
& $PSScriptRoot\MultiTarget\GenerateAllProjectReferences.ps1 -MultiTarget $MultiTargets -Components $Components

if ($Heads -eq 'all') {
$Heads = @('Uwp', 'WinAppSdk', 'Wasm', 'Tests.Uwp', 'Tests.WinAppSdk')
$Heads = @('Uwp', 'Wasdk', 'Wasm', 'Tests.Uwp', 'Tests.Wasdk')
}

function Invoke-MSBuildWithBinlog {
Expand Down
32 changes: 19 additions & 13 deletions CommunityToolkit.App.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace CommunityToolkit.App.Shared;
public sealed partial class App : Application
{
// MacOS and iOS don't know the correct type without a full namespace declaration, confusing it with NSWindow and UIWindow.
// Using static will not work.
#if WINAPPSDK
public static Microsoft.UI.Xaml.Window currentWindow = Microsoft.UI.Xaml.Window.Current;
#else
private static Windows.UI.Xaml.Window currentWindow = Windows.UI.Xaml.Window.Current;
// 'using static' will not work.
#if WINUI3
public static Microsoft.UI.Xaml.Window? currentWindow = Microsoft.UI.Xaml.Window.Current;
#elif WINUI2
private static Windows.UI.Xaml.Window? currentWindow = Windows.UI.Xaml.Window.Current;
#endif

/// <summary>
Expand All @@ -41,28 +41,34 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
currentWindow.AppWindow.SetIcon("Assets/Icon.ico");
currentWindow.SystemBackdrop = new MicaBackdrop();
#if ALL_SAMPLES
currentWindow.AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
currentWindow.AppWindow.TitleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent;
if (currentWindow is not null)
{
currentWindow.AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
currentWindow.AppWindow.TitleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent;
}
#endif
#endif

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (currentWindow.Content is not Frame rootFrame)
if (currentWindow is not null && currentWindow.Content is not Frame)
{
// Create a Frame to act as the navigation context and navigate to the first page
currentWindow.Content = rootFrame = new Frame();
currentWindow.Content = new Frame();
}

if (currentWindow?.Content is Frame rootFrame)
{
rootFrame.NavigationFailed += OnNavigationFailed;
}

#if !WINAPPSDK
if (e.PrelaunchActivated == false)
if (e.PrelaunchActivated == false)
#endif
rootFrame.Navigate(typeof(AppLoadingView), e.Arguments);
rootFrame.Navigate(typeof(AppLoadingView), e.Arguments);
}

// Ensure the current window is active
currentWindow.Activate();
currentWindow?.Activate();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static IEnumerable<GroupNavigationItemData> GenerateSubcategoryNavItems(
{
Content = subcategoryGroup.Key,
SelectsOnInvoked = false,
IsExpanded = true,
IsExpanded = false,
Style = (Style)App.Current.Resources["SubcategoryNavigationViewItemStyle"],
}, subcategoryGroup.ToArray());
}
Expand Down
4 changes: 2 additions & 2 deletions CommunityToolkit.App.Shared/Pages/GettingStartedPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- 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. -->
<!-- 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. -->
<Page x:Class="CommunityToolkit.App.Shared.Pages.GettingStartedPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down Expand Up @@ -72,7 +72,7 @@
Orientation="Vertical"
Spacing="4">
<TextBlock FontWeight="SemiBold"
Text="Version 8.0" />
Text="{x:Bind AppVersion}" />
<TextBlock FontSize="36"
FontWeight="SemiBold">
<Run Text="Windows Community Toolkit" />
Expand Down
3 changes: 3 additions & 0 deletions CommunityToolkit.App.Shared/Pages/GettingStartedPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
// See the LICENSE file in the project root for more information.

using CommunityToolkit.Tooling.SampleGen.Metadata;
using Windows.ApplicationModel;

namespace CommunityToolkit.App.Shared.Pages;

public sealed partial class GettingStartedPage : Page
{
public string AppVersion => $"Version {Package.Current.Id.Version.Major}.{Package.Current.Id.Version.Minor}";

public GettingStartedPage()
{
this.InitializeComponent();
Expand Down
4 changes: 2 additions & 2 deletions CommunityToolkit.App.Shared/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="About" />

<controls:SettingsExpander Description="© 2023. All rights reserved."
<controls:SettingsExpander Description="© 2024. All rights reserved."
Header="Windows Community Toolkit Gallery"
IsExpanded="True">
<controls:SettingsExpander.HeaderIcon>
Expand All @@ -82,7 +82,7 @@
</controls:SettingsExpander.HeaderIcon>
<TextBlock win:IsTextSelectionEnabled="True"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="Version 8.0.0" />
Text="{x:Bind AppVersion}" />
<controls:SettingsExpander.Items>
<controls:SettingsCard HorizontalContentAlignment="Left"
ContentAlignment="Left">
Expand Down
4 changes: 4 additions & 0 deletions CommunityToolkit.App.Shared/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Windows.ApplicationModel;

namespace CommunityToolkit.App.Shared.Pages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SettingsPage : Page
{
public string AppVersion => $"Version {Package.Current.Id.Version.Major}.{Package.Current.Id.Version.Minor}.{Package.Current.Id.Version.Build}";

public SettingsPage()
{
this.InitializeComponent();
Expand Down
5 changes: 3 additions & 2 deletions CommunityToolkit.App.Shared/Pages/Shell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public sealed partial class Shell : Page
public Shell()
{
this.InitializeComponent();
#if WINAPPSDK
appTitleBar.Window = App.currentWindow;
#if WINDOWS_WINAPPSDK
if (App.currentWindow is not null)
appTitleBar.Window = App.currentWindow;
#else
BackdropMaterial.SetApplyToRootOrPageBackground(this, true);
#endif
Expand Down
5 changes: 3 additions & 2 deletions CommunityToolkit.App.Shared/Pages/TabbedPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ public sealed partial class TabbedPage : Page
public TabbedPage()
{
this.InitializeComponent();
#if WINAPPSDK
appTitleBar.Window = App.currentWindow;
#if WINDOWS_WINAPPSDK
if (App.currentWindow is not null)
appTitleBar.Window = App.currentWindow;
#else
BackdropMaterial.SetApplyToRootOrPageBackground(this, true);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static async Task<string> GetDocumentationFileContents(ToolkitFrontMatte
// TODO: https://github.com/CommunityToolkit/Labs-Windows/issues/142
// MSBuild uses wildcard to find the files, and the wildcards decide where they end up
// Single experiments use relative paths, the allExperiment head uses absolute paths that grab from all experiments
// The wildcard captures decide the paths. This discrepency is accounted for manually.
// The wildcard captures decide the paths. This discrepancy is accounted for manually.
// Logic here is the exact same that MSBuild uses to find and include the files we need.
var assemblyName = typeof(ToolkitSampleRenderer).Assembly.GetName().Name;
if (string.IsNullOrWhiteSpace(assemblyName))
Expand All @@ -178,9 +178,9 @@ private static async Task<string> GetDocumentationFileContents(ToolkitFrontMatte
var textContents = await FileIO.ReadTextAsync(file);

// Remove YAML - need to use array overload as single string not supported on .NET Standard 2.0
var blocks = textContents.Split(new[] { "---" }, StringSplitOptions.RemoveEmptyEntries);
var blocks = textContents.Split(new[] { "---" }, 2, StringSplitOptions.RemoveEmptyEntries);

return blocks.LastOrDefault() ?? "Couldn't find content after YAML Front Matter removal.";
return blocks.LastOrDefault()?.Replace("<br>", " ") ?? "Couldn't find content after YAML Front Matter removal.";
}
catch (Exception e)
{
Expand Down
Loading

0 comments on commit 10bc602

Please sign in to comment.