mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-11 14:56:48 +01:00
show details
This commit is contained in:
@@ -41,6 +41,11 @@ public partial class SamplesListPage : ListPage
|
||||
Title = "Markdown with multiple blocks",
|
||||
Subtitle = "A page with multiple blocks of rendered markdown",
|
||||
},
|
||||
new ListItem(new SampleMarkdownDetails())
|
||||
{
|
||||
Title = "Markdown with details",
|
||||
Subtitle = "A page with markdown and details",
|
||||
},
|
||||
|
||||
new ListItem(new SampleFormPage())
|
||||
{
|
||||
|
||||
@@ -29,8 +29,8 @@ public partial class DetailsViewModel(IDetails _details, TaskScheduler Scheduler
|
||||
return;
|
||||
}
|
||||
|
||||
Title = model.Title;
|
||||
Body = model.Body;
|
||||
Title = model.Title ?? string.Empty;
|
||||
Body = model.Body ?? string.Empty;
|
||||
|
||||
UpdateProperty(nameof(Title));
|
||||
UpdateProperty(nameof(Body));
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.CmdPal.Extensions;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Models;
|
||||
|
||||
namespace Microsoft.CmdPal.UI.ViewModels;
|
||||
@@ -76,8 +78,7 @@ public partial class MarkdownPageViewModel : PageViewModel
|
||||
{
|
||||
Details = new(extensionDetails, PageContext);
|
||||
Details.InitializeProperties();
|
||||
UpdateProperty(nameof(Details));
|
||||
UpdateProperty(nameof(HasDetails));
|
||||
UpdateDetails();
|
||||
}
|
||||
|
||||
FetchContent();
|
||||
@@ -101,10 +102,32 @@ public partial class MarkdownPageViewModel : PageViewModel
|
||||
case nameof(Details):
|
||||
var extensionDetails = model.Details();
|
||||
Details = extensionDetails != null ? new(extensionDetails, PageContext) : null;
|
||||
UpdateProperty(nameof(Details));
|
||||
UpdateDetails();
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateProperty(propertyName);
|
||||
}
|
||||
|
||||
private void UpdateDetails()
|
||||
{
|
||||
UpdateProperty(nameof(Details));
|
||||
UpdateProperty(nameof(HasDetails));
|
||||
|
||||
Task.Factory.StartNew(
|
||||
() =>
|
||||
{
|
||||
if (HasDetails)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<ShowDetailsMessage>(new(Details));
|
||||
}
|
||||
else
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<HideDetailsMessage>();
|
||||
}
|
||||
},
|
||||
CancellationToken.None,
|
||||
TaskCreationOptions.None,
|
||||
PageContext.Scheduler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ public sealed partial class ShellPage :
|
||||
{
|
||||
if (RootFrame.CanGoBack)
|
||||
{
|
||||
HideDetails();
|
||||
|
||||
RootFrame.GoBack();
|
||||
RootFrame.ForwardStack.Clear();
|
||||
SearchBox.Focus(Microsoft.UI.Xaml.FocusState.Programmatic);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CmdPal.Extensions.Helpers;
|
||||
|
||||
namespace SamplePagesExtension;
|
||||
|
||||
internal sealed partial class SampleMarkdownDetails : MarkdownPage
|
||||
{
|
||||
public SampleMarkdownDetails()
|
||||
{
|
||||
Icon = new(string.Empty);
|
||||
Name = "Markdown with Details";
|
||||
Details = new Details()
|
||||
{
|
||||
Body = "... with _even more Markdown_ by it.",
|
||||
};
|
||||
}
|
||||
|
||||
public override string[] Bodies() => [
|
||||
"""
|
||||
# This page also has details
|
||||
|
||||
So you can have markdown...
|
||||
""",
|
||||
"""
|
||||
But what this is really useful for is the tags and other things you can put into
|
||||
Details. Which I'd do. **IF I HAD ANY**.
|
||||
"""
|
||||
];
|
||||
}
|
||||
@@ -21,7 +21,7 @@ internal sealed partial class SampleMarkdownManyBodies : MarkdownPage
|
||||
On it you'll find multiple blocks of markdown content
|
||||
""",
|
||||
"""
|
||||
# Here's another block
|
||||
## Here's another block
|
||||
|
||||
_Maybe_ you could use this pattern for implementing a post with comments page.
|
||||
""",
|
||||
|
||||
Reference in New Issue
Block a user