Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React, { useState } from 'react';
import {
View,
TextInput,
Button,
StyleSheet,
Text,
TouchableOpacity,
Keyboard
} from 'react-native';
interface Manualtem {
onSubmit: (barcode: string) => void;
onCancel?: () => void;
visible?: boolean;
}
const ManualItemInput: React.FC<Manualtem> = ({ onSubmit, onCancel, visible = true }) => {
const [barcode, setBarcode] = useState('');
if (!visible) return null;
const handleSubmit = () => {
if (barcode.trim().length > 0) {
Keyboard.dismiss();
onSubmit(barcode.trim());
setBarcode('');
}
};
return (
<View style={styles.container}>
<Text style={styles.title}>Saisie manuelle</Text>
<Text style={styles.subtitle}>Entrez le code-barres de l'article (EAN)</Text>
<TextInput
style={styles.input}
value={barcode}
onChangeText={setBarcode}
placeholder="Ex: 3274080005003"
placeholderTextColor="#999"
keyboardType="numeric"
onSubmitEditing={handleSubmit}
returnKeyType="search"
/>
<View style={styles.buttonContainer}>
{onCancel && (
<View style={styles.buttonWrapper}>
<Button title="Annuler" onPress={onCancel} color="red" />
</View>
)}
<View style={styles.buttonWrapper}>
<Button
title="Rechercher"
onPress={handleSubmit}
disabled={barcode.trim().length === 0}
/>
</View>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
width: '90%',
backgroundColor: 'white',
padding: 20,
borderRadius: 15,
alignSelf: 'center',
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
marginTop: 20,
},
title: {
fontSize: 18,
fontWeight: 'bold',
marginBottom: 5,
textAlign: 'center',
color: '#333',
},
subtitle: {
fontSize: 14,
color: '#666',
marginBottom: 15,
textAlign: 'center',
},
input: {
height: 50,
borderColor: '#ccc',
borderWidth: 1,
borderRadius: 8,
paddingHorizontal: 15,
fontSize: 16,
backgroundColor: '#f9f9f9',
marginBottom: 20,
color: '#000',
},
buttonContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
},
buttonWrapper: {
flex: 1,
marginHorizontal: 5,
}
});
export default ManualItemInput;