remove dialog dependency for camera modal

This commit is contained in:
lemonknowsall committed 2025-10-27 15:47:18 -07:00
1 parent 025cd9ed5e
commit df6989baf9
2 files changed
+66 -21

No files matched your search

+12
View File
@@ -336,8 +336,20 @@ export function CashuWallet() {
// Start/stop QR scanner when modal opens/closes // Start/stop QR scanner when modal opens/closes
useEffect(() => { useEffect(() => {
if (showQRScanner) { 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); startScanning(handleQRScanResult);
} else { } else {
// Restore body scroll
document.body.style.overflow = '';
document.body.style.position = '';
document.body.style.width = '';
document.body.style.height = '';
stopScanning(); stopScanning();
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
+54 -21
View File
@@ -5,7 +5,6 @@ import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label'; import { Label } from '@/components/ui/label';
import { X, Coins, AlertTriangle, RefreshCw, Key, ArrowRightLeft, Loader2 } from 'lucide-react'; import { X, Coins, AlertTriangle, RefreshCw, Key, ArrowRightLeft, Loader2 } from 'lucide-react';
import { QRModal } from '@/components/ui/qr-modal'; import { QRModal } from '@/components/ui/qr-modal';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { nip19 } from 'nostr-tools'; import { nip19 } from 'nostr-tools';
import { useToast } from '@/hooks/useToast'; import { useToast } from '@/hooks/useToast';
import { UTXO } from '@/lib/bitcoin'; import { UTXO } from '@/lib/bitcoin';
@@ -484,50 +483,84 @@ export function WalletModals({
</div> </div>
)} )}
{/* QR Scanner Modal */} {/* QR Scanner Modal - Full Screen Overlay */}
{showQRScanner && ( {showQRScanner && (
<Dialog open={showQRScanner} onOpenChange={(open) => { <div
if (!open) {
setShowQRScanner(false);
stopScanning();
}
}}>
<DialogContent
className="max-w-none w-screen h-[100dvh] p-0 m-0 bg-black border-0 rounded-none !top-0 !left-0 !right-0 !bottom-0 !translate-x-0 !translate-y-0 flex flex-col overflow-hidden [&>button]:absolute [&>button]:top-4 [&>button]:right-4 [&>button]:z-50 [&>button]:text-white [&>button]:bg-black/50 [&>button]:hover:bg-black/70"
style={{ style={{
position: 'fixed', position: 'fixed',
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
transform: 'none',
maxWidth: '100vw',
maxHeight: '100dvh',
height: '100dvh',
width: '100vw', width: '100vw',
height: '100dvh',
zIndex: 9999,
backgroundColor: '#000',
margin: 0, margin: 0,
padding: 0, padding: 0,
inset: 0 overflow: 'hidden'
}} }}
> >
<div id="qr-reader" style={{ {/* Close button */}
<button
onClick={() => {
setShowQRScanner(false);
stopScanning();
}}
style={{
position: 'absolute',
top: '16px',
right: '16px',
zIndex: 10000,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
border: 'none',
borderRadius: '8px',
padding: '12px',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
aria-label="Close scanner"
>
<X className="h-6 w-6 text-white" />
</button>
{/* Camera view */}
<div
id="qr-reader"
style={{
position: 'absolute', position: 'absolute',
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
width: '100%', width: '100%',
height: '100%' height: '100%',
}}></div> overflow: 'hidden'
}}
/>
{/* Error message */} {/* Error message */}
{qrError && ( {qrError && (
<div className="absolute bottom-20 left-4 right-4 p-3 bg-destructive text-destructive-foreground rounded z-50"> <div
style={{
position: 'absolute',
bottom: '80px',
left: '16px',
right: '16px',
padding: '12px',
backgroundColor: 'rgb(239, 68, 68)',
color: 'white',
borderRadius: '8px',
zIndex: 10000,
textAlign: 'center'
}}
>
{qrError} {qrError}
</div> </div>
)} )}
</DialogContent> </div>
</Dialog>
)} )}
</> </>
); );