Skip to content

Commit

Permalink
Use the non-labs markdown block, because pain and suffering (#240)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Griese <[email protected]>
  • Loading branch information
zadjii-msft and zadjii authored Dec 18, 2024
1 parent b0bfeec commit 8214331
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 39 deletions.
4 changes: 0 additions & 4 deletions nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="SDKLocalSource" value=".\src\modules\cmdpal\extensionsdk\_build" />
<add key="WCTLabs" value="https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
Expand All @@ -13,8 +12,5 @@
<packageSource key="SDKLocalSource">
<package pattern="Microsoft.CmdPal.Extensions.SDK" />
</packageSource>
<packageSource key="WCTLabs">
<package pattern="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" />
</packageSource>
</packageSourceMapping>
</configuration>
11 changes: 5 additions & 6 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using CommunityToolkit.Common.Deferred;
using CommunityToolkit.WinUI;
using CommunityToolkit.WinUI.Deferred;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand Down Expand Up @@ -90,20 +87,22 @@ private static void OnSourceKeyPropertyChanged(DependencyObject d, DependencyPro
}
else
{
_ = @this._queue.EnqueueAsync(async () =>
// TODO GH #239 switch back when using the new MD text block
// _ = @this._queue.EnqueueAsync(() =>
@this._queue.TryEnqueue(new(() =>
{
var eventArgs = new SourceRequestedEventArgs(e.NewValue);

if (@this.SourceRequested != null)
{
await @this.SourceRequested.InvokeAsync(@this, eventArgs);
@this.SourceRequested.Invoke(@this, eventArgs);

if (eventArgs.Value != null)
{
@this.Source = eventArgs.Value;
}
}
});
}));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using CommunityToolkit.Common;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.UI.Dispatching;
Expand Down Expand Up @@ -73,21 +72,25 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
// TODO: Handle failure case
System.Diagnostics.Debug.WriteLine(fpvm.InitializeCommand.ExecutionTask.Exception);

_ = _queue.EnqueueAsync(() =>
// TODO GH #239 switch back when using the new MD text block
// _ = _queue.EnqueueAsync(() =>
_queue.TryEnqueue(new(() =>
{
LoadedState = ViewModelLoadedState.Error;
});
}));
}
else
{
_ = _queue.EnqueueAsync(() =>
// TODO GH #239 switch back when using the new MD text block
// _ = _queue.EnqueueAsync(() =>
_queue.TryEnqueue(new(() =>
{
var result = (bool)fpvm.InitializeCommand.ExecutionTask.GetResultOrDefault()!;

ViewModel = fpvm;
WeakReferenceMessenger.Default.Send<NavigateToPageMessage>(new(result ? fpvm : null));
LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error;
});
}));
}
});
}
Expand Down
12 changes: 8 additions & 4 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,25 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
// TODO: Handle failure case
System.Diagnostics.Debug.WriteLine(lvm.InitializeCommand.ExecutionTask.Exception);

_ = _queue.EnqueueAsync(() =>
// TODO GH #239 switch back when using the new MD text block
// _ = _queue.EnqueueAsync(() =>
_queue.TryEnqueue(new(() =>
{
LoadedState = ViewModelLoadedState.Error;
});
}));
}
else
{
_ = _queue.EnqueueAsync(() =>
// TODO GH #239 switch back when using the new MD text block
// _ = _queue.EnqueueAsync(() =>
_queue.TryEnqueue(new(() =>
{
var result = (bool)lvm.InitializeCommand.ExecutionTask.GetResultOrDefault()!;

ViewModel = lvm;
WeakReferenceMessenger.Default.Send<NavigateToPageMessage>(new(result ? lvm : null));
LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error;
});
}));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
xmlns:cmdPalControls="using:Microsoft.CmdPal.UI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodels="using:Microsoft.CmdPal.UI.ViewModels"
xmlns:labs="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls"
Background="Transparent"
mc:Ignorable="d">

Expand Down Expand Up @@ -40,10 +40,13 @@
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}">

<labs:MarkdownTextBlock
<toolkit:MarkdownTextBlock
Text="{x:Bind}"
Config="{x:Bind local:MarkdownPage.MarkdownConfig}"
Background="Transparent" />
Background="Transparent"
Header3FontSize="12"
Header3FontWeight="Normal"
Header3Foreground="{ThemeResource TextFillColorSecondaryBrush}"
IsTextSelectionEnabled="True"/>
</Grid>
</DataTemplate>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
// See the LICENSE file in the project root for more information.

using CommunityToolkit.Common;
using CommunityToolkit.Labs.WinUI.MarkdownTextBlock;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.CmdPal.UI.ViewModels.Messages;
using Microsoft.UI.Dispatching;
Expand All @@ -22,8 +20,6 @@ public sealed partial class MarkdownPage : Page
{
private readonly DispatcherQueue _queue = DispatcherQueue.GetForCurrentThread();

public static readonly MarkdownConfig MarkdownConfig = CommunityToolkit.Labs.WinUI.MarkdownTextBlock.MarkdownConfig.Default;

public MarkdownPageViewModel? ViewModel
{
get => (MarkdownPageViewModel?)GetValue(ViewModelProperty);
Expand Down Expand Up @@ -76,21 +72,25 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
// TODO: Handle failure case
System.Diagnostics.Debug.WriteLine(mdpvm.InitializeCommand.ExecutionTask.Exception);

_ = _queue.EnqueueAsync(() =>
// TODO GH #239 switch back when using the new MD text block
// _ = _queue.EnqueueAsync(() =>
_queue.TryEnqueue(new(() =>
{
LoadedState = ViewModelLoadedState.Error;
});
}));
}
else
{
_ = _queue.EnqueueAsync(() =>
// TODO GH #239 switch back when using the new MD text block
// _ = _queue.EnqueueAsync(() =>
_queue.TryEnqueue(new(() =>
{
var result = (bool)mdpvm.InitializeCommand.ExecutionTask.GetResultOrDefault()!;

ViewModel = mdpvm;
WeakReferenceMessenger.Default.Send<NavigateToPageMessage>(new(result ? mdpvm : null));
LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error;
});
}));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" />
<PackageReference Include="CommunityToolkit.WinUI.Converters" />
<PackageReference Include="CommunityToolkit.WinUI.Extensions" />
<PackageReference Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" />
<PackageReference Include="Microsoft.WindowsAppSDK" />
Expand Down
12 changes: 7 additions & 5 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:help="using:Microsoft.CmdPal.UI.Helpers"
xmlns:labs="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="Transparent"
mc:Ignorable="d">
Expand Down Expand Up @@ -105,11 +105,13 @@
Visibility="{x:Bind ViewModel.Details.Title, Converter={StaticResource StringNotEmptyToVisibilityConverter}, Mode=OneWay}" />

<ScrollViewer Grid.Row="2" HorizontalAlignment="Stretch">
<labs:MarkdownTextBlock
x:Name="DetailsMarkdown"
<toolkit:MarkdownTextBlock
Text="{x:Bind ViewModel.Details.Body, Mode=OneWay}"
Background="Transparent"
Text="{x:Bind ViewModel.Details.Body, Mode=OneWay}" />

Header3FontSize="12"
Header3FontWeight="Normal"
Header3Foreground="{ThemeResource TextFillColorSecondaryBrush}"
IsTextSelectionEnabled="True"/>
</ScrollViewer>
</Grid>
<!-- /DetailsContent -->
Expand Down
2 changes: 0 additions & 2 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public ShellPage()
{
this.InitializeComponent();

DetailsMarkdown.Config = CommunityToolkit.Labs.WinUI.MarkdownTextBlock.MarkdownConfig.Default;

// how we are doing navigation around
WeakReferenceMessenger.Default.Register<NavigateBackMessage>(this);
WeakReferenceMessenger.Default.Register<NavigateToDetailsMessage>(this);
Expand Down

0 comments on commit 8214331

Please sign in to comment.