Qrcode port (#141)

* Qrcode port

* Add cache flag

* tweaks
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-09-08 19:34:17 -04:00
1 parent 0703d74e4b
commit 976d5a3fec
42 files changed
+1608 -2087

No files matched your search

@@ -1,8 +1,30 @@
import "pkg:/source/QrCode/QrImage.bs"
import "pkg:/source/utils/StringUtils.bs"
@asynctask
function GenerateQrCodeTask(input as object)
' TODO:P1 QR Code generation is happening on UI thread and is hanging for a second
' Needs to be properly decoupled from Node logic
qrPoster = input.qrPoster
poster = input.poster
mode = input.mode
text = input.text
qrPoster.text = text
size = input.size
padding = input.padding
if mode = invalid
mode = QrCode.QRMode.Byte
end if
if size = invalid
size = 200
end if
if padding = invalid
padding = 0
end if
qr = new QrCode.QRImage()
imagePath = qr.Generate(text, size, padding, mode)
if not StringUtils.IsNullOrEmpty(imagePath)
poster.uri = imagePath
end if
end function
@@ -21,6 +21,11 @@ function OnUrlSet()
urlLabel = m.top.findNode("urlLabel")
urlLabel.text = url
qrCode = m.top.findNode("QrCodePoster")
StartAsyncTask(GenerateQrCodeTask, { qrPoster: qrCode, text: url })
qrCodePoster = m.top.findNode("QrCodePoster")
StartAsyncTask(GenerateQrCodeTask, {
poster: qrCodePoster,
text: url,
size: qrCodePoster.loadWidth,
padding: 20
})
end function
@@ -26,11 +26,12 @@
translation="[0,92]"
text="Scan the QR code with your phone camera, or open the URL in a web browser:"
/>
<QRPoster
<Poster
id='QrCodePoster'
loadWidth='400'
height='400'
width='400'
loadHeight='400'
loadPadding='20'
loadWidth='400'
translation='[440, 160]' />
<Label