Skip to content

Commit

Permalink
Using webshare API for receive page
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Sep 2, 2024
1 parent 69af23f commit b8a9a4d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/aoWebWallet/Pages/ReceivePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@using ZXing;
@using aoWebWallet.Models
@using MudExtensions
@using Append.Blazor.WebShare
@inherits MvvmComponentBase<ReceiveViewModel>
@inject GatewayUrlHelper UrlHelper;
@inject IDialogService DialogService
Expand All @@ -11,7 +12,7 @@
@inject TransactionService transactionService;
@inject WalletDetailViewModel WalletDetailViewModel
@inject ClipboardService ClipboardService

@inject IWebShareService WebShareService

<PageTitle>Receive Tokens - @Program.PageTitlePostFix</PageTitle>

Expand Down Expand Up @@ -70,10 +71,11 @@
<MudIconButton Class="copy-clipboard" Icon="@Icons.Material.Filled.ContentCopy" Color="Color.Default" OnClick="async () => { await ClipboardService.CopyToClipboard(shareUrl); }" />
</MudStack>
<MudStack Spacing="0" Row="true">
<MudLink Href="@NavigationManager.Uri" Target="_blank" Typo="Typo.subtitle1">
Share this page
</MudLink>
<MudIconButton Class="copy-clipboard" Icon="@Icons.Material.Filled.ContentCopy" Color="Color.Default" OnClick="async () => { await ClipboardService.CopyToClipboard(NavigationManager.Uri); }" />
<MudStack Spacing="0" Row="true">
<MudText Typo="Typo.subtitle1">Share this page</MudText>
<MudIconButton Class="copy-clipboard" Icon="@Icons.Material.Filled.ContentCopy" Color="Color.Default" OnClick="async () => { await ClipboardService.CopyToClipboard(NavigationManager.Uri); }" />
<MudIconButton Class="copy-clipboard" Icon="@Icons.Material.Filled.Share" Color="Color.Default" OnClick="SharePage" />
</MudStack>
</MudStack>
</MudStack>
</MudPaper>
Expand Down Expand Up @@ -167,6 +169,20 @@
});
}

private async Task SharePage()
{
bool IsSupported = await WebShareService.IsSupportedAsync();
if (IsSupported)
{
await WebShareService.ShareAsync($"Send tokens to {@Address}", $"Use this page to send tokens to {@Address}", NavigationManager.Uri);
}
else
{
await ClipboardService.CopyToClipboard(NavigationManager.Uri);
//Snackbar.Add("Sharing not supported on this device.", Severity.Warning);
}
}



protected override async Task OnParametersSetAsync()
Expand Down
3 changes: 3 additions & 0 deletions src/aoWebWallet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using ArweaveAO.Models;
using MudExtensions.Services;
using Soenneker.Blazor.Utils.Navigation.Registrars;
using Append.Blazor.WebShare;

namespace aoWebWallet
{
Expand Down Expand Up @@ -129,6 +130,8 @@ private static void ConfigureServices(IServiceCollection services, string baseAd

services.AddNavigationUtil();

services.AddWebShare();

//Options
services.AddSingleton(new GraphqlConfig());
services.AddSingleton(new GatewayConfig());
Expand Down
1 change: 1 addition & 0 deletions src/aoWebWallet/aoWebWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Append.Blazor.WebShare" Version="7.0.0" />
<PackageReference Include="ArweaveAO" Version="0.0.8" />
<PackageReference Include="ArweaveBlazor" Version="0.0.10" />
<PackageReference Include="ClipLazor" Version="2.1.1" />
Expand Down

0 comments on commit b8a9a4d

Please sign in to comment.