优化项目结构
This commit is contained in:
parent
1705ace101
commit
e937988771
32
App.tsx
32
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
|
* 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>
|
||||||
|
|
@ -108,4 +84,4 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
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;
|
|
||||||
|
|
@ -2,4 +2,4 @@ export const ENV = {
|
||||||
API_URL: __DEV__ ? 'http://dev-api.example.com' : 'https://api.example.com',
|
API_URL: __DEV__ ? 'http://dev-api.example.com' : 'https://api.example.com',
|
||||||
APP_NAME: 'PdaRnTemplate',
|
APP_NAME: 'PdaRnTemplate',
|
||||||
VERSION: '1.0.0',
|
VERSION: '1.0.0',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,31 @@
|
||||||
export const theme = {
|
export const theme = {
|
||||||
colors: {
|
colors: {
|
||||||
// 基础颜色
|
// 基础颜色
|
||||||
aqua: '#05DCEF', // 青色主色调 (0xff05dcef)
|
aqua: '#05DCEF', // 青色主色调 (0xff05dcef)
|
||||||
background: '#ffffff', // 背景色
|
background: '#ffffff', // 背景色
|
||||||
backgroundGray: '#F5F5F5', // 灰色背景
|
backgroundGray: '#F5F5F5', // 灰色背景
|
||||||
text: '#333333', // 文本颜色
|
text: '#333333', // 文本颜色
|
||||||
textLight: '#666666', // 次要文本颜色
|
textLight: '#666666', // 次要文本颜色
|
||||||
border: '#dddddd', // 边框颜色
|
border: '#dddddd', // 边框颜色
|
||||||
error: '#ff3b30', // 错误颜色
|
error: '#ff3b30', // 错误颜色
|
||||||
cyan: '#00FFFF', // 青色背景
|
cyan: '#00FFFF', // 青色背景
|
||||||
lightGreen: '#7FFFAA', // 浅绿色
|
lightGreen: '#7FFFAA', // 浅绿色
|
||||||
|
|
||||||
// 渐变色配置
|
// 渐变色配置
|
||||||
gradients: {
|
gradients: {
|
||||||
primary: ['#05DCEF', '#7DE2F5', '#B8F2FF'], // 主要渐变(青蓝白,小清新)
|
primary: ['#05DCEF', '#7DE2F5', '#B8F2FF'], // 主要渐变(青蓝白,小清新)
|
||||||
contrast: ['#00F5A0', '#00D9F5'], // 对比渐变(绿青)
|
contrast: ['#00F5A0', '#00D9F5'], // 对比渐变(绿青)
|
||||||
header: ['#05DCEF', '#7DE2F5'], // 头部渐变
|
header: ['#05DCEF', '#7DE2F5'], // 头部渐变
|
||||||
button: ['#05DCEF', '#7DE2F5'], // 按钮渐变
|
button: ['#05DCEF', '#7DE2F5'], // 按钮渐变
|
||||||
},
|
},
|
||||||
|
|
||||||
// 图表颜色
|
// 图表颜色
|
||||||
chart: {
|
chart: {
|
||||||
cyan: '#00FFFF', // 青色
|
cyan: '#00FFFF', // 青色
|
||||||
lightGreen: '#7FFFAA', // 浅绿色
|
lightGreen: '#7FFFAA', // 浅绿色
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// 字体大小
|
// 字体大小
|
||||||
fontSize: {
|
fontSize: {
|
||||||
small: 12,
|
small: 12,
|
||||||
|
|
@ -36,7 +36,7 @@ export const theme = {
|
||||||
xxlarge: 24,
|
xxlarge: 24,
|
||||||
title: 32,
|
title: 32,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 间距
|
// 间距
|
||||||
spacing: {
|
spacing: {
|
||||||
xs: 4,
|
xs: 4,
|
||||||
|
|
@ -45,7 +45,7 @@ export const theme = {
|
||||||
large: 24,
|
large: 24,
|
||||||
xl: 32,
|
xl: 32,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 圆角
|
// 圆角
|
||||||
borderRadius: {
|
borderRadius: {
|
||||||
small: 4,
|
small: 4,
|
||||||
|
|
@ -54,7 +54,7 @@ export const theme = {
|
||||||
xl: 16,
|
xl: 16,
|
||||||
circle: 999,
|
circle: 999,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 阴影
|
// 阴影
|
||||||
shadow: {
|
shadow: {
|
||||||
small: {
|
small: {
|
||||||
|
|
@ -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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 类型定义
|
// 类型定义
|
||||||
|
|
@ -98,4 +96,4 @@ export type Theme = typeof theme;
|
||||||
// 导出类型
|
// 导出类型
|
||||||
declare module '@react-navigation/native' {
|
declare module '@react-navigation/native' {
|
||||||
export type ExtendedTheme = Theme;
|
export type ExtendedTheme = Theme;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,4 @@ export const useTheme = () => {
|
||||||
throw new Error('useTheme must be used within a ThemeProvider');
|
throw new Error('useTheme must be used within a ThemeProvider');
|
||||||
}
|
}
|
||||||
return theme;
|
return theme;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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 {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',
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
// 在这里添加其他页面的路由参数定义
|
// 在这里添加其他页面的路由参数定义
|
||||||
|
|
@ -18,4 +18,4 @@ declare global {
|
||||||
namespace ReactNavigation {
|
namespace ReactNavigation {
|
||||||
interface RootParamList extends RootStackParamList {}
|
interface RootParamList extends RootStackParamList {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 = [
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -18,4 +18,4 @@ export interface DeviceInfo {
|
||||||
model: string;
|
model: string;
|
||||||
osVersion: string;
|
osVersion: string;
|
||||||
serialNumber: string;
|
serialNumber: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,4 @@ export const storage = {
|
||||||
console.error('Error clearing data', error);
|
console.error('Error clearing data', error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user