-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
486 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@using Angor.Shared.Services | ||
@using Angor.Client.Models | ||
@using Nostr.Client.Messages | ||
@using Nostr.Client.Messages.Metadata | ||
@using QRCoder | ||
|
||
|
||
<div class="col-lg-6"> | ||
<h4 class="card-title">QR Code</h4> | ||
@if (!string.IsNullOrEmpty(base64qrcode)) | ||
{ | ||
<img src="data:image /png;base64,@base64qrcode" class="card-img-top qrcode" alt="QR Code"/> | ||
} | ||
</div> | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public string Data { get; set; } | ||
|
||
private static string lastqrcode; | ||
private static string lastaddress; | ||
private string base64qrcode; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
GenerateQRCode(Data); | ||
} | ||
|
||
public Task GenerateQRCode(string newData) | ||
{ | ||
Data = newData; | ||
|
||
if (lastaddress == Data) | ||
{ | ||
base64qrcode = lastqrcode; | ||
return Task.CompletedTask; | ||
} | ||
|
||
return Task.Run(() => | ||
{ | ||
base64qrcode = GenerateQRCodeInternal(Data); | ||
lastqrcode = base64qrcode; | ||
lastaddress = Data; | ||
|
||
StateHasChanged(); | ||
|
||
}); | ||
} | ||
|
||
public static string GenerateQRCodeInternal(string content) | ||
{ | ||
using QRCodeGenerator qrGenerator = new QRCodeGenerator(); | ||
using QRCodeData qrCodeData = qrGenerator.CreateQrCode(content, QRCodeGenerator.ECCLevel.Q); | ||
using PngByteQRCode pngByteQRCode = new PngByteQRCode(qrCodeData); | ||
return Convert.ToBase64String(pngByteQRCode.GetGraphic(10)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.