share modal

This commit is contained in:
2025-10-03 13:36:18 +02:00
parent 8ea7f89c7b
commit dcc50506de
13 changed files with 377 additions and 54 deletions
+37
View File
@@ -0,0 +1,37 @@
import QRCode from "qrcode-terminal/vendor/QRCode";
import QRErrorCorrectLevel from "qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel";
const getErrorLevel = (level) => {
if (typeof level === "number") {
return level;
}
const normalized = String(level || "M").toUpperCase();
return QRErrorCorrectLevel?.[normalized] ?? QRErrorCorrectLevel.M;
};
export const generateQrMatrix = ({
value,
errorCorrectionLevel = "M",
}) => {
if (!value) {
throw new Error("generateQrMatrix requires a value");
}
const qr = new QRCode(-1, getErrorLevel(errorCorrectionLevel));
qr.addData(value);
qr.make();
const size = qr.getModuleCount();
const matrix = new Array(size);
for (let row = 0; row < size; row += 1) {
matrix[row] = new Array(size);
for (let col = 0; col < size; col += 1) {
matrix[row][col] = qr.isDark(row, col);
}
}
return { matrix, size };
};
+1 -1
View File
@@ -11,6 +11,7 @@ const defaultPayload = {
url: musiclandShareUrl,
shareTitle: "MusicLand",
shareMessage: musiclandShareMessage,
qrUrl: musiclandShareUrl,
};
export const openShareSheet = (payload = {}) => {
@@ -21,4 +22,3 @@ export const openShareSheet = (payload = {}) => {
},
});
};