mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
redesigned camera modal with paste button
This commit is contained in:
1 parent
df6989baf9
commit
5687faa746
3 files changed
+65
-72
No files matched your search
@@ -45,7 +45,7 @@ export function CashuWallet() {
|
||||
const { user } = useCurrentUser();
|
||||
const { getInvoice: getLightningInvoice, isLoading: isResolvingAddress } = useLightningAddress();
|
||||
const { toast } = useToast();
|
||||
const { generateQRCode, isScanning, startScanning, stopScanning, error: qrError } = useQRCode();
|
||||
const { generateQRCode, isScanning, startScanning, stopScanning, error: qrError, classifyQRCode } = useQRCode();
|
||||
const { copy: copyToClipboard } = useCopyToClipboard();
|
||||
const { hasNsecAccess } = useNsecAccess();
|
||||
|
||||
@@ -336,20 +336,8 @@ export function CashuWallet() {
|
||||
// Start/stop QR scanner when modal opens/closes
|
||||
useEffect(() => {
|
||||
if (showQRScanner) {
|
||||
// Lock body scroll on mobile
|
||||
document.body.style.overflow = 'hidden';
|
||||
document.body.style.position = 'fixed';
|
||||
document.body.style.width = '100%';
|
||||
document.body.style.height = '100%';
|
||||
|
||||
startScanning(handleQRScanResult);
|
||||
} else {
|
||||
// Restore body scroll
|
||||
document.body.style.overflow = '';
|
||||
document.body.style.position = '';
|
||||
document.body.style.width = '';
|
||||
document.body.style.height = '';
|
||||
|
||||
stopScanning();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -458,6 +446,31 @@ export function CashuWallet() {
|
||||
}
|
||||
};
|
||||
|
||||
// Handle paste from clipboard
|
||||
const handlePasteQRCode = async () => {
|
||||
try {
|
||||
const text = await navigator.clipboard.readText();
|
||||
if (!text || !text.trim()) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Clipboard Empty",
|
||||
description: "No text found in clipboard",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const result = classifyQRCode(text.trim());
|
||||
await handleQRScanResult(result);
|
||||
} catch (err) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Paste Failed",
|
||||
description: "Could not read from clipboard",
|
||||
});
|
||||
console.error('Error pasting from clipboard:', err);
|
||||
}
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// RENDER
|
||||
// ============================================================================
|
||||
@@ -594,6 +607,7 @@ export function CashuWallet() {
|
||||
setShowQRScanner={setShowQRScanner}
|
||||
stopScanning={stopScanning}
|
||||
qrError={qrError}
|
||||
onPasteQRCode={handlePasteQRCode}
|
||||
/>
|
||||
|
||||
{/* Bottom Drawer Modals */}
|
||||
|
||||
Reference in new issue
Block a user