-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to net6.0 and minor updates (#164)
- Loading branch information
1 parent
beafa60
commit 40e43fc
Showing
38 changed files
with
2,125 additions
and
2,137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
using Blazored.Toast; | ||
using BlazorWebAssembly; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlazorWebAssembly | ||
{ | ||
public class Program | ||
{ | ||
public static async Task Main(string[] args) | ||
{ | ||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
builder.RootComponents.Add<App>("app"); | ||
builder.Services.AddBlazoredToast(); | ||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
|
||
await builder.Build().RunAsync(); | ||
} | ||
} | ||
} | ||
builder.RootComponents.Add<App>("#app"); | ||
builder.RootComponents.Add<HeadOutlet>("head::after"); | ||
|
||
builder.Services.AddBlazoredToast(); | ||
|
||
await builder.Build().RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 72 additions & 75 deletions
147
src/Blazored.Toast.TestExtensions/InMemoryToastService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,102 @@ | ||
using Blazored.Toast.Services; | ||
using Microsoft.AspNetCore.Components; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Blazored.Toast.TestExtensions | ||
namespace Blazored.Toast.TestExtensions; | ||
|
||
public class InMemoryToastService : IToastService | ||
{ | ||
public class InMemoryToastService : IToastService | ||
{ | ||
private readonly List<InMemoryToast> toasts = new List<InMemoryToast>(); | ||
public IReadOnlyList<InMemoryToast> Toasts => toasts; | ||
private readonly List<InMemoryToast> toasts = new List<InMemoryToast>(); | ||
public IReadOnlyList<InMemoryToast> Toasts => toasts; | ||
|
||
public event Action<ToastLevel, RenderFragment, string, Action> OnShow; | ||
public event Action<ToastLevel, RenderFragment, string, Action> OnShow; | ||
|
||
public event Action<Type, ToastParameters, ToastInstanceSettings> OnShowComponent; | ||
public event Action OnClearAll; | ||
public event Action<ToastLevel> OnClearToasts; | ||
public event Action OnClearCustomToasts; | ||
public event Action<Type, ToastParameters, ToastInstanceSettings> OnShowComponent; | ||
public event Action OnClearAll; | ||
public event Action<ToastLevel> OnClearToasts; | ||
public event Action OnClearCustomToasts; | ||
|
||
public void ShowToast<TComponent>() where TComponent : IComponent | ||
{ | ||
toasts.Add(new InMemoryToast(typeof(TComponent))); | ||
} | ||
public void ShowToast<TComponent>() where TComponent : IComponent | ||
{ | ||
toasts.Add(new InMemoryToast(typeof(TComponent))); | ||
} | ||
|
||
public void ShowToast<TComponent>(ToastParameters parameters) where TComponent : IComponent | ||
{ | ||
toasts.Add(new InMemoryToast(typeof(TComponent))); | ||
} | ||
public void ShowToast<TComponent>(ToastParameters parameters) where TComponent : IComponent | ||
{ | ||
toasts.Add(new InMemoryToast(typeof(TComponent))); | ||
} | ||
|
||
public void ShowToast<TComponent>(ToastInstanceSettings settings) where TComponent : IComponent | ||
{ | ||
toasts.Add(new InMemoryToast(typeof(TComponent))); | ||
} | ||
public void ShowToast<TComponent>(ToastInstanceSettings settings) where TComponent : IComponent | ||
{ | ||
toasts.Add(new InMemoryToast(typeof(TComponent))); | ||
} | ||
|
||
public void ShowToast<TComponent>(ToastParameters parameters, ToastInstanceSettings settings) where TComponent : IComponent | ||
{ | ||
toasts.Add(new InMemoryToast(typeof(TComponent))); | ||
} | ||
public void ShowToast<TComponent>(ToastParameters parameters, ToastInstanceSettings settings) where TComponent : IComponent | ||
{ | ||
toasts.Add(new InMemoryToast(typeof(TComponent))); | ||
} | ||
|
||
public void ShowError(string message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Error, message, heading, onClick); | ||
public void ShowError(string message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Error, message, heading, onClick); | ||
|
||
public void ShowError(RenderFragment message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Error, message, heading, onClick); | ||
public void ShowError(RenderFragment message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Error, message, heading, onClick); | ||
|
||
public void ShowInfo(string message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Info, message, heading, onClick); | ||
public void ShowInfo(string message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Info, message, heading, onClick); | ||
|
||
public void ShowInfo(RenderFragment message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Info, message, heading, onClick); | ||
public void ShowInfo(RenderFragment message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Info, message, heading, onClick); | ||
|
||
public void ShowSuccess(string message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Success, message, heading, onClick); | ||
public void ShowSuccess(string message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Success, message, heading, onClick); | ||
|
||
public void ShowSuccess(RenderFragment message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Success, message, heading, onClick); | ||
public void ShowSuccess(RenderFragment message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Success, message, heading, onClick); | ||
|
||
public void ShowToast(ToastLevel level, string message, string heading = "", Action onClick = null) | ||
=> ShowToast(level, builder => builder.AddContent(0, message), heading, onClick); | ||
public void ShowToast(ToastLevel level, string message, string heading = "", Action onClick = null) | ||
=> ShowToast(level, builder => builder.AddContent(0, message), heading, onClick); | ||
|
||
public void ShowToast(ToastLevel level, RenderFragment message, string heading = "", Action onClick = null) | ||
=> toasts.Add(new InMemoryToast(typeof(Configuration.ToastInstance), level, message, GetHeading(level, heading))); | ||
public void ShowToast(ToastLevel level, RenderFragment message, string heading = "", Action onClick = null) | ||
=> toasts.Add(new InMemoryToast(typeof(Configuration.ToastInstance), level, message, GetHeading(level, heading))); | ||
|
||
public void ShowWarning(string message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Warning, message, heading, onClick); | ||
public void ShowWarning(string message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Warning, message, heading, onClick); | ||
|
||
public void ShowWarning(RenderFragment message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Warning, message, heading, onClick); | ||
public void ShowWarning(RenderFragment message, string heading = "", Action onClick = null) | ||
=> ShowToast(ToastLevel.Warning, message, heading, onClick); | ||
|
||
private string GetHeading(ToastLevel level, string heading) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(heading)) return heading; | ||
private string GetHeading(ToastLevel level, string heading) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(heading)) return heading; | ||
|
||
return level switch | ||
{ | ||
ToastLevel.Error => "Error", | ||
ToastLevel.Info => "Info", | ||
ToastLevel.Success => "Success", | ||
ToastLevel.Warning => "Warning", | ||
_ => throw new InvalidOperationException(), | ||
}; | ||
} | ||
return level switch | ||
{ | ||
ToastLevel.Error => "Error", | ||
ToastLevel.Info => "Info", | ||
ToastLevel.Success => "Success", | ||
ToastLevel.Warning => "Warning", | ||
_ => throw new InvalidOperationException(), | ||
}; | ||
} | ||
|
||
public void ClearAll() | ||
=> toasts.Clear(); | ||
public void ClearAll() | ||
=> toasts.Clear(); | ||
|
||
public void ClearToasts(ToastLevel toastLevel) | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == toastLevel); | ||
public void ClearToasts(ToastLevel toastLevel) | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == toastLevel); | ||
|
||
public void ClearWarningToasts() | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == ToastLevel.Warning); | ||
public void ClearWarningToasts() | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == ToastLevel.Warning); | ||
|
||
public void ClearInfoToasts() | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == ToastLevel.Info); | ||
public void ClearInfoToasts() | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == ToastLevel.Info); | ||
|
||
public void ClearSuccessToasts() | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == ToastLevel.Success); | ||
public void ClearSuccessToasts() | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == ToastLevel.Success); | ||
|
||
public void ClearErrorToasts() | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == ToastLevel.Error); | ||
public void ClearErrorToasts() | ||
=> toasts.RemoveAll(x => x.ToastType == typeof(Configuration.ToastInstance) && x.ToastLevel == ToastLevel.Error); | ||
|
||
public void ClearCustomToasts() | ||
=> toasts.RemoveAll(x => x.ToastType != typeof(Configuration.ToastInstance)); | ||
} | ||
public void ClearCustomToasts() | ||
=> toasts.RemoveAll(x => x.ToastType != typeof(Configuration.ToastInstance)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.