优化项目结构
This commit is contained in:
parent
1705ace101
commit
e937988771
30
App.tsx
30
App.tsx
|
|
@ -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
|
||||
* https://github.com/facebook/react-native
|
||||
|
|
@ -27,11 +5,11 @@
|
|||
* @format
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, {useState, useEffect} from 'react';
|
||||
import Navigation from './src/navigation';
|
||||
import {ThemeProvider} from './src/contexts/ThemeContext';
|
||||
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 {
|
||||
const [fontLoaded, setFontLoaded] = useState(false);
|
||||
|
|
@ -71,9 +49,7 @@ function App(): JSX.Element {
|
|||
return (
|
||||
<View style={styles.container}>
|
||||
<ActivityIndicator size="large" />
|
||||
<Text style={styles.statusText}>
|
||||
{fontError || 'Loading icons...'}
|
||||
</Text>
|
||||
<Text style={styles.statusText}>{fontError || 'Loading icons...'}</Text>
|
||||
<Text style={styles.debugText}>
|
||||
Using MaterialIcons font family: {MaterialIcons.getFontFamily()}
|
||||
</Text>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "pda_react_native_template",
|
||||
"version": "0.0.1",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android": "react-native run-android",
|
||||
|
|
|
|||
26
src/App.tsx
26
src/App.tsx
|
|
@ -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;
|
||||
|
|
@ -73,7 +73,7 @@ export const theme = {
|
|||
width: 0,
|
||||
height: 4,
|
||||
},
|
||||
shadowOpacity: 0.30,
|
||||
shadowOpacity: 0.3,
|
||||
shadowRadius: 4.65,
|
||||
elevation: 4,
|
||||
},
|
||||
|
|
@ -88,8 +88,6 @@ export const theme = {
|
|||
elevation: 6,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
// 类型定义
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -4,7 +4,7 @@ import {createNativeStackNavigator} from '@react-navigation/native-stack';
|
|||
import {LoginScreen} from '../screens/auth/LoginScreen';
|
||||
import {HomeScreen} from '../screens/home/HomeScreen';
|
||||
import {StockInEmpty} from '../screens/stockIn/StockInEmpty';
|
||||
import StockInWheelManual from '../screens/stockIn/StockInWheelManual';
|
||||
import {StockInManual} from '../screens/stockIn/StockInManual';
|
||||
import {RootStackParamList} from './types';
|
||||
import {Platform} from 'react-native';
|
||||
import {screensEnabled, enableScreens} from 'react-native-screens';
|
||||
|
|
@ -50,8 +50,8 @@ const Navigation = () => {
|
|||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="StockInWheelManual"
|
||||
component={StockInWheelManual}
|
||||
name="StockInManual"
|
||||
component={StockInManual}
|
||||
options={{
|
||||
animation: 'none',
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ export type RootStackParamList = {
|
|||
Login: undefined;
|
||||
Home: undefined;
|
||||
StockInEmpty: undefined;
|
||||
StockInWheelEBS: undefined;
|
||||
StockInWheelManual: undefined;
|
||||
StockInEBS: undefined;
|
||||
StockInManual: undefined;
|
||||
Pick: undefined;
|
||||
StockCheck: undefined;
|
||||
// 在这里添加其他页面的路由参数定义
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export const HomeScreen: React.FC = () => {
|
|||
|
||||
const menuItems: MenuItem[] = [
|
||||
{ title: '空载具入库', icon: 'local-shipping', route: 'StockInEmpty' },
|
||||
{ title: '手动码盘入库', icon: 'inventory', route: 'StockInWheelManual' },
|
||||
{ title: '手动码盘入库', icon: 'inventory', route: 'StockInManual' },
|
||||
];
|
||||
|
||||
const stockData = [
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ interface PackageDataItem {
|
|||
lineLocationId: string;
|
||||
}
|
||||
|
||||
const StockInWheelManual: React.FC = () => {
|
||||
export const StockInManual: React.FC = () => {
|
||||
const theme = useTheme();
|
||||
const navigation = useNavigation();
|
||||
const [vehicleCode, setVehicleCode] = useState('');
|
||||
|
|
@ -656,4 +656,4 @@ const styles = StyleSheet.create({
|
|||
},
|
||||
});
|
||||
|
||||
export default StockInWheelManual;
|
||||
export default StockInManual;
|
||||
Loading…
Reference in New Issue
Block a user