refactor(scanner): more basic work to get the scanner just running
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 2m33s
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 2m33s
This commit is contained in:
33
lstMobile/temps/(tabs)/_layout.tsx
Normal file
33
lstMobile/temps/(tabs)/_layout.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Tabs } from "expo-router";
|
||||
import { Home, Settings } from "lucide-react-native";
|
||||
import { colors } from "../../stlyes/global";
|
||||
|
||||
export default function TabLayout() {
|
||||
return (
|
||||
<Tabs
|
||||
screenOptions={{
|
||||
headerShown: false,
|
||||
tabBarStyle: {},
|
||||
tabBarActiveTintColor: "black",
|
||||
tabBarInactiveTintColor: colors.textSecondary,
|
||||
}}
|
||||
>
|
||||
<Tabs.Screen
|
||||
name="home"
|
||||
options={{
|
||||
title: "Home",
|
||||
tabBarIcon: ({ color, size }) => <Home color={color} size={size} />,
|
||||
}}
|
||||
/>
|
||||
<Tabs.Screen
|
||||
name="config"
|
||||
options={{
|
||||
title: "Config",
|
||||
tabBarIcon: ({ color, size }) => (
|
||||
<Settings size={size} color={color} />
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
94
lstMobile/temps/(tabs)/config.tsx
Normal file
94
lstMobile/temps/(tabs)/config.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
// app/config.tsx
|
||||
|
||||
import Constants from "expo-constants";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, Button, Text, TextInput, View } from "react-native";
|
||||
|
||||
export default function Config() {
|
||||
const [serverUrl, setServerUrl] = useState("");
|
||||
const [scannerId, setScannerId] = useState("");
|
||||
const [config, setConfig] = useState<AppConfig | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const router = useRouter();
|
||||
|
||||
const version = Constants.expoConfig?.version;
|
||||
const build = Constants.expoConfig?.android?.versionCode ?? 1;
|
||||
|
||||
useEffect(() => {
|
||||
const loadConfig = async () => {
|
||||
const existing = await getConfig();
|
||||
|
||||
if (existing) {
|
||||
setServerUrl(existing.serverUrl);
|
||||
setScannerId(existing.scannerId);
|
||||
setConfig(existing);
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
loadConfig();
|
||||
}, []);
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!serverUrl.trim() || !scannerId.trim()) {
|
||||
Alert.alert("Missing info", "Please fill in both fields.");
|
||||
return;
|
||||
}
|
||||
|
||||
await saveConfig({
|
||||
serverUrl: serverUrl.trim(),
|
||||
scannerId: scannerId.trim(),
|
||||
});
|
||||
|
||||
Alert.alert("Saved", "Config saved to device.");
|
||||
//router.replace("/");
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <Text>Loading config...</Text>;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, padding: 16, gap: 12 }}>
|
||||
<View style={{ alignItems: "center", margin: 10 }}>
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>
|
||||
LST Scanner Config
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<Text>Server IP</Text>
|
||||
<TextInput
|
||||
value={serverUrl}
|
||||
onChangeText={setServerUrl}
|
||||
placeholder="192.168.1.1"
|
||||
autoCapitalize="none"
|
||||
keyboardType="numeric"
|
||||
style={{ borderWidth: 1, padding: 10, borderRadius: 8 }}
|
||||
/>
|
||||
|
||||
<Text>Server port</Text>
|
||||
<TextInput
|
||||
value={scannerId}
|
||||
onChangeText={setScannerId}
|
||||
placeholder="3000"
|
||||
autoCapitalize="characters"
|
||||
keyboardType="numeric"
|
||||
style={{ borderWidth: 1, padding: 10, borderRadius: 8 }}
|
||||
/>
|
||||
|
||||
<View
|
||||
style={{ flexDirection: "row", justifyContent: "center", padding: 3 }}
|
||||
>
|
||||
<Button title="Save Config" onPress={handleSave} />
|
||||
</View>
|
||||
|
||||
<View style={{ marginTop: "auto", alignItems: "center", padding: 10 }}>
|
||||
<Text style={{ fontSize: 12, color: "#666" }}>
|
||||
LST Scanner v{version}-{build}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
43
lstMobile/temps/(tabs)/home.tsx
Normal file
43
lstMobile/temps/(tabs)/home.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import axios from "axios";
|
||||
import * as Application from "expo-application";
|
||||
import * as Device from "expo-device";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, Platform, ScrollView, Text, View } from "react-native";
|
||||
import HomeHeader from "../../components/HomeHeader";
|
||||
import { hasValidSetup, type PersistedAppState } from "../../lib/storage";
|
||||
import {
|
||||
evaluateVersion,
|
||||
type ServerVersionInfo,
|
||||
type StartupStatus,
|
||||
} from "../../lib/versionValidation";
|
||||
import { globalStyles } from "../../stlyes/global";
|
||||
|
||||
export default function Index() {
|
||||
return (
|
||||
<ScrollView>
|
||||
<View style={globalStyles.container}>
|
||||
<HomeHeader />
|
||||
|
||||
<Text>Welcome. Blake</Text>
|
||||
<Text>Running on: {Platform.OS}</Text>
|
||||
<Text>Device model: {Device.modelName}</Text>
|
||||
<Text>Device Brand: {Device.brand}</Text>
|
||||
<Text> OS Version: {Device.osVersion}</Text>
|
||||
<View style={{ flex: 1, padding: 16, gap: 12 }}>
|
||||
<Text style={{ fontSize: 22, fontWeight: "600" }}>Welcome</Text>
|
||||
|
||||
{/* {config ? (
|
||||
<>
|
||||
<Text>Server: {config.serverUrl}</Text>
|
||||
<Text>Scanner: {config.scannerId}</Text>
|
||||
<Text>Server: v{serverInfo?.versionName}</Text>
|
||||
</>
|
||||
) : (
|
||||
<Text>No config found yet.</Text>
|
||||
)} */}
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user