Skip to content

Commit 65326c0

Browse files
authored
Merge pull request CommunityToolkit#211 from CommunityToolkit/llama/port-notifications
🧪 Bring over StackedNotificationsBehavior from Toolkit
2 parents c335c4b + 6747fa5 commit 65326c0

File tree

6 files changed

+61
-8
lines changed

6 files changed

+61
-8
lines changed

CommunityToolkit.Labs.Shared/Renderers/Markdown/MarkdownTextBlock.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,15 @@ namespace CommunityToolkit.Labs.Shared.Renderers;
2323
/// </summary>
2424
public partial class MarkdownTextBlock : ToolkitMTB
2525
{
26+
#if HAS_UNO
27+
//// Polyfill dummy for event callback
28+
#pragma warning disable CS0067 // Unused on purpose for polyfill
29+
public event EventHandler<LinkClickedEventArgs>? LinkClicked;
30+
#pragma warning restore CS0067 // Unused on purpose for polyfill
31+
#endif
2632
}
33+
34+
#if HAS_UNO
35+
//// Polyfill dummy for event callback
36+
public class LinkClickedEventArgs : EventArgs { }
37+
#endif

CommunityToolkit.Labs.Shared/Renderers/ToolkitDocumentationRenderer.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<DataTemplate x:Key="DocumentTemplate"
1919
x:DataType="x:String">
2020
<renderer:MarkdownTextBlock Background="Transparent"
21+
LinkClicked="MarkdownTextBlock_LinkClicked"
2122
Text="{Binding}"
2223
TextWrapping="WrapWholeWords" />
2324
</DataTemplate>

CommunityToolkit.Labs.Shared/Renderers/ToolkitDocumentationRenderer.xaml.cs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
using CommunityToolkit.Labs.Core.SourceGenerators;
66
using CommunityToolkit.Labs.Core.SourceGenerators.Metadata;
77
using Windows.Storage;
8+
using Windows.System;
9+
10+
#if !HAS_UNO
11+
#if !WINAPPSDK
12+
using Microsoft.Toolkit.Uwp.UI.Controls;
13+
#else
14+
using CommunityToolkit.WinUI.UI.Controls;
15+
#endif
16+
#endif
817

918
namespace CommunityToolkit.Labs.Shared.Renderers;
1019

@@ -113,8 +122,12 @@ private async Task LoadData()
113122
index = match.Index + match.Length;
114123
}
115124

116-
// Put rest of text at end
117-
DocsAndSamples.Add(doctext.Substring(index));
125+
var rest = doctext.Substring(index).Trim();
126+
// Put rest of text at end (if any)
127+
if (rest.Length > 0)
128+
{
129+
DocsAndSamples.Add(rest);
130+
}
118131
}
119132
}
120133

@@ -174,4 +187,30 @@ private static async Task<string> GetDocumentationFileContents(ToolkitFrontMatte
174187
return $"Exception Encountered Loading file '{fileUri}':\n{e.Message}\n{e.StackTrace}";
175188
}
176189
}
190+
191+
192+
#if HAS_UNO
193+
private void MarkdownTextBlock_LinkClicked(object sender, LinkClickedEventArgs e)
194+
{
195+
// No-op - TODO: See https://github.com/CommunityToolkit/Labs-Windows/issues/151
196+
}
197+
#elif !HAS_UNO
198+
private async void MarkdownTextBlock_LinkClicked(object sender, LinkClickedEventArgs e)
199+
{
200+
if (!Uri.IsWellFormedUriString(e.Link, UriKind.Absolute))
201+
{
202+
await new ContentDialog
203+
{
204+
Title = "Windows Community Toolkit Labs Sample App",
205+
Content = $"Link {e.Link} was malformed.",
206+
CloseButtonText = "Close",
207+
XamlRoot = XamlRoot // TODO: For UWP this is only on 1903+
208+
}.ShowAsync();
209+
}
210+
else
211+
{
212+
await Launcher.LaunchUriAsync(new Uri(e.Link));
213+
}
214+
}
215+
#endif
177216
}

Labs.Head.Uwp.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project>
1+
<Project>
22
<Import Project="$(RepositoryDirectory)common\Labs.Uwp.Base.props" />
33
<Import Project="$(RepositoryDirectory)common\Labs.Head.Uwp.Dependencies.props" />
44

Labs.Uno.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<ItemGroup Condition="'$(IsUno)' == 'true'">
55
<PackageReference Include="Uno.UI" Version="4.6.18" />
66
</ItemGroup>
7+
<PropertyGroup Condition="'$(IsUno)' == 'true'">
8+
<UnoUIUseRoslynSourceGenerators>true</UnoUIUseRoslynSourceGenerators>
9+
</PropertyGroup>
710

811
<ItemGroup Condition="'$(IsWasm)' == 'true' OR '$(IsWpf)' == 'true' OR '$(IsGtk)' == 'true'">
912
<PackageReference Include="Uno.UI.RemoteControl" Version="4.6.18" Condition="'$(Configuration)'=='Debug'" />

Labs.Uwp.Base.props

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<IncludeContentInPack>false</IncludeContentInPack>
99
</PropertyGroup>
1010

11+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
12+
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
13+
</PropertyGroup>
14+
1115
<PropertyGroup>
1216
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
1317
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -44,7 +48,6 @@
4448
<UseVSHostingProcess>false</UseVSHostingProcess>
4549
<ErrorReport>prompt</ErrorReport>
4650
<Prefer32Bit>true</Prefer32Bit>
47-
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
4851
</PropertyGroup>
4952

5053
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
@@ -69,7 +72,6 @@
6972
<UseVSHostingProcess>false</UseVSHostingProcess>
7073
<ErrorReport>prompt</ErrorReport>
7174
<Prefer32Bit>true</Prefer32Bit>
72-
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
7375
</PropertyGroup>
7476

7577
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
@@ -82,7 +84,6 @@
8284
<UseVSHostingProcess>false</UseVSHostingProcess>
8385
<ErrorReport>prompt</ErrorReport>
8486
<Prefer32Bit>true</Prefer32Bit>
85-
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
8687
</PropertyGroup>
8788

8889
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
@@ -95,7 +96,6 @@
9596
<UseVSHostingProcess>false</UseVSHostingProcess>
9697
<ErrorReport>prompt</ErrorReport>
9798
<Prefer32Bit>true</Prefer32Bit>
98-
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
9999
</PropertyGroup>
100100

101101
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
@@ -120,7 +120,6 @@
120120
<UseVSHostingProcess>false</UseVSHostingProcess>
121121
<ErrorReport>prompt</ErrorReport>
122122
<Prefer32Bit>true</Prefer32Bit>
123-
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
124123
</PropertyGroup>
125124

126125
<PropertyGroup>

0 commit comments

Comments
 (0)