Skip to content

Commit

Permalink
Merge pull request #18653 from jeromelaban/dev/jela/toast-title
Browse files Browse the repository at this point in the history
fix(VS): Adjust toast title
  • Loading branch information
jeromelaban authored Nov 5, 2024
2 parents 94b1943 + e9fb0bc commit 0a7ad2f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
13 changes: 5 additions & 8 deletions src/Uno.UI.RemoteControl.VS/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
8 changes: 4 additions & 4 deletions src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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();

Expand All @@ -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");
}
Expand Down
30 changes: 14 additions & 16 deletions src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 0a7ad2f

Please sign in to comment.