From a05c4c0a305507b95b07b6ea797857f028301be7 Mon Sep 17 00:00:00 2001 From: Vikram Reddy Date: Tue, 18 Jun 2024 23:43:11 +0530 Subject: [PATCH] Offcanvas demos updated. (#764) --- .../Offcanvas/Offcanvas_Demo_06_Events.razor | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/BlazorBootstrap.Demo.RCL/Components/Pages/Offcanvas/Offcanvas_Demo_06_Events.razor b/BlazorBootstrap.Demo.RCL/Components/Pages/Offcanvas/Offcanvas_Demo_06_Events.razor index fb50735e8..41e24b4d9 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Pages/Offcanvas/Offcanvas_Demo_06_Events.razor +++ b/BlazorBootstrap.Demo.RCL/Components/Pages/Offcanvas/Offcanvas_Demo_06_Events.razor @@ -1,9 +1,9 @@  + OnShowing="OnOffcanvasShowing" + OnShown="OnOffcanvasShown" + OnHiding="OnOffcanvasHiding" + OnHidden="OnOffcanvasHidden">
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
@@ -17,12 +17,30 @@ + + @code { private Offcanvas offcanvas = default!; + + List messages = new List(); + + private void ShowMessage(ToastType toastType, string message) + => messages.Add(CreateToastMessage(toastType, message)); + + private ToastMessage CreateToastMessage(ToastType toastType, string message) + => new ToastMessage + { + Type = toastType, + Title = "Blazor Bootstrap", + HelpText = $"{DateTime.Now}", + Message = $"Event {message}. DateTime: {DateTime.Now}", + }; + private async Task OnShowOffcanvasClick() => await offcanvas.ShowAsync(); private async Task OnHideOffcanvasClick() => await offcanvas.HideAsync(); - private async Task OnOffcanvasShowingAsync() => await Task.Run(() => { Console.WriteLine("Event: Showing"); }); - private async Task OnOffcanvasShownAsync() => await Task.Run(() => { Console.WriteLine("Event: Shown"); }); - private async Task OnOffcanvasHidingAsync() => await Task.Run(() => { Console.WriteLine("Event: Hiding"); }); - private async Task OnOffcanvasHiddenAsync() => await Task.Run(() => { Console.WriteLine("Event: Hidden"); }); + + private void OnOffcanvasShowing() => ShowMessage(ToastType.Primary, "Event: Showing"); + private void OnOffcanvasShown() => ShowMessage(ToastType.Secondary, "Event: Shown"); + private void OnOffcanvasHiding() => ShowMessage(ToastType.Success, "Event: Hiding"); + private void OnOffcanvasHidden() => ShowMessage(ToastType.Danger, "Event: Hidden"); } \ No newline at end of file