优化项目结构

This commit is contained in:
李宇奇 2025-07-09 14:47:04 +08:00
parent 1705ace101
commit e937988771
16 changed files with 37 additions and 150 deletions

30
App.tsx
View File

@ -1,25 +1,3 @@
// /**
// * Sample React Native App
// * https://github.com/facebook/react-native
// *
// * @format
// */
//
// import React from 'react';
// import Navigation from './src/navigation';
// import {ThemeProvider} from './src/contexts/ThemeContext';
//
// function App(): JSX.Element {
// return (
// <ThemeProvider>
// <Navigation />
// </ThemeProvider>
// );
// }
//
// export default App;
/** /**
* Sample React Native App * Sample React Native App
* https://github.com/facebook/react-native * https://github.com/facebook/react-native
@ -27,11 +5,11 @@
* @format * @format
*/ */
import React, { useState, useEffect } from 'react'; import React, {useState, useEffect} from 'react';
import Navigation from './src/navigation'; import Navigation from './src/navigation';
import {ThemeProvider} from './src/contexts/ThemeContext'; import {ThemeProvider} from './src/contexts/ThemeContext';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import { View, Text, ActivityIndicator, StyleSheet } from 'react-native'; import {View, Text, ActivityIndicator, StyleSheet} from 'react-native';
function App(): JSX.Element { function App(): JSX.Element {
const [fontLoaded, setFontLoaded] = useState(false); const [fontLoaded, setFontLoaded] = useState(false);
@ -71,9 +49,7 @@ function App(): JSX.Element {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ActivityIndicator size="large" /> <ActivityIndicator size="large" />
<Text style={styles.statusText}> <Text style={styles.statusText}>{fontError || 'Loading icons...'}</Text>
{fontError || 'Loading icons...'}
</Text>
<Text style={styles.debugText}> <Text style={styles.debugText}>
Using MaterialIcons font family: {MaterialIcons.getFontFamily()} Using MaterialIcons font family: {MaterialIcons.getFontFamily()}
</Text> </Text>

View File

@ -1,6 +1,6 @@
{ {
"name": "pda_react_native_template", "name": "pda_react_native_template",
"version": "0.0.1", "version": "1.0.0",
"private": true, "private": true,
"scripts": { "scripts": {
"android": "react-native run-android", "android": "react-native run-android",

View File

@ -1,26 +0,0 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React from 'react';
import {StatusBar} from 'react-native';
import Navigation from './navigation';
import {ThemeProvider} from './contexts/ThemeContext';
import {theme} from './constants/theme';
const App = () => {
return (
<ThemeProvider theme={theme}>
<StatusBar
backgroundColor={theme.colors.primary}
barStyle="light-content"
/>
<Navigation />
</ThemeProvider>
);
};
export default App;

View File

@ -73,7 +73,7 @@ export const theme = {
width: 0, width: 0,
height: 4, height: 4,
}, },
shadowOpacity: 0.30, shadowOpacity: 0.3,
shadowRadius: 4.65, shadowRadius: 4.65,
elevation: 4, elevation: 4,
}, },
@ -88,8 +88,6 @@ export const theme = {
elevation: 6, elevation: 6,
}, },
}, },
}; };
// 类型定义 // 类型定义

View File

@ -1,23 +0,0 @@
class ScannerService {
async init(): Promise<void> {
// 初始化扫描器
console.log('Scanner initialized');
}
async startScan(): Promise<string> {
// 开始扫描
return new Promise((resolve) => {
// 模拟扫描结果
setTimeout(() => {
resolve('Scanned barcode result');
}, 1000);
});
}
async stopScan(): Promise<void> {
// 停止扫描
console.log('Scanner stopped');
}
}
export const scannerService = new ScannerService();

View File

@ -1,38 +0,0 @@
import {useState, useCallback} from 'react';
import {scannerService} from '../device/scanner';
export const useScanner = () => {
const [isScanning, setIsScanning] = useState(false);
const [result, setResult] = useState<string | null>(null);
const [error, setError] = useState<Error | null>(null);
const startScan = useCallback(async () => {
try {
setIsScanning(true);
setError(null);
const scanResult = await scannerService.startScan();
setResult(scanResult);
} catch (err) {
setError(err as Error);
} finally {
setIsScanning(false);
}
}, []);
const stopScan = useCallback(async () => {
try {
await scannerService.stopScan();
setIsScanning(false);
} catch (err) {
setError(err as Error);
}
}, []);
return {
isScanning,
result,
error,
startScan,
stopScan,
};
};

View File

@ -4,7 +4,7 @@ import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {LoginScreen} from '../screens/auth/LoginScreen'; import {LoginScreen} from '../screens/auth/LoginScreen';
import {HomeScreen} from '../screens/home/HomeScreen'; import {HomeScreen} from '../screens/home/HomeScreen';
import {StockInEmpty} from '../screens/stockIn/StockInEmpty'; import {StockInEmpty} from '../screens/stockIn/StockInEmpty';
import StockInWheelManual from '../screens/stockIn/StockInWheelManual'; import {StockInManual} from '../screens/stockIn/StockInManual';
import {RootStackParamList} from './types'; import {RootStackParamList} from './types';
import {Platform} from 'react-native'; import {Platform} from 'react-native';
import {screensEnabled, enableScreens} from 'react-native-screens'; import {screensEnabled, enableScreens} from 'react-native-screens';
@ -50,8 +50,8 @@ const Navigation = () => {
}} }}
/> />
<Stack.Screen <Stack.Screen
name="StockInWheelManual" name="StockInManual"
component={StockInWheelManual} component={StockInManual}
options={{ options={{
animation: 'none', animation: 'none',
}} }}

View File

@ -4,8 +4,8 @@ export type RootStackParamList = {
Login: undefined; Login: undefined;
Home: undefined; Home: undefined;
StockInEmpty: undefined; StockInEmpty: undefined;
StockInWheelEBS: undefined; StockInEBS: undefined;
StockInWheelManual: undefined; StockInManual: undefined;
Pick: undefined; Pick: undefined;
StockCheck: undefined; StockCheck: undefined;
// 在这里添加其他页面的路由参数定义 // 在这里添加其他页面的路由参数定义

View File

@ -49,7 +49,7 @@ export const HomeScreen: React.FC = () => {
const menuItems: MenuItem[] = [ const menuItems: MenuItem[] = [
{ title: '空载具入库', icon: 'local-shipping', route: 'StockInEmpty' }, { title: '空载具入库', icon: 'local-shipping', route: 'StockInEmpty' },
{ title: '手动码盘入库', icon: 'inventory', route: 'StockInWheelManual' }, { title: '手动码盘入库', icon: 'inventory', route: 'StockInManual' },
]; ];
const stockData = [ const stockData = [

View File

@ -34,7 +34,7 @@ interface PackageDataItem {
lineLocationId: string; lineLocationId: string;
} }
const StockInWheelManual: React.FC = () => { export const StockInManual: React.FC = () => {
const theme = useTheme(); const theme = useTheme();
const navigation = useNavigation(); const navigation = useNavigation();
const [vehicleCode, setVehicleCode] = useState(''); const [vehicleCode, setVehicleCode] = useState('');
@ -656,4 +656,4 @@ const styles = StyleSheet.create({
}, },
}); });
export default StockInWheelManual; export default StockInManual;