Skip to content

Commit

Permalink
Merge branch 'master' into feature/meme-frames
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost authored Jun 21, 2024
2 parents 6728e8c + 9598a2d commit 7546eac
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 33 deletions.
16 changes: 12 additions & 4 deletions src/aoWebWallet/Pages/ReceivePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,20 @@
{
<MudItem xs="12">
<MudPaper Class="pa-4">

@{
var itemName = "AOS Command";
var aosCommandText = "Send({ Target = \"" + BindingContext.Token.TokenId + "\", Action = \"Transfer\", Recipient = \"" + Address + "\", Quantity = \"TOKEN_AMOUNT\"})";
}
<MudStack>
<MudText Typo="Typo.h6">aos command</MudText>
<MudText Class="KodeMono" Typo="Typo.subtitle1">
Send({ Target = "@BindingContext.Token.TokenId", Action = "Transfer", Recipient = "@Address", Quantity = "TOKEN_AMOUNT"})
</MudText>
<MudStack Row="true">
<MudText Class="KodeMono" Typo="Typo.subtitle1">
@aosCommandText
</MudText>
<MudIconButton Class="copy-clipboard" Icon="@Icons.Material.Filled.ContentCopy" Color="Color.Default" OnClick="async () => { await ClipboardService.CopyToClipboard(aosCommandText, itemName); }" />

</MudStack>

</MudStack>
</MudPaper>
</MudItem>
Expand Down
6 changes: 5 additions & 1 deletion src/aoWebWallet/Pages/WalletDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
<MudText Typo="Typo.body2">@BindingContext.SelectedWallet?.Wallet.Name</MudText>
@if (BindingContext.SelectedWallet?.Wallet.OwnerAddress != null)
{
<MudChip>owner: @BindingContext.SelectedWallet?.Wallet.OwnerAddress</MudChip>
string ownerUrl = $"/wallet/{BindingContext.SelectedWallet.Wallet.OwnerAddress}";

<MudLink Href="@ownerUrl">
<MudChip>owner: @BindingContext.SelectedWallet?.Wallet.OwnerAddress</MudChip>
</MudLink>
}
</MudStack>
@if (BindingContext.SelectedWallet?.Wallet.NeedsBackup ?? false)
Expand Down
4 changes: 2 additions & 2 deletions src/aoWebWallet/Services/ClipboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace aoWebWallet.Services
{
public class ClipboardService(IClipLazor clipboard, ISnackbar snackbar)
{
public async Task CopyToClipboard(string? text)
public async Task CopyToClipboard(string? text, string? itemName = "Address")
{
bool isSupported = await clipboard.IsClipboardSupported();
bool isWritePermitted = await clipboard.IsPermitted(PermissionCommand.Write);
Expand All @@ -17,7 +17,7 @@ public async Task CopyToClipboard(string? text)
var isCopied = await clipboard.WriteTextAsync(text.AsMemory());
if (isCopied)
{
snackbar.Add("Address copied to clipboard", Severity.Success);
snackbar.Add($"{itemName} copied to clipboard", Severity.Success);
}
}
}
Expand Down
60 changes: 34 additions & 26 deletions src/aoWebWallet/Shared/Components/ActionQuantityComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,46 @@
@* <p>@ActionParam.Key = @ActionParam.Value | @ActionParam.ParamType</p> *@

<MudItem>
@if(Token == null)
{
<MudText>Loading token data...</MudText>
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
return;
}
@if (ActionParam.ParamType == ActionParamType.Balance && string.IsNullOrEmpty(Address))
{
<MudText>Please select a wallet...</MudText>
return;
}
@if (ActionParam.ParamType == ActionParamType.Balance && BalanceData == null && !ReadOnly)
{
<MudText>Loading balance...</MudText>
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
return;
}
@if (Token == null)
{
<MudText>Loading token data...</MudText>
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
return;
}
@if (ActionParam.ParamType == ActionParamType.Balance && string.IsNullOrEmpty(Address))
{
<MudText>Please select a wallet...</MudText>
return;
}
@if (ActionParam.ParamType == ActionParamType.Balance && BalanceData == null && !ReadOnly)
{
<MudText>Loading balance...</MudText>
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
return;
}

@if (ReadOnly)
{
@if (ReadOnly)
{
<MudChip>@ActionParam.Key</MudChip> <MudChip Color="Color.Secondary"> @BalanceHelper.FormatBalance(long.Parse(ActionParam.Value ?? "0"), Token?.TokenData?.Denomination ?? 0) @Token?.TokenData?.Ticker</MudChip>
}
else
{
if (ActionParam.ParamType == ActionParamType.Quantity
|| ActionParam.ParamType == ActionParamType.Balance)
|| ActionParam.ParamType == ActionParamType.Balance)
{
var label = $"{ActionParam.Key} ({Token?.TokenData?.Ticker})";

<MudStack Row="true">
<MudTextField @ref="mudTextField" T="decimal" Label="@label" Variant="Variant.Text" ValueChanged="UpdateDecimalValue" Format="@DenominationFormat" Validation="@(new Func<decimal, IEnumerable<string>>(ValidateBalance))"></MudTextField>
@*<MudText>@Token?.TokenData?.Ticker</MudText>*@
</MudStack>
</MudStack>

if (ActionParam.ParamType == ActionParamType.Balance)
{
<MudChip style="border-radius:0;" Variant="Variant.Text" Color="Color.Success">Balance available: <br/> @BalanceHelper.FormatBalance(BalanceData?.Balance, Token?.TokenData?.Denomination ?? 1) @Token?.TokenData?.Ticker</MudChip>
if (ActionParam.ParamType == ActionParamType.Balance)
{
<MudChip style="border-radius:0;" Variant="Variant.Text" Color="Color.Success" OnClick="SetBalance">Balance available: <br /> @BalanceHelper.FormatBalance(BalanceData?.Balance, Token?.TokenData?.Denomination ?? 1) @Token?.TokenData?.Ticker</MudChip>
}
}
}
}
</MudItem>

@code {
Expand Down Expand Up @@ -103,7 +103,7 @@
yield return "Must be greater or equal than 0.";
}

if(e > 0)
if (e > 0)
{

if (ActionParam.ParamType == ActionParamType.Balance)
Expand Down Expand Up @@ -149,4 +149,12 @@
StateHasChanged();
}

private void SetBalance()
{
if(mudTextField != null)
{
mudTextField.SetText(BalanceHelper.FormatBalance(BalanceData?.Balance, Token?.TokenData?.Denomination ?? 1));
}
}

}

0 comments on commit 7546eac

Please sign in to comment.