This commit is contained in:
Chris Kruining 2026-02-09 16:35:08 +01:00
parent 83ab4df537
commit b4e4ff73ec
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
8 changed files with 427 additions and 10586 deletions

View file

@ -19,7 +19,7 @@ import { api } from "../../convex/_generated/api";
import { useCameraPermission } from "@/lib/hooks/useCamera";
import { useCurrentUser } from "@/lib/hooks";
import { useHashCache } from "@/lib/context";
import { recognizeCard } from "@/lib/recognition";
import { recognizeCard, configureDebug } from "@/lib/recognition";
import { loadImageAsBase64 } from "@/lib/recognition/imageLoader";
import { decodeImageBase64 } from "@/lib/recognition/skiaDecoder";
import { AdaptiveCamera, CameraHandle, isExpoGo } from "@/components/camera";
@ -49,6 +49,7 @@ export default function ScanScreen() {
const [isAddingToCollection, setIsAddingToCollection] = useState(false);
const [lastScanResult, setLastScanResult] = useState<ScanResult | null>(null);
const [scanError, setScanError] = useState<string | null>(null);
const [debugEnabled, setDebugEnabled] = useState(false);
// Hash cache from context
const { cardHashes, hashesLoaded } = useHashCache();
@ -64,6 +65,17 @@ export default function ScanScreen() {
lastScanResult ? { scryfallId: lastScanResult.cardId } : "skip"
);
// Toggle debug mode
const toggleDebug = useCallback(() => {
const newState = !debugEnabled;
setDebugEnabled(newState);
configureDebug({
enabled: newState,
albumName: "Scry Debug",
});
console.log("[Scry] Debug mode:", newState ? "ON" : "OFF");
}, [debugEnabled]);
const clearScanState = useCallback(() => {
setLastScanResult(null);
setScanError(null);
@ -121,6 +133,7 @@ export default function ScanScreen() {
enableCardDetection: true,
enableRotationMatching: true,
minConfidence: 0.85,
debug: debugEnabled,
}
);
@ -151,7 +164,7 @@ export default function ScanScreen() {
} finally {
setIsProcessing(false);
}
}, [isProcessing, hashesLoaded, cardHashes]);
}, [isProcessing, hashesLoaded, cardHashes, debugEnabled]);
const handleAddToCollection = useCallback(async () => {
if (!lastScanResult || !userId || !getCardByScryfallId) return;
@ -318,8 +331,14 @@ export default function ScanScreen() {
)}
</Pressable>
{/* Placeholder for symmetry */}
<View style={styles.controlButton} />
{/* Debug toggle */}
<Pressable style={styles.controlButton} onPress={toggleDebug}>
<FontAwesome
name="bug"
size={24}
color={debugEnabled ? "#FF6B6B" : "#fff"}
/>
</Pressable>
</View>
</View>
);