feat(mobile): shadcn like and tailwind added to make things look yummy
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m21s
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m21s
This commit is contained in:
@@ -1,19 +1,39 @@
|
||||
import { Tabs } from "expo-router";
|
||||
import { Home, Settings } from "lucide-react-native";
|
||||
import { useAppStore } from "../../hooks/useAppStore";
|
||||
|
||||
export default function TabsLayout() {
|
||||
const serverPort = useAppStore((s) => s.serverPort);
|
||||
return (
|
||||
<Tabs
|
||||
screenOptions={{
|
||||
headerShown: false, // Hides the header for all screens in this navigator
|
||||
}}>
|
||||
<Tabs.Screen name="scanner" options={{ title: "Scan" }} />
|
||||
<Tabs.Screen name="config" options={{ title: "settings" }} />
|
||||
<Tabs.Screen name="logs" options={{ title: "Logs",
|
||||
href: parseInt(serverPort || "0", 10) >= 50000 ? null : "/(tabs)/logs",
|
||||
}}
|
||||
/>
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
const serverPort = useAppStore((s) => s.serverPort);
|
||||
return (
|
||||
<Tabs
|
||||
screenOptions={{
|
||||
headerShown: false, // Hides the header for all screens in this navigator
|
||||
}}
|
||||
>
|
||||
<Tabs.Screen
|
||||
name="scanner"
|
||||
options={{
|
||||
title: "Scan",
|
||||
tabBarIcon: ({ color, size }) => <Home size={size} color={color} />,
|
||||
}}
|
||||
/>
|
||||
<Tabs.Screen
|
||||
name="config"
|
||||
options={{
|
||||
title: "settings",
|
||||
tabBarIcon: ({ color, size }) => (
|
||||
<Settings size={size} color={color} />
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<Tabs.Screen
|
||||
name="logs"
|
||||
options={{
|
||||
title: "Logs",
|
||||
href:
|
||||
parseInt(serverPort || "0", 10) >= 50000 ? null : "/(tabs)/logs",
|
||||
}}
|
||||
/>
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Stack } from "expo-router";
|
||||
import { StatusBar } from "expo-status-bar";
|
||||
import "../../global.css";
|
||||
import { PortalHost } from "@rn-primitives/portal";
|
||||
|
||||
export default function RootLayout() {
|
||||
return (
|
||||
@@ -9,6 +11,7 @@ export default function RootLayout() {
|
||||
<Stack.Screen name="index" />
|
||||
{/* <Stack.Screen name="(tabs)" /> */}
|
||||
</Stack>
|
||||
<PortalHost />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,17 +42,17 @@ export default function Index() {
|
||||
);
|
||||
await devDelay(1500);
|
||||
//router.replace("/scanner");
|
||||
setReady(true)
|
||||
setReady(true);
|
||||
return;
|
||||
}
|
||||
|
||||
setMessage(<Text>Checking for updates</Text>)
|
||||
await devDelay(1500)
|
||||
setMessage(<Text>Checking for updates</Text>);
|
||||
await devDelay(1500);
|
||||
// TODO if theres an update go to update screen message :D
|
||||
setMessage(<Text>Opening LST scan app</Text>);
|
||||
await devDelay(3250);
|
||||
//router.replace("/scanner");
|
||||
setReady(true)
|
||||
setReady(true);
|
||||
} catch (error) {
|
||||
console.log("Startup error", error);
|
||||
setMessage(<Text>Something went wrong during startup.</Text>);
|
||||
@@ -62,9 +62,9 @@ export default function Index() {
|
||||
startup();
|
||||
}, [hasHydrated, hasValidSetup, serverPort, router]);
|
||||
|
||||
if (ready) {
|
||||
return <Redirect href="/(tabs)/scanner" />;
|
||||
}
|
||||
if (ready) {
|
||||
return <Redirect href="/(tabs)/scanner" />;
|
||||
}
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
|
||||
@@ -1,31 +1,121 @@
|
||||
import React from 'react'
|
||||
import { View, Text } from 'react-native'
|
||||
import { ScannerTestScreen } from './ScannExample'
|
||||
import { useAppStore } from '../hooks/useAppStore';
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { useAppStore } from "../hooks/useAppStore";
|
||||
import { sendTcpMessage } from "../lib/tcpScan";
|
||||
import { type ZebraScanResult, zebraScanner } from "../lib/ZebraScanner";
|
||||
import { ScannedLabelBox } from "./ScannedLabels";
|
||||
|
||||
const STX = "\x02";
|
||||
const ETX = "\x03";
|
||||
|
||||
export default function ProdScanner() {
|
||||
const scannerIdFromStore = useAppStore((s) => s.scannerId);
|
||||
return (
|
||||
<View>
|
||||
<View style={{ alignItems: "center", margin: 10 }}>
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>SScanner ID: {scannerIdFromStore}</Text>
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
marginTop: 50,
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Text>Relocate</Text>
|
||||
<Text>0 / 4</Text>
|
||||
</View>
|
||||
|
||||
{/* <View>
|
||||
<Text>List of recent scanned pallets TBA</Text>
|
||||
</View> */}
|
||||
<ScannerTestScreen />
|
||||
</View>
|
||||
|
||||
|
||||
)
|
||||
const [lastScan, setLastScan] = useState<any>(null);
|
||||
const [tagScans, setTagScans] = useState<any>([]);
|
||||
const scannerIdFromStore = useAppStore((s) => s.scannerId);
|
||||
const serverIp = useAppStore((s) => s.serverIp);
|
||||
const serverPort = useAppStore((s) => s.serverPort);
|
||||
|
||||
const handleScan = useCallback(
|
||||
async (scan: ZebraScanResult) => {
|
||||
const scanned = scan.data;
|
||||
|
||||
let commandToSend = `${STX}${scannerIdFromStore}@${scanned}${ETX}`;
|
||||
|
||||
// if we are sscc we need to scan like this .... <STX>98@]C100090087710038712256<ETX>
|
||||
if (scan.data.startsWith("000")) {
|
||||
commandToSend = `${STX}${scannerIdFromStore}@]C1${scanned}${ETX}`;
|
||||
setTagScans((prev: any) => [
|
||||
parseInt(scanned.slice(10, -1) || "000", 10).toString(),
|
||||
...prev,
|
||||
]);
|
||||
}
|
||||
|
||||
// if we change commands we want to zero out the last scanned labels
|
||||
if (/^[a-zA-Z]/.test(scan.data)) {
|
||||
setTagScans([]);
|
||||
}
|
||||
|
||||
const something = await sendTcpMessage(
|
||||
commandToSend,
|
||||
serverIp,
|
||||
parseInt(serverPort || "0", 10),
|
||||
);
|
||||
// Later this is where your TCP send goes.
|
||||
// const response = await sendTcpMessage(tcpMessage);
|
||||
setLastScan(something.data[0]);
|
||||
//console.log("TCP response:", something);
|
||||
},
|
||||
[scannerIdFromStore, serverIp, serverPort],
|
||||
);
|
||||
|
||||
console.log(lastScan);
|
||||
|
||||
useEffect(() => {
|
||||
zebraScanner.ensureProfile();
|
||||
zebraScanner.startListening();
|
||||
|
||||
const sub = zebraScanner.addScanListener((scan) => {
|
||||
//console.log("SCAN:", scan);
|
||||
handleScan(scan);
|
||||
});
|
||||
|
||||
return () => {
|
||||
sub.remove();
|
||||
zebraScanner.stopListening();
|
||||
};
|
||||
}, [handleScan]);
|
||||
return (
|
||||
<View>
|
||||
<View>
|
||||
<View style={{ alignItems: "center", margin: 10 }}>
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>
|
||||
Scanner ID: {parseInt(scannerIdFromStore || "0", 10)}
|
||||
</Text>
|
||||
</View>
|
||||
{!lastScan ? (
|
||||
<View
|
||||
style={{
|
||||
marginTop: 10,
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Text className="text-xl font-bold">Waiting on scan....</Text>
|
||||
</View>
|
||||
) : (
|
||||
<View
|
||||
style={{
|
||||
marginTop: 10,
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>
|
||||
{lastScan?.action}
|
||||
</Text>
|
||||
|
||||
{lastScan?.type === "error" ? (
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>
|
||||
{lastScan?.message}
|
||||
</Text>
|
||||
) : (
|
||||
<View
|
||||
style={{
|
||||
marginTop: 15,
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>
|
||||
{lastScan?.prompt}
|
||||
</Text>
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>
|
||||
{lastScan?.message}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<ScannedLabelBox labels={tagScans} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button, Text, View } from "react-native";
|
||||
import { sendTcpMessage } from "../lib/tcpScan";
|
||||
import { type ZebraScanResult, zebraScanner } from "../lib/ZebraScanner";
|
||||
|
||||
const STX = "\x02";
|
||||
@@ -13,20 +14,19 @@ export function ScannerTestScreen() {
|
||||
|
||||
const scanned = scan.data;
|
||||
|
||||
// Hard-coded command example:
|
||||
// <stx>98@{scanned}<etx>
|
||||
const tcpMessage = `${STX}98@${scanned}${ETX}`;
|
||||
let commandToSend = `${STX}98@${scanned}${ETX}`;
|
||||
|
||||
console.log("TCP message to send:", tcpMessage);
|
||||
console.log("TCP message visible:", `<stx>98@${scanned}<etx>`);
|
||||
// if we are sscc we need to scan like this .... <STX>98@]C100090087710038712256<ETX>
|
||||
if (scan.data.startsWith("000")) {
|
||||
commandToSend = `${STX}98@]C1${scanned}${ETX}`;
|
||||
}
|
||||
|
||||
const something = await sendTcpMessage(commandToSend, "10.44.0.26", 50001);
|
||||
// Later this is where your TCP send goes.
|
||||
// const response = await sendTcpMessage(tcpMessage);
|
||||
|
||||
const fakeResponse = `Would send TCP: <stx>98@${scanned}<etx>`;
|
||||
|
||||
console.log("TCP response:", fakeResponse);
|
||||
setLastResponse(fakeResponse);
|
||||
console.log("TCP response:", something);
|
||||
setLastResponse(JSON.stringify(something));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
50
lstMobile/src/components/ScannedLabels.tsx
Normal file
50
lstMobile/src/components/ScannedLabels.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { ScrollView, Text, View } from "react-native";
|
||||
|
||||
type ScannedLabel = {
|
||||
id: string;
|
||||
barcode: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
type ScannedLabelBoxProps = {
|
||||
labels: ScannedLabel[];
|
||||
};
|
||||
|
||||
export function ScannedLabelBox({ labels }: ScannedLabelBoxProps) {
|
||||
return (
|
||||
<View style={{ flex: 1, marginTop: 30 }}>
|
||||
<Text style={{ fontSize: 18, fontWeight: "700", marginBottom: 8 }}>
|
||||
Current scanned labels
|
||||
</Text>
|
||||
|
||||
<ScrollView
|
||||
style={{
|
||||
flex: 1,
|
||||
borderWidth: 1,
|
||||
borderColor: "#ccc",
|
||||
borderRadius: 8,
|
||||
padding: 2,
|
||||
margin: 2,
|
||||
}}
|
||||
contentContainerStyle={{ gap: 2 }}
|
||||
>
|
||||
{labels.length === 0 ? (
|
||||
<Text style={{ color: "#777" }}>No labels scanned yet</Text>
|
||||
) : (
|
||||
labels.map((label) => (
|
||||
<View
|
||||
key={`${label}`}
|
||||
style={{
|
||||
padding: 2,
|
||||
borderRadius: 8,
|
||||
backgroundColor: "#f2f2f2",
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 18, fontWeight: "700" }}>{label}</Text>
|
||||
</View>
|
||||
))
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
52
lstMobile/src/components/ui/card.tsx
Normal file
52
lstMobile/src/components/ui/card.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Text, TextClassContext } from '@/components/ui/text';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { View } from 'react-native';
|
||||
|
||||
function Card({ className, ...props }: React.ComponentProps<typeof View>) {
|
||||
return (
|
||||
<TextClassContext.Provider value="text-card-foreground">
|
||||
<View
|
||||
className={cn(
|
||||
'bg-card border-border flex flex-col gap-6 rounded-xl border py-6 shadow-sm shadow-black/5',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</TextClassContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
function CardHeader({ className, ...props }: React.ComponentProps<typeof View>) {
|
||||
return <View className={cn('flex flex-col gap-1.5 px-6', className)} {...props} />;
|
||||
}
|
||||
|
||||
function CardTitle({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Text>) {
|
||||
return (
|
||||
<Text
|
||||
role="heading"
|
||||
aria-level={3}
|
||||
className={cn('font-semibold leading-none', className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function CardDescription({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Text>) {
|
||||
return <Text className={cn('text-muted-foreground text-sm', className)} {...props} />;
|
||||
}
|
||||
|
||||
function CardContent({ className, ...props }: React.ComponentProps<typeof View>) {
|
||||
return <View className={cn('px-6', className)} {...props} />;
|
||||
}
|
||||
|
||||
function CardFooter({ className, ...props }: React.ComponentProps<typeof View>) {
|
||||
return <View className={cn('flex flex-row items-center px-6', className)} {...props} />;
|
||||
}
|
||||
|
||||
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
||||
88
lstMobile/src/components/ui/text.tsx
Normal file
88
lstMobile/src/components/ui/text.tsx
Normal file
@@ -0,0 +1,88 @@
|
||||
import { cn } from '@/lib/utils';
|
||||
import * as Slot from '@rn-primitives/slot';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import * as React from 'react';
|
||||
import { Platform, Text as RNText, type Role } from 'react-native';
|
||||
|
||||
const textVariants = cva(
|
||||
cn(
|
||||
'text-foreground text-base',
|
||||
Platform.select({
|
||||
web: 'select-text',
|
||||
})
|
||||
),
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: '',
|
||||
h1: cn(
|
||||
'text-center text-4xl font-extrabold tracking-tight',
|
||||
Platform.select({ web: 'scroll-m-20 text-balance' })
|
||||
),
|
||||
h2: cn(
|
||||
'border-border border-b pb-2 text-3xl font-semibold tracking-tight',
|
||||
Platform.select({ web: 'scroll-m-20 first:mt-0' })
|
||||
),
|
||||
h3: cn('text-2xl font-semibold tracking-tight', Platform.select({ web: 'scroll-m-20' })),
|
||||
h4: cn('text-xl font-semibold tracking-tight', Platform.select({ web: 'scroll-m-20' })),
|
||||
p: 'mt-3 leading-7 sm:mt-6',
|
||||
blockquote: 'mt-4 border-l-2 pl-3 italic sm:mt-6 sm:pl-6',
|
||||
code: cn(
|
||||
'bg-muted relative rounded px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold'
|
||||
),
|
||||
lead: 'text-muted-foreground text-xl',
|
||||
large: 'text-lg font-semibold',
|
||||
small: 'text-sm font-medium leading-none',
|
||||
muted: 'text-muted-foreground text-sm',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
type TextVariantProps = VariantProps<typeof textVariants>;
|
||||
|
||||
type TextVariant = NonNullable<TextVariantProps['variant']>;
|
||||
|
||||
const ROLE: Partial<Record<TextVariant, Role>> = {
|
||||
h1: 'heading',
|
||||
h2: 'heading',
|
||||
h3: 'heading',
|
||||
h4: 'heading',
|
||||
blockquote: Platform.select({ web: 'blockquote' as Role }),
|
||||
code: Platform.select({ web: 'code' as Role }),
|
||||
};
|
||||
|
||||
const ARIA_LEVEL: Partial<Record<TextVariant, string>> = {
|
||||
h1: '1',
|
||||
h2: '2',
|
||||
h3: '3',
|
||||
h4: '4',
|
||||
};
|
||||
|
||||
const TextClassContext = React.createContext<string | undefined>(undefined);
|
||||
|
||||
function Text({
|
||||
className,
|
||||
asChild = false,
|
||||
variant = 'default',
|
||||
...props
|
||||
}: React.ComponentProps<typeof RNText> &
|
||||
TextVariantProps & {
|
||||
asChild?: boolean;
|
||||
}) {
|
||||
const textClass = React.useContext(TextClassContext);
|
||||
const Component = asChild ? Slot.Text : RNText;
|
||||
return (
|
||||
<Component
|
||||
className={cn(textVariants({ variant }), textClass, className)}
|
||||
role={variant ? ROLE[variant] : undefined}
|
||||
aria-level={variant ? ARIA_LEVEL[variant] : undefined}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { Text, TextClassContext };
|
||||
@@ -1,7 +1,7 @@
|
||||
import TcpSocket from "react-native-tcp-socket";
|
||||
|
||||
const STX = "\x02";
|
||||
const ETX = "\x03";
|
||||
// const STX = "\x02";
|
||||
// const ETX = "\x03";
|
||||
|
||||
type TcpResponse = {
|
||||
success: boolean;
|
||||
@@ -9,26 +9,154 @@ type TcpResponse = {
|
||||
data: string[];
|
||||
};
|
||||
|
||||
function parseErpResponse(buffer: Buffer) {
|
||||
const text = buffer
|
||||
.toString("utf8")
|
||||
.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|#[0-9A-Za-z])/g, "")
|
||||
.replace(/\x02/g, "")
|
||||
.replace(/\x03/g, "")
|
||||
.trim();
|
||||
|
||||
const noHeader = text.replace(/^\d+@/, "");
|
||||
console.log(text);
|
||||
if (!noHeader.includes("Scan:")) {
|
||||
return {
|
||||
raw: text,
|
||||
type: "error",
|
||||
message: noHeader.trim(),
|
||||
lines: [noHeader.trim()],
|
||||
};
|
||||
}
|
||||
|
||||
const [actionPart, scanPart = ""] = noHeader.split("Scan:");
|
||||
const action = actionPart.trim();
|
||||
const scanClean = scanPart.trim();
|
||||
|
||||
const successMatch = scanClean.match(/^(.*?)\s+V$/);
|
||||
|
||||
if (successMatch) {
|
||||
const prompt = successMatch[1].trim();
|
||||
|
||||
return {
|
||||
raw: text,
|
||||
type: "success",
|
||||
action,
|
||||
prompt,
|
||||
status: "V",
|
||||
lines: [action, prompt, "V"],
|
||||
};
|
||||
}
|
||||
|
||||
// // Handles: "Production lotInvalid barcode"
|
||||
// const knownErrors = [
|
||||
// "Invalid barcode",
|
||||
// "Invalid machine",
|
||||
// "Not on stock",
|
||||
// "Article tolerance for consolidation not satisfied",
|
||||
// ].sort((a, b) => b.length - a.length);
|
||||
|
||||
// const foundError = knownErrors.find((err) => scanClean.includes(err));
|
||||
|
||||
// if (foundError) {
|
||||
// const prompt = scanClean.replace(foundError, "").trim();
|
||||
|
||||
// return {
|
||||
// raw: text,
|
||||
// type: "error",
|
||||
// action,
|
||||
// prompt,
|
||||
// message: foundError,
|
||||
// lines: [action, prompt, foundError].filter(Boolean),
|
||||
// };
|
||||
// }
|
||||
|
||||
// return {
|
||||
// raw: text,
|
||||
// type: "pending",
|
||||
// action,
|
||||
// prompt: scanClean,
|
||||
// lines: [action, scanClean].filter(Boolean),
|
||||
// };
|
||||
|
||||
const unitMatch = scanClean.match(/^(Unit\s+\d+\/\d+)(.*)$/);
|
||||
|
||||
if (unitMatch) {
|
||||
const prompt = unitMatch[1].trim(); // "Unit 1/4"
|
||||
const remainder = unitMatch[2].trim(); // everything after
|
||||
|
||||
// SUCCESS
|
||||
if (remainder === "V") {
|
||||
return {
|
||||
raw: text,
|
||||
type: "success",
|
||||
action,
|
||||
prompt,
|
||||
status: "V",
|
||||
lines: [action, prompt, "V"],
|
||||
};
|
||||
}
|
||||
|
||||
// Known ERP errors
|
||||
const knownErrors = [
|
||||
"Invalid barcode",
|
||||
"Invalid machine",
|
||||
"Not on stock",
|
||||
"Article tolerance for consolidation not satisfied",
|
||||
];
|
||||
|
||||
const foundError = knownErrors.find((err) =>
|
||||
remainder.toLowerCase().includes(err.toLowerCase()),
|
||||
);
|
||||
|
||||
if (foundError) {
|
||||
return {
|
||||
raw: text,
|
||||
type: "error",
|
||||
action,
|
||||
prompt,
|
||||
message: foundError,
|
||||
lines: [action, prompt, foundError],
|
||||
};
|
||||
}
|
||||
|
||||
if (remainder) {
|
||||
return {
|
||||
raw: text,
|
||||
type: "prompt",
|
||||
action,
|
||||
prompt,
|
||||
message: remainder,
|
||||
lines: [action, prompt, remainder],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
raw: text,
|
||||
type: "pending",
|
||||
action,
|
||||
prompt,
|
||||
lines: [action, prompt],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a Zebra-style TCP message:
|
||||
* <STX>98@{scanned}<ETX>
|
||||
*/
|
||||
export async function sendTcpMessage(
|
||||
scanned: string,
|
||||
command: string,
|
||||
host: string,
|
||||
port: number,
|
||||
timeoutMs = 5000,
|
||||
): Promise<TcpResponse> {
|
||||
return new Promise((resolve) => {
|
||||
const responses: string[] = [];
|
||||
const responses: any = [];
|
||||
|
||||
const client = TcpSocket.createConnection({ host, port }, () => {
|
||||
const payload = `${STX}98@${scanned}${ETX}`;
|
||||
console.log("Sending TCP (visible):", `${command}`);
|
||||
|
||||
console.log("Sending TCP (raw):", payload);
|
||||
console.log("Sending TCP (visible):", `<stx>98@${scanned}<etx>`);
|
||||
|
||||
client.write(payload);
|
||||
client.write(command);
|
||||
});
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
@@ -42,10 +170,17 @@ export async function sendTcpMessage(
|
||||
}, timeoutMs);
|
||||
|
||||
client.on("data", (data) => {
|
||||
const text = data.toString();
|
||||
console.log("TCP received:", text);
|
||||
//const text = data.toString();
|
||||
//console.log("TCP received:", text);
|
||||
const parsed = parseErpResponse(data);
|
||||
|
||||
responses.push(text);
|
||||
responses.push(parsed);
|
||||
clearTimeout(timeout);
|
||||
resolve({
|
||||
success: true,
|
||||
message: "TCP Response",
|
||||
data: responses,
|
||||
});
|
||||
});
|
||||
|
||||
client.on("error", (err) => {
|
||||
|
||||
81
lstMobile/src/lib/theme.ts
Normal file
81
lstMobile/src/lib/theme.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { DarkTheme, DefaultTheme, type Theme } from "@react-navigation/native";
|
||||
|
||||
export const THEME = {
|
||||
light: {
|
||||
background: "hsl(0 0% 100%)",
|
||||
foreground: "hsl(0 0% 3.9%)",
|
||||
card: "hsl(0 0% 100%)",
|
||||
cardForeground: "hsl(0 0% 3.9%)",
|
||||
popover: "hsl(0 0% 100%)",
|
||||
popoverForeground: "hsl(0 0% 3.9%)",
|
||||
primary: "hsl(0 0% 9%)",
|
||||
primaryForeground: "hsl(0 0% 98%)",
|
||||
secondary: "hsl(0 0% 96.1%)",
|
||||
secondaryForeground: "hsl(0 0% 9%)",
|
||||
muted: "hsl(0 0% 96.1%)",
|
||||
mutedForeground: "hsl(0 0% 45.1%)",
|
||||
accent: "hsl(0 0% 96.1%)",
|
||||
accentForeground: "hsl(0 0% 9%)",
|
||||
destructive: "hsl(0 84.2% 60.2%)",
|
||||
border: "hsl(0 0% 89.8%)",
|
||||
input: "hsl(0 0% 89.8%)",
|
||||
ring: "hsl(0 0% 63%)",
|
||||
radius: "0.625rem",
|
||||
chart1: "hsl(12 76% 61%)",
|
||||
chart2: "hsl(173 58% 39%)",
|
||||
chart3: "hsl(197 37% 24%)",
|
||||
chart4: "hsl(43 74% 66%)",
|
||||
chart5: "hsl(27 87% 67%)",
|
||||
},
|
||||
dark: {
|
||||
background: "hsl(0 0% 3.9%)",
|
||||
foreground: "hsl(0 0% 98%)",
|
||||
card: "hsl(0 0% 3.9%)",
|
||||
cardForeground: "hsl(0 0% 98%)",
|
||||
popover: "hsl(0 0% 3.9%)",
|
||||
popoverForeground: "hsl(0 0% 98%)",
|
||||
primary: "hsl(0 0% 98%)",
|
||||
primaryForeground: "hsl(0 0% 9%)",
|
||||
secondary: "hsl(0 0% 14.9%)",
|
||||
secondaryForeground: "hsl(0 0% 98%)",
|
||||
muted: "hsl(0 0% 14.9%)",
|
||||
mutedForeground: "hsl(0 0% 63.9%)",
|
||||
accent: "hsl(0 0% 14.9%)",
|
||||
accentForeground: "hsl(0 0% 98%)",
|
||||
destructive: "hsl(0 70.9% 59.4%)",
|
||||
border: "hsl(0 0% 14.9%)",
|
||||
input: "hsl(0 0% 14.9%)",
|
||||
ring: "hsl(300 0% 45%)",
|
||||
radius: "0.625rem",
|
||||
chart1: "hsl(220 70% 50%)",
|
||||
chart2: "hsl(160 60% 45%)",
|
||||
chart3: "hsl(30 80% 55%)",
|
||||
chart4: "hsl(280 65% 60%)",
|
||||
chart5: "hsl(340 75% 55%)",
|
||||
},
|
||||
};
|
||||
|
||||
export const NAV_THEME: Record<"light" | "dark", Theme> = {
|
||||
light: {
|
||||
...DefaultTheme,
|
||||
colors: {
|
||||
background: THEME.light.background,
|
||||
border: THEME.light.border,
|
||||
card: THEME.light.card,
|
||||
notification: THEME.light.destructive,
|
||||
primary: THEME.light.primary,
|
||||
text: THEME.light.foreground,
|
||||
},
|
||||
},
|
||||
dark: {
|
||||
...DarkTheme,
|
||||
colors: {
|
||||
background: THEME.dark.background,
|
||||
border: THEME.dark.border,
|
||||
card: THEME.dark.card,
|
||||
notification: THEME.dark.destructive,
|
||||
primary: THEME.dark.primary,
|
||||
text: THEME.dark.foreground,
|
||||
},
|
||||
},
|
||||
};
|
||||
6
lstMobile/src/lib/utils.ts
Normal file
6
lstMobile/src/lib/utils.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
Reference in New Issue
Block a user