From a0e853b93ea90d68b49ddffd2fe930cea8b194ea Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Fri, 1 Nov 2024 09:30:33 -0400 Subject: [PATCH] fix(VS): Adjust toast title --- src/Uno.UI.RemoteControl.VS/EntryPoint.cs | 13 ++++---- .../GlobalJsonObserver.cs | 8 ++--- .../Notifications/InfoBar.cs | 30 +++++++++---------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/Uno.UI.RemoteControl.VS/EntryPoint.cs b/src/Uno.UI.RemoteControl.VS/EntryPoint.cs index 3467cf518859..d73493b1ccc6 100644 --- a/src/Uno.UI.RemoteControl.VS/EntryPoint.cs +++ b/src/Uno.UI.RemoteControl.VS/EntryPoint.cs @@ -519,14 +519,11 @@ private async Task CreateInfoBarAsync(NotificationRequestIdeMessage e, IVsShell var infoBar = await _infoBarFactory.CreateAsync( new InfoBarModel( - e.Message, - e.Commands.Select(Commands => new ActionBarItem - { - Text = Commands.Text, - Name = Commands.Name, - ActionContext = Commands.Parameter, - IsButton = true, - }).ToArray(), + new ActionBarTextSpan[] { + new(e.Title, Bold: true), + new(e.Message) + }, + e.Commands.Select(Commands => new ActionBarItem(Commands.Text, Commands.Name, ActionContext: Commands.Parameter, IsButton: true)).ToArray(), e.Kind == NotificationKind.Information ? KnownMonikers.StatusInformation : KnownMonikers.StatusError, isCloseButtonVisible: true)); diff --git a/src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs b/src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs index e7d397e90fbe..1254ac2381b8 100644 --- a/src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs +++ b/src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs @@ -121,8 +121,8 @@ await _asyncPackage.GetServiceAsync(typeof(SVsShell)) is IVsShell shell && await _asyncPackage.GetServiceAsync(typeof(SVsInfoBarUIFactory)) is IVsInfoBarUIFactory infoBarFactory) { var factory = new InfoBarFactory(infoBarFactory, shell); - var restartVSItem = new ActionBarItem { Text = "Restart Visual Studio" }; - var moreInformationVSItem = new ActionBarItem { Text = "More information" }; + var restartVSItem = new ActionBarItem("Restart Visual Studio"); + var moreInformationVSItem = new ActionBarItem("More information"); var infoBar = await factory.CreateAsync( new InfoBarModel( @@ -141,7 +141,7 @@ await _asyncPackage.GetServiceAsync(typeof(SVsShell)) is IVsShell shell { _asyncPackage.JoinableTaskFactory.Run(async () => { - if (e.ActionItem == restartVSItem) + if (ReferenceEquals(e.ActionItem, restartVSItem)) { await _asyncPackage.JoinableTaskFactory.SwitchToMainThreadAsync(); @@ -152,7 +152,7 @@ await _asyncPackage.GetServiceAsync(typeof(SVsShell)) is IVsShell shell var hr = shell4.Restart((uint)type); } } - else if (e.ActionItem == moreInformationVSItem) + else if (ReferenceEquals(e.ActionItem, moreInformationVSItem)) { System.Diagnostics.Process.Start("https://aka.platform.uno/upgrade-uno-packages"); } diff --git a/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs b/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs index 524de5fa9b13..709954f22209 100644 --- a/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs +++ b/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs @@ -145,19 +145,17 @@ void IVsInfoBarUIEvents.OnActionItemClicked(IVsInfoBarUIElement infoBarUIElement } } -class ActionBarItem : IVsInfoBarActionItem -{ - public string? Text { get; set; } - - public string? Name { get; set; } - - public bool Bold { get; set; } - - public bool Italic { get; set; } - - public bool Underline { get; set; } - - public object? ActionContext { get; set; } - - public bool IsButton { get; set; } -} +record class ActionBarTextSpan( + string Text + , bool Bold = false + , bool Italic = false + , bool Underline = false) : IVsInfoBarTextSpan; + +record ActionBarItem( + string? Text + , string? Name = null + , bool Bold = false + , bool Italic = false + , bool Underline = false + , object? ActionContext = null + , bool IsButton = false) : IVsInfoBarActionItem;