dynamic list page example

This commit is contained in:
Jordi Adoumie
2024-09-07 22:31:52 -07:00
parent 7f489f2c13
commit b82840c5ed
3 changed files with 65 additions and 7 deletions

View File

@@ -0,0 +1,53 @@
// 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 System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.Extensions.Helpers;
using Microsoft.UI.Windowing;
namespace SamplePagesExtension;
internal sealed class SampleDynamicListPage : DynamicListPage
{
public SampleDynamicListPage()
{
Icon = new(string.Empty);
Name = "SSH Keychain";
}
public override ISection[] GetItems(string query)
{
return [
new ListSection()
{
Title = "Sample List Page",
Items = [
new ListItem(new NoOpCommand()) { Title = string.IsNullOrEmpty(query) ? "dynamic item" : query, Subtitle = "Notice how the title changes for this list item when you type in the filter box" },
new ListItem(new NoOpCommand()) { Title = "TODO: Implement your extension here" },
new ListItem(new NoOpCommand()) { Title = "This one has a subtitle too", Subtitle = "Example Subtitle" },
new ListItem(new NoOpCommand())
{
Title = "This one has a tag too",
Subtitle = "the one with a tag",
Tags = [new Tag()
{
Text = "Sample Tag",
}
],
}
],
}
];
}
}

View File

@@ -1,9 +1,9 @@
{
"profiles": {
"SSHKeychainExtension (Package)": {
"SamplePagesExtension (Package)": {
"commandName": "MsixPackage"
},
"SSHKeychainExtension (Unpackaged)": {
"SamplePagesExtension (Unpackaged)": {
"commandName": "Project"
}
}

View File

@@ -30,11 +30,16 @@ public class SamplePagesCommandsProvider : ICommandProvider
Title = "Form Page Sample Command",
Subtitle = "SamplePages Extension",
},
new ListItem(new SampleListPageWithDetails())
{
Title = "List Page With Details Sample Command",
Subtitle = "SamplePages Extension",
}
new ListItem(new SampleListPageWithDetails())
{
Title = "List Page With Details Sample Command",
Subtitle = "SamplePages Extension",
},
new ListItem(new SampleDynamicListPage())
{
Title = "Dynamic List Page Command",
Subtitle = "SamplePages Extension",
}
];
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize