Skip to content

Commit

Permalink
Added navigate back option after send action
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Jun 23, 2024
1 parent 438ea4e commit 15511a5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
39 changes: 32 additions & 7 deletions src/aoWebWallet/Pages/ActionPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@inject TokenDataService dataService
@inject TransactionService transactionService;
@inject WalletDetailViewModel WalletDetailViewModel
@using Soenneker.Blazor.Utils.Navigation.Abstract
@inject INavigationUtil NavigationUtil

<PageTitle>@Program.PageTitlePostFix</PageTitle>

Expand All @@ -16,7 +18,7 @@

<SelectActiveWalletComponent ReadOnly="readOnly" />

@if(readOnly)
@if (readOnly)
{
<MudText>Please review your transaction:</MudText>
}
Expand All @@ -25,6 +27,10 @@

@if (!readOnly && !string.IsNullOrEmpty(BindingContext.ActiveWalletAddress))
{
if (NavigationUtil.CanNavigateBack)
{
<MudButton Color="Color.Secondary" Variant="Variant.Filled" OnClick="NavigationUtil.NavigateBack" Class="mt-8">Back</MudButton>
}
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Preview" Class="mt-8">Preview</MudButton>
<MudText Color="Color.Error">@validation</MudText>
}
Expand All @@ -47,14 +53,26 @@
}
</MudCardContent>
@* <MudCardActions>
<MudButton Variant="Variant.Text" Color="Color.Primary">Learn More</MudButton>
</MudCardActions> *@
<MudButton Variant="Variant.Text" Color="Color.Primary">Learn More</MudButton>
</MudCardActions> *@
</MudCard>
}

if (NavigationUtil.CanNavigateBack)
{
<MudButton Color="Color.Secondary" Variant="Variant.Filled" OnClick="NavigationUtil.NavigateBack" Class="mt-8">Back</MudButton>
}
<MudButton Class="px-12 mt-8 mr-2" Color="Color.Default" Variant="Variant.Filled" OnClick="Cancel">Cancel</MudButton>
<MudButton Class="px-12 mt-8" Color="Color.Primary" Variant="Variant.Filled" OnClick="Submit">Submit</MudButton>
}
else if (transactionService.LastTransaction.DataLoader.LoadingState == LoadingState.None && string.IsNullOrEmpty(transactionService.LastTransaction.Data?.Id))
{
if (NavigationUtil.CanNavigateBack)
{
<MudButton Color="Color.Secondary" Variant="Variant.Filled" OnClick="NavigationUtil.NavigateBack" Class="mt-8">Back</MudButton>
}
}


@if (transactionService.LastTransaction.DataLoader != null)
{
Expand All @@ -69,7 +87,14 @@
</MudText>
</MudStack>

<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="ReturnToWallet">Return to wallet</MudButton>
if (NavigationUtil.CanNavigateBack)
{
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="NavigationUtil.NavigateBack" Class="mt-8">Back</MudButton>
}
else
{
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="ReturnToWallet">Return to wallet</MudButton>
}
@* <MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="ViewTransaction">View Transaction</MudButton> *@
}
}
Expand All @@ -80,7 +105,7 @@
@code
{
private string? validation;

private bool readOnly = false;
private bool started = false;

Expand Down Expand Up @@ -144,7 +169,7 @@
return;

var wallet = BindingContext.WalletList.Data.Where(x => x.Address == BindingContext.ActiveWallet?.Address).FirstOrDefault();
if(wallet == null)
if (wallet == null)
{
if (BindingContext.ActiveWallet?.Address == BindingContext.ActiveWalletAddress)
{
Expand All @@ -162,6 +187,6 @@
await transactionService.SendAction(wallet, ownerWallet, AoAction);
}



}
9 changes: 8 additions & 1 deletion src/aoWebWallet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using aoWebWallet.Models;
using ArweaveAO.Models;
using MudExtensions.Services;
using Soenneker.Blazor.Utils.Navigation.Registrars;

namespace aoWebWallet
{
Expand Down Expand Up @@ -72,7 +73,11 @@ public static async Task Main(string[] args)

ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress);

await builder.Build().RunAsync();
WebAssemblyHost host = builder.Build();

host.Services.WarmupNavigation();

await host.RunAsync();
}

private static void ConfigureServices(IServiceCollection services, string baseAddress)
Expand Down Expand Up @@ -122,6 +127,8 @@ private static void ConfigureServices(IServiceCollection services, string baseAd

services.AddClipboard();

services.AddNavigationUtil();

//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 @@ -23,6 +23,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.6" PrivateAssets="all" />
<PackageReference Include="ReactorBlazorQRCodeScanner" Version="1.0.7" />
<PackageReference Include="Soenneker.Blazor.Utils.Navigation" Version="2.1.243" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 15511a5

Please sign in to comment.