-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 238 Toast * Add cancellation token tests * Fix action button is missed on long text * `dotnet format` Update code via new `.editorconfig` * Fix Namine Violation (remove `_` prefix) * Update Toast_Tests.cs * fix naming policy * Fix build * Update `CommunityToolkit.Maui.Markup` * IAlert, fix possible race conditions, add tests and fix sample * Add `Assert.IsAssignableFrom<IAlert>` * Remove Null Forgiving Operator * Fix CharacterSpacing, extract default values, add toast text size * Fix Android Toast text size, add tests * Remove `<InternalsVisibleTo Include="CommunityToolkit.Maui" />` * Remove `SemaphoreSlim`, Ensure `IAlert.Show` + `IAlert.Dismiss` always runs on MainThread * Use `ValueTask.CompletedTask` * Fix partial methods on Windows * Register ToastPage * Update dispose * Remove empty lines * Update src/CommunityToolkit.Maui/Alerts/Snackbar/SnackBar.shared.cs * Update src/CommunityToolkit.Maui/Alerts/Toast/Toast.shared.cs * Remove reference to `nativeSnackbar` and `nativeToast` backing field; Reference Property instead * Init only for snackbar and toast, small refactoring * Update Fluent Assertions NuGet Package * Keep static methods grouped together * Group partial methods together Co-authored-by: Brandon Minnick <[email protected]>
- Loading branch information
1 parent
170ffc5
commit 26007f7
Showing
26 changed files
with
684 additions
and
152 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
36 changes: 36 additions & 0 deletions
36
samples/CommunityToolkit.Maui.Sample/Pages/Alerts/ToastPage.xaml
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<pages:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages" | ||
xmlns:converters="clr-namespace:CommunityToolkit.Maui.Converters;assembly=CommunityToolkit.Maui" | ||
x:Class="CommunityToolkit.Maui.Sample.Pages.Alerts.ToastPage"> | ||
|
||
<pages:BasePage.Resources> | ||
<ResourceDictionary> | ||
<converters:ColorToColorForTextConverter x:Key="ColorToColorForTextConverter"/> | ||
</ResourceDictionary> | ||
</pages:BasePage.Resources> | ||
|
||
<VerticalStackLayout Spacing="12"> | ||
|
||
<Label Text="The Toast is a timed alert that appears at the bottom of the screen by default. It is dismissed after a configurable duration of time." | ||
LineBreakMode = "WordWrap" /> | ||
|
||
<Label Text="Windows uses toast notifications to display toast. Make sure you switched off Focus Assist." | ||
IsVisible="false"> | ||
<Label.IsVisible> | ||
<OnPlatform x:TypeArguments="x:Boolean"> | ||
<On Platform="UWP" Value="true" /> | ||
</OnPlatform> | ||
</Label.IsVisible> | ||
</Label> | ||
|
||
<Button Clicked="ShowToastButtonClicked" | ||
Text="Display Toast"/> | ||
|
||
<Button Clicked="ShowCustomToastButtonClicked" | ||
Text="Display Custom Toast"/> | ||
|
||
</VerticalStackLayout> | ||
|
||
</pages:BasePage> |
24 changes: 24 additions & 0 deletions
24
samples/CommunityToolkit.Maui.Sample/Pages/Alerts/ToastPage.xaml.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using CommunityToolkit.Maui.Alerts; | ||
using CommunityToolkit.Maui.Core; | ||
|
||
namespace CommunityToolkit.Maui.Sample.Pages.Alerts; | ||
|
||
public partial class ToastPage : BasePage | ||
{ | ||
public ToastPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
async void ShowToastButtonClicked(object? sender, EventArgs args) | ||
{ | ||
var toast = Toast.Make("This is a default Toast."); | ||
await toast.Show(); | ||
} | ||
|
||
async void ShowCustomToastButtonClicked(object? sender, EventArgs args) | ||
{ | ||
var toast = Toast.Make("This is a big Toast.", ToastDuration.Long, 30d); | ||
await toast.Show(); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
samples/CommunityToolkit.Maui.Sample/ViewModels/Alerts/SnackbarViewModel.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace CommunityToolkit.Maui.Sample.ViewModels.Alerts; | ||
|
||
public class SnackbarViewModel : BaseViewModel | ||
{ | ||
} |
5 changes: 5 additions & 0 deletions
5
samples/CommunityToolkit.Maui.Sample/ViewModels/Alerts/ToastViewModel.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace CommunityToolkit.Maui.Sample.ViewModels.Alerts; | ||
|
||
public class ToastViewModel : BaseViewModel | ||
{ | ||
} |
7 changes: 1 addition & 6 deletions
7
...unityToolkit.Maui.Sample/ViewModels/Converters/ItemSelectedEventArgsConverterViewModel.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
22 changes: 22 additions & 0 deletions
22
src/CommunityToolkit.Maui.Core/Interfaces/IAlert.shared.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace CommunityToolkit.Maui.Core; | ||
|
||
/// <summary> | ||
/// Alert | ||
/// </summary> | ||
public interface IAlert : IAsyncDisposable | ||
{ | ||
/// <summary> | ||
/// Message text | ||
/// </summary> | ||
string Text { get; } | ||
|
||
/// <summary> | ||
/// Dismiss the alert | ||
/// </summary> | ||
Task Dismiss(CancellationToken token = default); | ||
|
||
/// <summary> | ||
/// Show the alert | ||
/// </summary> | ||
Task Show(CancellationToken token = default); | ||
} |
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
33 changes: 33 additions & 0 deletions
33
src/CommunityToolkit.Maui.Core/Interfaces/IToast.shared.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace CommunityToolkit.Maui.Core; | ||
|
||
/// <summary> | ||
/// Toast | ||
/// </summary> | ||
public interface IToast : IAlert | ||
{ | ||
/// <summary> | ||
/// Toast duration | ||
/// </summary> | ||
ToastDuration Duration { get; } | ||
|
||
/// <summary> | ||
/// Toast font size | ||
/// </summary> | ||
double TextSize { get; } | ||
} | ||
|
||
/// <summary> | ||
/// Toast duration | ||
/// </summary> | ||
public enum ToastDuration | ||
{ | ||
/// <summary> | ||
/// Displays Toast for a short time | ||
/// </summary> | ||
Short, | ||
|
||
/// <summary> | ||
/// Displays Toast for a long time | ||
/// </summary> | ||
Long | ||
} |
33 changes: 33 additions & 0 deletions
33
src/CommunityToolkit.Maui.Core/Primitives/Defaults.shared.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.ComponentModel; | ||
|
||
namespace CommunityToolkit.Maui.Core; | ||
|
||
/// <summary> | ||
/// Default Values for CommunityToolkit.Maui | ||
/// </summary> | ||
public static class Defaults | ||
{ | ||
/// <summary> | ||
/// Default Font Size | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public const double FontSize = 14; | ||
|
||
/// <summary> | ||
/// Default Character Spacing | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public const double CharacterSpacing = 0.0d; | ||
|
||
/// <summary> | ||
/// Default Text Color | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static readonly Color TextColor = Colors.Black; | ||
|
||
/// <summary> | ||
/// Default Background Color | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static readonly Color BackgroundColor = Colors.LightGray; | ||
} |
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
Oops, something went wrong.