Skip to content

Commit

Permalink
perf: Add Alert binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed May 31, 2023
1 parent b64414c commit 6c7f6db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Uno.UWP/UI/Popups/MessageDialog.Interop.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ internal partial class MessageDialog
{
internal static partial class NativeMethods
{
[JSImport("globalThis.alert")]
internal static partial void Alert(string message);
}
}
}
#endif
#endif
4 changes: 4 additions & 0 deletions src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ private IAsyncOperation<IUICommand> ShowNativeAsync(CancellationToken ct)
{
VisualTreeHelperProxy.CloseAllFlyouts();

#if NET7_0_OR_GREATER
NativeMethods.Alert(Content);
#else
var command = $"Uno.UI.WindowManager.current.alert(\"{Uno.Foundation.WebAssemblyRuntime.EscapeJs(Content)}\");";
Uno.Foundation.WebAssemblyRuntime.InvokeJS(command);
#endif

return AsyncOperation.FromTask<IUICommand>(
ct => Task.FromResult<IUICommand>(new UICommand("OK")) // TODO: Localize (PBI 28711)
Expand Down

0 comments on commit 6c7f6db

Please sign in to comment.