From b8a9a4d3e75ef4d5709c15345b3b0e6c81389b39 Mon Sep 17 00:00:00 2001 From: Michiel Post Date: Mon, 2 Sep 2024 14:38:18 +0200 Subject: [PATCH] Using webshare API for receive page --- src/aoWebWallet/Pages/ReceivePage.razor | 26 ++++++++++++++++++++----- src/aoWebWallet/Program.cs | 3 +++ src/aoWebWallet/aoWebWallet.csproj | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/aoWebWallet/Pages/ReceivePage.razor b/src/aoWebWallet/Pages/ReceivePage.razor index dad012c..3d486dd 100644 --- a/src/aoWebWallet/Pages/ReceivePage.razor +++ b/src/aoWebWallet/Pages/ReceivePage.razor @@ -2,6 +2,7 @@ @using ZXing; @using aoWebWallet.Models @using MudExtensions +@using Append.Blazor.WebShare @inherits MvvmComponentBase @inject GatewayUrlHelper UrlHelper; @inject IDialogService DialogService @@ -11,7 +12,7 @@ @inject TransactionService transactionService; @inject WalletDetailViewModel WalletDetailViewModel @inject ClipboardService ClipboardService - +@inject IWebShareService WebShareService Receive Tokens - @Program.PageTitlePostFix @@ -70,10 +71,11 @@ - - Share this page - - + + Share this page + + + @@ -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() diff --git a/src/aoWebWallet/Program.cs b/src/aoWebWallet/Program.cs index 759fddc..7d7ca73 100644 --- a/src/aoWebWallet/Program.cs +++ b/src/aoWebWallet/Program.cs @@ -17,6 +17,7 @@ using ArweaveAO.Models; using MudExtensions.Services; using Soenneker.Blazor.Utils.Navigation.Registrars; +using Append.Blazor.WebShare; namespace aoWebWallet { @@ -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()); diff --git a/src/aoWebWallet/aoWebWallet.csproj b/src/aoWebWallet/aoWebWallet.csproj index a9645d8..16a4269 100644 --- a/src/aoWebWallet/aoWebWallet.csproj +++ b/src/aoWebWallet/aoWebWallet.csproj @@ -12,6 +12,7 @@ +