test(android app): this is the start to the android app

This commit is contained in:
2025-11-15 16:22:19 -06:00
parent eb6b9ce388
commit 7b630d5c0b
25 changed files with 14215 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
import React, { useEffect, useRef, useState } from "react";
import { Text, TextInput, View } from "react-native";
export default function HiddenScannerListener({ onScan }: { onScan: any }) {
const [buffer, setBuffer] = useState("");
const inputRef = useRef<TextInput>(null);
// Keep focusing the invisible input
useEffect(() => {
const timer = setInterval(() => {
if (inputRef.current) inputRef.current.focus();
}, 500);
return () => clearInterval(timer);
}, []);
const handleChange = (text: string) => {
// Most scanners append '\n' (Enter) or '\t'; trim and send
if (text.endsWith("\n") || text.endsWith("\t")) {
const code = text.trim();
if (code) onScan?.(code);
setBuffer("");
} else {
setBuffer(text);
}
};
return (
<TextInput
ref={inputRef}
value={buffer}
onChangeText={handleChange}
autoFocus
style={{
position: "absolute",
opacity: 0, // invisible
height: 0, // takes no space
width: 0,
}}
/>
);
}