-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MessageBox] Add settable primary action text for Show... methods (#2808
) * Docu update * Fix #2805 by adding primary action parameter to message box shortcut methods
- Loading branch information
Showing
6 changed files
with
139 additions
and
36 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
82 changes: 82 additions & 0 deletions
82
examples/Demo/Shared/Pages/MessageBox/Examples/DialogMessageBoxAsyncCustomPrimary.razor
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,82 @@ | ||
@inject IDialogService DialogService | ||
|
||
|
||
<FluentStack> | ||
<FluentButton OnClick="@ShowSuccessAsync" Appearance="Appearance.Accent">Success</FluentButton> | ||
<FluentButton OnClick="@ShowWarningAsync" Appearance="Appearance.Accent">Warning</FluentButton> | ||
<FluentButton OnClick="@ShowErrorAsync" Appearance="Appearance.Accent">Error</FluentButton> | ||
<FluentButton OnClick="@ShowInformationAsync" Appearance="Appearance.Accent">Information</FluentButton> | ||
<FluentButton OnClick="@ShowConfirmationAsync" Appearance="Appearance.Accent">Confirmation</FluentButton> | ||
<FluentButton OnClick="@ShowMessageBoxLongAsync" Appearance="Appearance.Accent">Long message</FluentButton> | ||
<FluentButton OnClick="@ShowMessageBoxAsync" Appearance="Appearance.Accent">Custom message</FluentButton> | ||
</FluentStack> | ||
|
||
<p> | ||
Last result: @(canceled == null ? "" : (canceled == true ? "❌ Canceled" : "✅ OK")) | ||
</p> | ||
|
||
@code | ||
{ | ||
bool? canceled; | ||
|
||
private async Task ShowSuccessAsync() | ||
{ | ||
var dialog = await DialogService.ShowSuccessAsync("The action was a success", null, "Hooray!"); | ||
var result = await dialog.Result; | ||
canceled = result.Cancelled; | ||
} | ||
|
||
private async Task ShowWarningAsync() | ||
{ | ||
var dialog = await DialogService.ShowWarningAsync("This is your final warning", null, "Stop!"); | ||
var result = await dialog.Result; | ||
canceled = result.Cancelled; | ||
} | ||
|
||
private async Task ShowErrorAsync() | ||
{ | ||
var dialog = await DialogService.ShowErrorAsync("This is an error", null, "Oops"); | ||
var result = await dialog.Result; | ||
canceled = result.Cancelled; | ||
} | ||
|
||
private async Task ShowInformationAsync() | ||
{ | ||
var dialog = await DialogService.ShowInfoAsync("This is a message", null, "Confirm"); | ||
var result = await dialog.Result; | ||
canceled = result.Cancelled; | ||
} | ||
|
||
private async Task ShowConfirmationAsync() | ||
{ | ||
var dialog = await DialogService.ShowConfirmationAsync("Do you have two eyes?", "Yup", "Nope", "Eyes on you"); | ||
var result = await dialog.Result; | ||
canceled = result.Cancelled; | ||
} | ||
|
||
private async Task ShowMessageBoxLongAsync() | ||
{ | ||
var dialog = await DialogService.ShowInfoAsync("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum", null, "Excepteur"); | ||
var result = await dialog.Result; | ||
canceled = result.Cancelled; | ||
} | ||
|
||
private async Task ShowMessageBoxAsync() | ||
{ | ||
var dialog = await DialogService.ShowMessageBoxAsync(new DialogParameters<MessageBoxContent>() | ||
{ | ||
Content = new() | ||
{ | ||
Title = "My title", | ||
MarkupMessage = new MarkupString("My <strong>customized</strong> message"), | ||
Icon = new Icons.Regular.Size24.Games(), | ||
IconColor = Color.Success, | ||
}, | ||
PrimaryAction = "OK", | ||
SecondaryAction = "Cancel", | ||
Width = "300px", | ||
}); | ||
var result = await dialog.Result; | ||
canceled = result.Cancelled; | ||
} | ||
} |
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.