Добавлен стандартный "поделиться ПЛ"
This commit is contained in:
45
PlaylistShared.Pwa/Components/Common/ShareDialog.razor
Normal file
45
PlaylistShared.Pwa/Components/Common/ShareDialog.razor
Normal file
@@ -0,0 +1,45 @@
|
||||
@inject IJSRuntime JS
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">Поделиться плейлистом</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudStack Spacing="2">
|
||||
<MudText>Скопируйте ссылку и отправьте её друзьям:</MudText>
|
||||
<MudTextField @bind-Value="ShareUrl"
|
||||
Variant="Variant.Outlined"
|
||||
ReadOnly="true"
|
||||
Margin="Margin.Dense"
|
||||
Class="mt-2" />
|
||||
</MudStack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
||||
OnClick="CopyToClipboard">
|
||||
Скопировать ссылку
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Default"
|
||||
OnClick="Close">
|
||||
Закрыть
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
public string ShareUrl { get; set; } = string.Empty;
|
||||
|
||||
private async Task CopyToClipboard()
|
||||
{
|
||||
await JS.InvokeVoidAsync("navigator.clipboard.writeText", ShareUrl);
|
||||
Snackbar.Add("Ссылка скопирована в буфер обмена!", Severity.Success);
|
||||
MudDialog.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
private void Close() => MudDialog.Cancel();
|
||||
}
|
||||
Reference in New Issue
Block a user