Skip to content

Commit d2ba633

Browse files
committed
Make "Show details" a toggle and fix context menu icon
1 parent 8af6a99 commit d2ba633

4 files changed

Lines changed: 43 additions & 7 deletions

File tree

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListItemViewModel.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ pageContext is ListViewModel listViewModel &&
208208
contextItemViewModel.Command.Id == ShowDetailsCommand.ShowDetailsCommandId))
209209
{
210210
var showDetailsCommand = new ShowDetailsCommand(Details);
211-
var showDetailsContextItem = new CommandContextItem(showDetailsCommand);
211+
var showDetailsContextItem = new CommandContextItem(showDetailsCommand)
212+
{
213+
Icon = showDetailsCommand.Icon,
214+
};
212215
var showDetailsContextItemViewModel = new CommandContextItemViewModel(showDetailsContextItem, PageContext);
213216
showDetailsContextItemViewModel.SlowInitializeProperties();
214217
UnsafeMoreCommands.Add(showDetailsContextItemViewModel);
@@ -249,7 +252,10 @@ pageContext is ListViewModel listViewModel &&
249252
}
250253

251254
var showDetailsCommand = new ShowDetailsCommand(Details);
252-
var showDetailsContextItem = new CommandContextItem(showDetailsCommand);
255+
var showDetailsContextItem = new CommandContextItem(showDetailsCommand)
256+
{
257+
Icon = showDetailsCommand.Icon,
258+
};
253259
var showDetailsContextItemViewModel = new CommandContextItemViewModel(showDetailsContextItem, PageContext);
254260
showDetailsContextItemViewModel.SlowInitializeProperties();
255261
UnsafeMoreCommands.Add(showDetailsContextItemViewModel);

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.resx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
<value>Disabled</value>
263263
</data>
264264
<data name="builtin_main_list_page_searchbar_placeholder" xml:space="preserve">
265-
<value>Search for apps, files and commands...</value>
265+
<value>NEXT Search for apps, files and commands...</value>
266266
</data>
267267
<data name="builtin_home_name" xml:space="preserve">
268268
<value>Home</value>
@@ -307,6 +307,10 @@
307307
<value>Show details</value>
308308
<comment>Name for the command that shows details of an item</comment>
309309
</data>
310+
<data name="HideDetailsCommand" xml:space="preserve">
311+
<value>Hide details</value>
312+
<comment>Name for the command that hides details of an item</comment>
313+
</data>
310314
<data name="PinnedItemSuffix" xml:space="preserve">
311315
<value>Pinned</value>
312316
<comment>Suffix shown for pinned items in the dock</comment>

src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ShowDetailsCommand.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,39 @@ public sealed partial class ShowDetailsCommand : InvokableCommand
1212
{
1313
public static string ShowDetailsCommandId { get; } = "com.microsoft.cmdpal.showDetails";
1414

15-
private static IconInfo IconInfo { get; } = new IconInfo("\uF000"); // KnowledgeArticle Icon
15+
private static IconInfo ShowIcon { get; } = new IconInfo("\uF000"); // KnowledgeArticle Icon
16+
17+
private static IconInfo HideIcon { get; } = new IconInfo("\uED1A"); // Hide Icon
1618

1719
private DetailsViewModel Details { get; set; }
1820

21+
private bool _isDetailsVisible;
22+
1923
public ShowDetailsCommand(DetailsViewModel details)
2024
{
2125
Id = ShowDetailsCommandId;
2226
Name = UI.ViewModels.Properties.Resources.ShowDetailsCommand;
23-
Icon = IconInfo;
27+
Icon = ShowIcon;
2428
Details = details;
2529
}
2630

2731
public override CommandResult Invoke()
2832
{
29-
// Send the ShowDetailsMessage when the action is invoked
30-
WeakReferenceMessenger.Default.Send<ShowDetailsMessage>(new(Details));
33+
_isDetailsVisible = !_isDetailsVisible;
34+
35+
if (_isDetailsVisible)
36+
{
37+
WeakReferenceMessenger.Default.Send<ShowDetailsMessage>(new(Details));
38+
Name = UI.ViewModels.Properties.Resources.HideDetailsCommand;
39+
Icon = HideIcon;
40+
}
41+
else
42+
{
43+
WeakReferenceMessenger.Default.Send<HideDetailsMessage>();
44+
Name = UI.ViewModels.Properties.Resources.ShowDetailsCommand;
45+
Icon = ShowIcon;
46+
}
47+
3148
return CommandResult.KeepOpen();
3249
}
3350
}

0 commit comments

Comments
 (0)