Skip to content

Commit

Permalink
🐛 fix(Keys.razor): fix button click event to be async
Browse files Browse the repository at this point in the history
✨ feat(Wallets.razor): add copy button to text modal and implement copy function
  • Loading branch information
markettes committed Jun 19, 2023
1 parent b54c83e commit e6401e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Pages/Keys.razor
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
RowRemoving="OnRowRemoving"
RowUpdated="OnRowUpdated"
NewItemDefaultSetter="NewItemDefaultSetter">

<PopupTitleTemplate>
<h2>@(context.EditState) keys</h2>
</PopupTitleTemplate>
Expand Down Expand Up @@ -58,7 +58,7 @@
{
@StringHelper.TruncateHeadAndTail(context.XPUB, 6);
<span>&nbsp</span>
<Button Color="Color.Primary" Clicked="@(() => CopyStrToClipboard(context.XPUB))" Size="Size.Small" Outline>
<Button Color="Color.Primary" Clicked="@(async () => await CopyStrToClipboard(context.XPUB))" Size="Size.Small" Outline>
<i class="oi oi-clipboard"></i>
</Button>
}
Expand Down Expand Up @@ -98,7 +98,7 @@

private async Task GetData()
{

userKeys = await KeyRepository.GetUserKeys(_loggedUser);
}

Expand All @@ -109,7 +109,7 @@

var addResult = await KeyRepository.AddAsync(arg.Item);


if (addResult.Item1)
{
ToastService.ShowSuccess("Success");
Expand Down Expand Up @@ -152,15 +152,15 @@
}
}
}


private async Task OnRowUpdated(SavedRowItem<Key, Dictionary<string, object>> arg)
{
if (arg.Item == null) return;

var updateResult = KeyRepository.Update(arg.Item);


if (updateResult.Item1)
{
ToastService.ShowSuccess("Success");
Expand All @@ -177,7 +177,7 @@

private async Task CopyStrToClipboard(string arg)
{
await ClipboardService.WriteTextAsync(arg);
await ClipboardService.WriteTextAsync(arg);
ToastService.ShowSuccess("Text copied");
}

Expand Down
13 changes: 13 additions & 0 deletions src/Pages/Wallets.razor
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@
<p>@_textModalContent</p>
</ModalBody>
<ModalFooter>
@if (_textModalCopy)
{
<Button Color="Color.Primary" Clicked="@(async () => await CopyStrToClipboard(_textModalContent))">Copy</Button>
}
<Button Color="Color.Secondary" Clicked="@CloseTextModal">Close</Button>
</ModalFooter>
</ModalContent>
Expand Down Expand Up @@ -347,6 +351,7 @@
private Modal _textModalRef;
private string _textModalTitle = string.Empty;
private string _textModalContent = string.Empty;
private bool _textModalCopy;

private Modal _finaliseModalRef;
private Wallet? _selectedWalletToFinalise;
Expand Down Expand Up @@ -629,6 +634,7 @@
_textModalTitle = $"Wallet: {wallet.Name} On-chain Balance";
_textModalContent = $"Confirmed: {((Money) balance.Confirmed).ToUnit(MoneyUnit.BTC)} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(((Money) balance.Confirmed).ToUnit(MoneyUnit.BTC), _btcPrice), 2)} USD) - " +
$"Unconfirmed: {((Money) balance.Unconfirmed).ToUnit(MoneyUnit.BTC)} BTC ({Math.Round(PriceConversionHelper.BtcToUsdConversion(((Money) balance.Unconfirmed).ToUnit(MoneyUnit.BTC), _btcPrice), 2)} USD)";
_textModalCopy = false;

await _textModalRef.Show();
}
Expand All @@ -650,6 +656,7 @@
{
_textModalTitle = $"Unused BTC Address for funding this wallet";
_textModalContent = bitcoinAddress.ToString();
_textModalCopy = true;
await _textModalRef.Show();
}
else
Expand Down Expand Up @@ -818,4 +825,10 @@
}
}

private async Task CopyStrToClipboard(string arg)
{
await ClipboardService.WriteTextAsync(arg);
ToastService.ShowSuccess("Text copied");
}

}

0 comments on commit e6401e0

Please sign in to comment.