From cd4dfd7a1fbfba14132296e223c950038e38cba7 Mon Sep 17 00:00:00 2001 From: Michiel Post Date: Thu, 28 Mar 2024 11:10:11 +0100 Subject: [PATCH] Menu update and short addresses helper --- .../Extensions/AddressExtensions.cs | 10 ++++ src/aoWebWallet/Pages/WalletDetail.razor | 23 ++++++-- src/aoWebWallet/Pages/WalletDetail.razor.cs | 9 +++- src/aoWebWallet/Pages/Wallets.razor | 7 ++- src/aoWebWallet/Shared/NavMenu.razor | 53 ++++++++++++------- src/aoWebWallet/ViewModels/MainViewModel.cs | 9 +++- src/aoWebWallet/_Imports.razor | 3 +- 7 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 src/aoWebWallet/Extensions/AddressExtensions.cs diff --git a/src/aoWebWallet/Extensions/AddressExtensions.cs b/src/aoWebWallet/Extensions/AddressExtensions.cs new file mode 100644 index 0000000..cc6cae3 --- /dev/null +++ b/src/aoWebWallet/Extensions/AddressExtensions.cs @@ -0,0 +1,10 @@ +namespace aoWebWallet.Extensions +{ + public static class AddressExtensions + { + public static string ToShortAddress(this string address) + { + return address[0..7] + "..." + address[^7..]; + } + } +} diff --git a/src/aoWebWallet/Pages/WalletDetail.razor b/src/aoWebWallet/Pages/WalletDetail.razor index 387c1e3..4a06bcb 100644 --- a/src/aoWebWallet/Pages/WalletDetail.razor +++ b/src/aoWebWallet/Pages/WalletDetail.razor @@ -17,15 +17,30 @@ @Address @BindingContext.SelectedWallet?.Name + @if (BindingContext.SelectedWallet?.NeedsBackup ?? false) + { + + + Wallet not backed up yet! + + } + @if (!string.IsNullOrEmpty(BindingContext.SelectedWallet?.Jwk)) + { + + + + } - + @if(BindingContext.SelectedWallet?.Source == WalletTypes.Explorer) { - + + + } @@ -73,9 +88,9 @@ } - +@* - + *@ diff --git a/src/aoWebWallet/Pages/WalletDetail.razor.cs b/src/aoWebWallet/Pages/WalletDetail.razor.cs index cf5eec0..500b868 100644 --- a/src/aoWebWallet/Pages/WalletDetail.razor.cs +++ b/src/aoWebWallet/Pages/WalletDetail.razor.cs @@ -1,4 +1,5 @@ -using aoWebWallet.ViewModels; +using aoWebWallet.Models; +using aoWebWallet.ViewModels; using Microsoft.AspNetCore.Components; using MudBlazor; @@ -43,5 +44,11 @@ protected override async Task LoadDataAsync() await base.LoadDataAsync(); } + private async void DownloadWallet(Wallet wallet) + { + await BindingContext.DownloadWallet(wallet); + StateHasChanged(); + } + } } diff --git a/src/aoWebWallet/Pages/Wallets.razor b/src/aoWebWallet/Pages/Wallets.razor index 9131c47..c9502f7 100644 --- a/src/aoWebWallet/Pages/Wallets.razor +++ b/src/aoWebWallet/Pages/Wallets.razor @@ -19,7 +19,6 @@ } - @if (BindingContext.WalletList.Data != null && BindingContext.WalletList.Data.Any()) @@ -95,6 +94,12 @@ } } + else + { + Loading wallets... + + + } diff --git a/src/aoWebWallet/Shared/NavMenu.razor b/src/aoWebWallet/Shared/NavMenu.razor index 5002fa3..aee6a91 100644 --- a/src/aoWebWallet/Shared/NavMenu.razor +++ b/src/aoWebWallet/Shared/NavMenu.razor @@ -2,24 +2,38 @@ -@* -
- - j7hh8628... -
-
- - aGh8628... -
-
*@ - Wallets + @if ((BindingContext.WalletList.Data ?? new()).Any()) + { + Home + + @{ + int logoCount = 1; + } + @foreach (var wallet in BindingContext.WalletList.Data ?? new()) + { + string logoUrl = $"images/account--{logoCount}.svg"; + string detailUrl = $"wallet/{wallet.Address}"; + + + + @wallet.Address.ToShortAddress() + + logoCount++; + } + + } + else + { + Wallets + } + Token Explorer
- Settings - About -
+ Settings + About +
@if (BindingContext.UserSettings?.IsDarkMode ?? true) { @@ -33,19 +47,22 @@
-
- +
+ + Width="66" Class="pt-2" Alt="AOWW Logotype" /> Copyright @DateTimeOffset.UtcNow.Year
-@code{ +@code { private string[] icons = { Icons.Material.Filled.WbSunny, Icons.Material.Filled.NightlightRound }; + int logoCount = 1; protected override void OnInitialized() { + WatchDataLoaderVM(BindingContext.WalletList); + BindingContext.PropertyChanged += BindingContext_PropertyChanged; base.OnInitialized(); diff --git a/src/aoWebWallet/ViewModels/MainViewModel.cs b/src/aoWebWallet/ViewModels/MainViewModel.cs index 546b9b6..31583c6 100644 --- a/src/aoWebWallet/ViewModels/MainViewModel.cs +++ b/src/aoWebWallet/ViewModels/MainViewModel.cs @@ -274,8 +274,13 @@ public async Task DownloadWallet(Wallet wallet) if (this.WalletList.Data != null) { - await storageService.SaveWalletList(this.WalletList.Data); - //await LoadWalletList(); + var selected = this.WalletList.Data.Where(x => x.Address == address).FirstOrDefault(); + if(selected != null) + { + selected.LastBackedUpDate = DateTimeOffset.UtcNow; + await storageService.SaveWalletList(this.WalletList.Data); + //await LoadWalletList(); + } } } diff --git a/src/aoWebWallet/_Imports.razor b/src/aoWebWallet/_Imports.razor index 4f56d36..f47c765 100644 --- a/src/aoWebWallet/_Imports.razor +++ b/src/aoWebWallet/_Imports.razor @@ -17,4 +17,5 @@ @using MudBlazor @using webvNext.DataLoader @using ArweaveAO -@using ArweaveBlazor \ No newline at end of file +@using ArweaveBlazor +@using aoWebWallet.Extensions \ No newline at end of file