@jescon-technologies/react-native-ui-kit 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +70 -0
- package/package.json +26 -3
- package/src/Alerts/AAlert.js +1 -1
- package/src/HOC/ConfirmOverlay.js +192 -0
- package/src/HOC/HAbsolute.js +56 -0
- package/src/HOC/HDiscontinue.js +105 -0
- package/src/HOC/HHeading.js +70 -0
- package/src/HOC/HMoreButton.js +88 -0
- package/src/HOC/HNatureHeading.js +402 -0
- package/src/HOC/HOCIcons.js +80 -0
- package/src/HOC/HOverlay.js +99 -0
- package/src/HOC/HOverlayCentered.js +140 -0
- package/src/HOC/HShadowButton.js +45 -0
- package/src/HOC/HShadowCountButton.js +82 -0
- package/src/HOC/OptionOverlay.js +48 -0
- package/src/Media/AudioScreen.js +347 -0
- package/src/Media/BarcodeScan.js +145 -0
- package/src/Media/CAudioPlay.js +228 -0
- package/src/Media/CCaptureImageWithoutEdit.js +330 -0
- package/src/Media/CImageGallery.js +289 -0
- package/src/Media/CImageZoom.js +82 -0
- package/src/Media/CSingleImage.js +391 -0
- package/src/Media/CSketchCanvas.js +76 -0
- package/src/Media/CVideoPlay.js +31 -0
- package/src/Media/DocumentScreen.js +367 -0
- package/src/Media/DrawingScreen.js +582 -0
- package/src/Media/ImageScreen.js +313 -0
- package/src/Media/RecordAudio.js +250 -0
- package/src/Media/RecordVideo.js +223 -0
- package/src/Media/VideoScreen.js +383 -0
- package/src/StaticComponents/SAlphabet.js +47 -0
- package/src/StaticComponents/SCheckBox.js +42 -0
- package/src/StaticComponents/SDatePicker.js +208 -0
- package/src/StaticComponents/SDatePickerLabel.js +253 -0
- package/src/StaticComponents/SDatePickerNew.js +258 -0
- package/src/StaticComponents/SDateTimePickerNew.js +381 -0
- package/src/StaticComponents/SDropDownGenerate.js +450 -0
- package/src/StaticComponents/SDropDownHoc.js +636 -0
- package/src/StaticComponents/SDropDownIcon.js +500 -0
- package/src/StaticComponents/SMenuBox.js +131 -0
- package/src/StaticComponents/SOverlay.js +177 -0
- package/src/StaticComponents/SOverlayTextInput.js +109 -0
- package/src/StaticComponents/SSearch.js +438 -0
- package/src/StaticComponents/SSearchBar.js +53 -0
- package/src/StaticComponents/SSpeedDial.js +303 -0
- package/src/StaticComponents/STextInput.js +289 -0
- package/src/StaticComponents/STextInputProps.js +36 -0
- package/src/StaticComponents/STimePicker.js +171 -0
- package/src/StaticComponents/STimingDropDownNew.js +1589 -0
- package/src/StaticComponents/STimingSwitch.js +34 -0
- package/src/layout/CContainerView.js +21 -0
- package/src/layout/CDetailView.js +81 -0
- package/src/layout/FooterBlock.js +0 -3
- package/src/layout/HeaderBlock.js +353 -0
- package/src/index.js +0 -15
- package/src/screens/ForgotPassword.js +0 -346
- package/src/screens/Login.js +0 -328
- package/src/screens/Splash.js +0 -788
- /package/src/{components → layout}/Loader.js +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
TouchableOpacity,
|
|
5
|
+
Text,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Animated,
|
|
8
|
+
Dimensions,
|
|
9
|
+
Modal,
|
|
10
|
+
FlatList,
|
|
11
|
+
TouchableWithoutFeedback,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
14
|
+
|
|
15
|
+
export default function SSpeedDial(props) {
|
|
16
|
+
const { buttons } = props;
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
19
|
+
const rotateAnim = useRef(new Animated.Value(0)).current;
|
|
20
|
+
const scaleAnim = useRef(new Animated.Value(0)).current;
|
|
21
|
+
const windowHeight = Dimensions.get('window').height;
|
|
22
|
+
|
|
23
|
+
const toggleMenu = () => {
|
|
24
|
+
if (open) {
|
|
25
|
+
// Close animation
|
|
26
|
+
Animated.parallel([
|
|
27
|
+
Animated.timing(rotateAnim, {
|
|
28
|
+
toValue: 0,
|
|
29
|
+
duration: 300,
|
|
30
|
+
useNativeDriver: true,
|
|
31
|
+
}),
|
|
32
|
+
Animated.timing(scaleAnim, {
|
|
33
|
+
toValue: 0,
|
|
34
|
+
duration: 200,
|
|
35
|
+
useNativeDriver: true,
|
|
36
|
+
}),
|
|
37
|
+
]).start(() => {
|
|
38
|
+
setOpen(false);
|
|
39
|
+
setModalVisible(false);
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
// Open animation
|
|
43
|
+
setOpen(true);
|
|
44
|
+
setModalVisible(true);
|
|
45
|
+
Animated.parallel([
|
|
46
|
+
Animated.timing(rotateAnim, {
|
|
47
|
+
toValue: 1,
|
|
48
|
+
duration: 300,
|
|
49
|
+
useNativeDriver: true,
|
|
50
|
+
}),
|
|
51
|
+
Animated.timing(scaleAnim, {
|
|
52
|
+
toValue: 1,
|
|
53
|
+
duration: 300,
|
|
54
|
+
useNativeDriver: true,
|
|
55
|
+
delay: 100,
|
|
56
|
+
}),
|
|
57
|
+
]).start();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleButtonPress = (functionid) => {
|
|
62
|
+
// Close menu first
|
|
63
|
+
Animated.parallel([
|
|
64
|
+
Animated.timing(rotateAnim, {
|
|
65
|
+
toValue: 0,
|
|
66
|
+
duration: 200,
|
|
67
|
+
useNativeDriver: true,
|
|
68
|
+
}),
|
|
69
|
+
Animated.timing(scaleAnim, {
|
|
70
|
+
toValue: 0,
|
|
71
|
+
duration: 150,
|
|
72
|
+
useNativeDriver: true,
|
|
73
|
+
}),
|
|
74
|
+
]).start(() => {
|
|
75
|
+
setOpen(false);
|
|
76
|
+
setModalVisible(false);
|
|
77
|
+
// Then call the callback
|
|
78
|
+
if (props.callBack) {
|
|
79
|
+
props.callBack(functionid);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const rotateInterpolate = rotateAnim.interpolate({
|
|
85
|
+
inputRange: [0, 1],
|
|
86
|
+
outputRange: ['0deg', '45deg'],
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const scaleInterpolate = scaleAnim.interpolate({
|
|
90
|
+
inputRange: [0, 1],
|
|
91
|
+
outputRange: [0, 1],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const renderActionButton = ({ item, index }) => {
|
|
95
|
+
const translateY = scaleAnim.interpolate({
|
|
96
|
+
inputRange: [0, 1],
|
|
97
|
+
outputRange: [0, -(index + 1) * 70], // Adjust spacing between buttons
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Animated.View
|
|
102
|
+
style={[
|
|
103
|
+
styles.actionButtonContainer,
|
|
104
|
+
{
|
|
105
|
+
transform: [
|
|
106
|
+
{ translateY },
|
|
107
|
+
{ scale: scaleInterpolate },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
]}
|
|
111
|
+
>
|
|
112
|
+
<TouchableOpacity
|
|
113
|
+
style={[
|
|
114
|
+
styles.actionButton,
|
|
115
|
+
{ backgroundColor: item.color || 'darkblue' },
|
|
116
|
+
]}
|
|
117
|
+
onPress={() => handleButtonPress(item.functionid)}
|
|
118
|
+
>
|
|
119
|
+
<MaterialIcons name={item.iconname} size={24} color="#fff" />
|
|
120
|
+
</TouchableOpacity>
|
|
121
|
+
{item.title && (
|
|
122
|
+
<View style={styles.titleContainer}>
|
|
123
|
+
<Text style={styles.titleText}>{item.title}</Text>
|
|
124
|
+
</View>
|
|
125
|
+
)}
|
|
126
|
+
</Animated.View>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<>
|
|
132
|
+
<Modal
|
|
133
|
+
transparent={true}
|
|
134
|
+
visible={modalVisible}
|
|
135
|
+
animationType="none"
|
|
136
|
+
onRequestClose={() => {
|
|
137
|
+
setModalVisible(false);
|
|
138
|
+
setOpen(false);
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<TouchableWithoutFeedback onPress={toggleMenu}>
|
|
142
|
+
<View style={styles.modalOverlay} />
|
|
143
|
+
</TouchableWithoutFeedback>
|
|
144
|
+
|
|
145
|
+
<View style={styles.modalContent}>
|
|
146
|
+
{buttons && buttons.map((item, index) => (
|
|
147
|
+
<View key={index} style={styles.actionRow}>
|
|
148
|
+
<View style={styles.titleLeftContainer}>
|
|
149
|
+
<Text style={styles.titleLeftText}>{item.title}</Text>
|
|
150
|
+
</View>
|
|
151
|
+
<TouchableOpacity
|
|
152
|
+
style={[
|
|
153
|
+
styles.modalActionButton,
|
|
154
|
+
{ backgroundColor: item.color || 'darkblue' },
|
|
155
|
+
]}
|
|
156
|
+
onPress={() => handleButtonPress(item.functionid)}
|
|
157
|
+
>
|
|
158
|
+
<MaterialIcons name={item.iconname} size={24} color="#fff" />
|
|
159
|
+
</TouchableOpacity>
|
|
160
|
+
</View>
|
|
161
|
+
))}
|
|
162
|
+
</View>
|
|
163
|
+
</Modal>
|
|
164
|
+
|
|
165
|
+
{/* Main Floating Button */}
|
|
166
|
+
<TouchableOpacity
|
|
167
|
+
style={styles.mainButton}
|
|
168
|
+
onPress={toggleMenu}
|
|
169
|
+
activeOpacity={0.8}
|
|
170
|
+
>
|
|
171
|
+
<Animated.View style={{ transform: [{ rotate: rotateInterpolate }] }}>
|
|
172
|
+
<MaterialIcons name={open ? 'close' : 'edit'} size={28} color="#fff" />
|
|
173
|
+
</Animated.View>
|
|
174
|
+
</TouchableOpacity>
|
|
175
|
+
</>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const styles = StyleSheet.create({
|
|
180
|
+
// Modal Styles
|
|
181
|
+
modalOverlay: {
|
|
182
|
+
flex: 1,
|
|
183
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
184
|
+
},
|
|
185
|
+
modalContent: {
|
|
186
|
+
position: 'absolute',
|
|
187
|
+
bottom: 80, // Position above the main button
|
|
188
|
+
right: 20,
|
|
189
|
+
backgroundColor: 'white',
|
|
190
|
+
borderRadius: 10,
|
|
191
|
+
padding: 10,
|
|
192
|
+
shadowColor: '#000',
|
|
193
|
+
shadowOffset: {
|
|
194
|
+
width: 0,
|
|
195
|
+
height: 2,
|
|
196
|
+
},
|
|
197
|
+
shadowOpacity: 0.25,
|
|
198
|
+
shadowRadius: 3.84,
|
|
199
|
+
elevation: 5,
|
|
200
|
+
minWidth: 200,
|
|
201
|
+
},
|
|
202
|
+
actionRow: {
|
|
203
|
+
flexDirection: 'row',
|
|
204
|
+
alignItems: 'center',
|
|
205
|
+
justifyContent: 'space-between',
|
|
206
|
+
marginVertical: 8,
|
|
207
|
+
paddingHorizontal: 10,
|
|
208
|
+
},
|
|
209
|
+
titleLeftContainer: {
|
|
210
|
+
flex: 1,
|
|
211
|
+
marginRight: 15,
|
|
212
|
+
},
|
|
213
|
+
titleLeftText: {
|
|
214
|
+
fontSize: 16,
|
|
215
|
+
color: '#333',
|
|
216
|
+
textAlign: 'right',
|
|
217
|
+
},
|
|
218
|
+
modalActionButton: {
|
|
219
|
+
width: 50,
|
|
220
|
+
height: 50,
|
|
221
|
+
borderRadius: 25,
|
|
222
|
+
justifyContent: 'center',
|
|
223
|
+
alignItems: 'center',
|
|
224
|
+
elevation: 3,
|
|
225
|
+
shadowColor: '#000',
|
|
226
|
+
shadowOffset: {
|
|
227
|
+
width: 0,
|
|
228
|
+
height: 1,
|
|
229
|
+
},
|
|
230
|
+
shadowOpacity: 0.2,
|
|
231
|
+
shadowRadius: 1.41,
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
// Main Button Styles
|
|
235
|
+
mainButton: {
|
|
236
|
+
position: 'absolute',
|
|
237
|
+
bottom: 20,
|
|
238
|
+
right: 20,
|
|
239
|
+
width: 60,
|
|
240
|
+
height: 60,
|
|
241
|
+
borderRadius: 30,
|
|
242
|
+
backgroundColor: 'darkblue',
|
|
243
|
+
justifyContent: 'center',
|
|
244
|
+
alignItems: 'center',
|
|
245
|
+
elevation: 5,
|
|
246
|
+
shadowColor: '#000',
|
|
247
|
+
shadowOffset: {
|
|
248
|
+
width: 0,
|
|
249
|
+
height: 2,
|
|
250
|
+
},
|
|
251
|
+
shadowOpacity: 0.25,
|
|
252
|
+
shadowRadius: 3.84,
|
|
253
|
+
zIndex: 1000,
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
// Alternative layout for action buttons (if you prefer vertical layout)
|
|
257
|
+
actionButtonContainer: {
|
|
258
|
+
position: 'absolute',
|
|
259
|
+
bottom: 80,
|
|
260
|
+
right: 20,
|
|
261
|
+
flexDirection: 'row',
|
|
262
|
+
alignItems: 'center',
|
|
263
|
+
},
|
|
264
|
+
actionButton: {
|
|
265
|
+
width: 50,
|
|
266
|
+
height: 50,
|
|
267
|
+
borderRadius: 25,
|
|
268
|
+
justifyContent: 'center',
|
|
269
|
+
alignItems: 'center',
|
|
270
|
+
elevation: 3,
|
|
271
|
+
},
|
|
272
|
+
titleContainer: {
|
|
273
|
+
position: 'absolute',
|
|
274
|
+
right: 60,
|
|
275
|
+
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
276
|
+
paddingHorizontal: 10,
|
|
277
|
+
paddingVertical: 5,
|
|
278
|
+
borderRadius: 5,
|
|
279
|
+
},
|
|
280
|
+
titleText: {
|
|
281
|
+
color: 'white',
|
|
282
|
+
fontSize: 14,
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// USAGE remains the same:
|
|
287
|
+
// <SSpeedDial
|
|
288
|
+
// buttons={[
|
|
289
|
+
// {
|
|
290
|
+
// "functionid": 1,
|
|
291
|
+
// "color": "darkblue",
|
|
292
|
+
// "iconname": "add",
|
|
293
|
+
// "title": "Browse",
|
|
294
|
+
// },
|
|
295
|
+
// {
|
|
296
|
+
// "functionid": 2,
|
|
297
|
+
// "color": "darkblue",
|
|
298
|
+
// "iconname": "audiotrack",
|
|
299
|
+
// "title": "Record Audio",
|
|
300
|
+
// }
|
|
301
|
+
// ]}
|
|
302
|
+
// callBack={val => val == undefined ? null : getFunctions(val)}
|
|
303
|
+
// />
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { View, TextInput, Dimensions, TouchableOpacity, Text } from 'react-native';
|
|
3
|
+
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
|
4
|
+
import { Global } from '../Common/Global';
|
|
5
|
+
import { normalize } from '../CommonStyle/componentStyle';
|
|
6
|
+
import CText from '../CustomComponents/CText';
|
|
7
|
+
|
|
8
|
+
const STextInput = (props) => {
|
|
9
|
+
const [text, setText] = useState('');
|
|
10
|
+
const [colorBg, setColorBg] = useState(false);
|
|
11
|
+
// const [data, setData] = useState(props.data != undefined ? props.data : {
|
|
12
|
+
// itemwidth: "92%",
|
|
13
|
+
// displaytext: "Name",
|
|
14
|
+
// iconname: 'home',
|
|
15
|
+
// value: 45,
|
|
16
|
+
// type: 'number-pad',
|
|
17
|
+
// editable: true,
|
|
18
|
+
// placeholder: "Name",
|
|
19
|
+
// decimal: 2
|
|
20
|
+
// })
|
|
21
|
+
|
|
22
|
+
const data = props.data != undefined ? props.data : {
|
|
23
|
+
itemwidth: '92%',
|
|
24
|
+
displaytext: 'Name',
|
|
25
|
+
iconname: 'home',
|
|
26
|
+
value: 45,
|
|
27
|
+
type: 'number-pad',
|
|
28
|
+
editable: true,
|
|
29
|
+
placeholder: 'Name',
|
|
30
|
+
decimal: 2,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View style={{
|
|
35
|
+
marginHorizontal: normalize(5),
|
|
36
|
+
}}>
|
|
37
|
+
{data.displaytext != undefined ?
|
|
38
|
+
<CText style={{ fontSize: normalize(12), color: 'black', paddingHorizontal: 5 }}>{data.displaytext != undefined ? data.displaytext : 'Default'}</CText> : null}
|
|
39
|
+
|
|
40
|
+
<View style={{ flexDirection: 'row',alignItems:'center' }}>
|
|
41
|
+
<View style={{ flexDirection: 'row', borderWidth: 1, borderRadius: 5, alignItems: 'center', backgroundColor: '#fff', elevation: 3, borderColor: colorBg ? '#8ec6ff' : 'lightgrey' }}>
|
|
42
|
+
{props.hideicon ? null : <FontAwesome5 name={data.iconname != undefined ? data.iconname : 'file-alt'} size={normalize(15)} color={Global.AppTheme.primary_color} style={{ paddingHorizontal: 5, width: normalize(25) }} />}
|
|
43
|
+
<TextInput
|
|
44
|
+
style={{
|
|
45
|
+
width: data.itemwidth != undefined ? data.itemwidth : Dimensions.get('screen').width * 0.25,
|
|
46
|
+
padding: normalize(5),
|
|
47
|
+
fontSize: normalize(14),
|
|
48
|
+
height: data.disableheight ? null : data.height != undefined ? normalize(100) : normalize(30),
|
|
49
|
+
paddingBottom: 3,
|
|
50
|
+
color:'black',
|
|
51
|
+
}}
|
|
52
|
+
onChangeText={val => ChangeValue(val)}
|
|
53
|
+
multiline={true}
|
|
54
|
+
onFocus={() => setColorBg(true)}
|
|
55
|
+
onEndEditing={(val) => props.onEndEditing != undefined ? props.onEndEditing(val) : () => getFocusOut()}
|
|
56
|
+
onSubmitEditing={props.onSubmitEditing != undefined ? (val) => props.onSubmitEditing(val) : null}
|
|
57
|
+
autoCapitalize={data.capitalize != undefined ? data.capitalize : 'none'}
|
|
58
|
+
textAlign={data.alignment != undefined ? data.alignment : data.type == 'number-pad' ? 'right' : 'left'}
|
|
59
|
+
keyboardType={data.type != undefined ? data.type : 'default'}
|
|
60
|
+
maxLength={data.maxlength != undefined ? data.maxlength : 200}
|
|
61
|
+
editable={data.editable != undefined ? data.editable : true}
|
|
62
|
+
placeholder={data.placeholder != undefined ? data.placeholder : null}
|
|
63
|
+
{...props}
|
|
64
|
+
>{data.value != undefined ? data.value : ''}</TextInput>
|
|
65
|
+
</View>
|
|
66
|
+
|
|
67
|
+
{props.unit != undefined && props.unit != null && props.unit != '' ?
|
|
68
|
+
<TouchableOpacity
|
|
69
|
+
disabled={props.tprcallback ? false : true}
|
|
70
|
+
onPress={() => {
|
|
71
|
+
props.tprcallback ? props.tprcallback(true) : null;
|
|
72
|
+
}}
|
|
73
|
+
style={{
|
|
74
|
+
borderStyle: props.tprcallback ? 'solid' : 'dotted',
|
|
75
|
+
elevation: props.tprcallback ? 3 : 0,
|
|
76
|
+
borderRadius: 5,
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
height: normalize(30),
|
|
79
|
+
justifyContent: 'center',
|
|
80
|
+
borderWidth: 1,
|
|
81
|
+
marginLeft: 1,
|
|
82
|
+
width: normalize(30),
|
|
83
|
+
backgroundColor: '#f7f7f7',
|
|
84
|
+
borderColor: Global.AppTheme.primary_color,
|
|
85
|
+
}}>
|
|
86
|
+
<Text numberOfLines={1} adjustsFontSizeToFit style={{
|
|
87
|
+
fontWeight: 'bold', color: data.errorStatus != undefined
|
|
88
|
+
&& data.errorStatus ? 'red' : Global.AppTheme.primary_color, fontSize: normalize(12),
|
|
89
|
+
}}>{props.unit}</Text>
|
|
90
|
+
{/* <Text style={{
|
|
91
|
+
fontSize: normalize(8),
|
|
92
|
+
color: 'black'
|
|
93
|
+
}}>
|
|
94
|
+
{"Setup"}
|
|
95
|
+
</Text> */}
|
|
96
|
+
</TouchableOpacity> : null}
|
|
97
|
+
</View>
|
|
98
|
+
</View>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
function getFocusOut() {
|
|
102
|
+
setColorBg(false);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function ChangeValue(changevalue) {
|
|
106
|
+
|
|
107
|
+
if (props.normalTextInput) {
|
|
108
|
+
setText(changevalue);
|
|
109
|
+
(props.callBack != undefined ? (props.callBack(changevalue)) : console.log('non changed'));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
|
|
113
|
+
let datatype = data.datatype != undefined ? data.datatype : 'integer';
|
|
114
|
+
let _error = changevalue == '' ? false : validate(changevalue, datatype);
|
|
115
|
+
data.errorStatus = _error == false ? false : true;
|
|
116
|
+
setText(changevalue);
|
|
117
|
+
(props.callBack != undefined ? (props.callBack(changevalue)) : console.log('non changed'));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function validate(text, datatype) {
|
|
122
|
+
let status = true;
|
|
123
|
+
switch (datatype) {
|
|
124
|
+
case 'integer':
|
|
125
|
+
let integerRegex = /^[0-9.]*$/;
|
|
126
|
+
if (integerRegex.exec(text)) {
|
|
127
|
+
if (data.minvalue == null && data.maxvalue == null) {
|
|
128
|
+
status = false;
|
|
129
|
+
} else if (data.minvalue == null) {
|
|
130
|
+
if (data.maxvalue == '') {
|
|
131
|
+
status = false;
|
|
132
|
+
} else {
|
|
133
|
+
if (text <= data.maxvalue) {
|
|
134
|
+
status = false;
|
|
135
|
+
} else {
|
|
136
|
+
status = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} else if (data.maxvalue == null) {
|
|
140
|
+
if (data.minvalue == '') {
|
|
141
|
+
status = false;
|
|
142
|
+
} else {
|
|
143
|
+
if (text >= data.minvalue) {
|
|
144
|
+
status = false;
|
|
145
|
+
} else {
|
|
146
|
+
status = true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
} else if (data.minvalue == '' && data.maxvalue == '') {
|
|
150
|
+
status = false;
|
|
151
|
+
} else if (data.minvalue == '') {
|
|
152
|
+
if (text <= data.maxvalue) {
|
|
153
|
+
status = false;
|
|
154
|
+
} else {
|
|
155
|
+
status = true;
|
|
156
|
+
}
|
|
157
|
+
} else if (data.maxvalue == '') {
|
|
158
|
+
if (text >= data.minvalue) {
|
|
159
|
+
status = false;
|
|
160
|
+
} else {
|
|
161
|
+
status = true;
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
if (text >= data.minvalue && text <= data.maxvalue) {
|
|
165
|
+
status = false;
|
|
166
|
+
} else {
|
|
167
|
+
status = true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
status = true;
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case 'password':
|
|
175
|
+
let passwordRegex = /[0-9a-zA-Z]/;
|
|
176
|
+
if (passwordRegex.exec(text)) {status = false;}
|
|
177
|
+
else {status = true;}
|
|
178
|
+
break;
|
|
179
|
+
case 'string':
|
|
180
|
+
let stringRegex = /^[a-zA-Z0-9.!#$%&@\s]*$/;
|
|
181
|
+
if (stringRegex.exec(text)) {
|
|
182
|
+
let minvalue = data.minvalue;
|
|
183
|
+
let maxvalue = data.maxvalue;
|
|
184
|
+
let length = text == null ? 0 : text.length;
|
|
185
|
+
if (minvalue == null && maxvalue == null) {
|
|
186
|
+
status = false;
|
|
187
|
+
} else if (minvalue == null) {
|
|
188
|
+
if (maxvalue == '') {
|
|
189
|
+
status = false;
|
|
190
|
+
} else {
|
|
191
|
+
if (length <= maxvalue) {
|
|
192
|
+
status = false;
|
|
193
|
+
} else {
|
|
194
|
+
status = true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} else if (maxvalue == null) {
|
|
198
|
+
if (minvalue == '') {
|
|
199
|
+
status = false;
|
|
200
|
+
} else {
|
|
201
|
+
if (length >= minvalue) {
|
|
202
|
+
status = false;
|
|
203
|
+
} else {
|
|
204
|
+
status = true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} else if (minvalue == '' && maxvalue == '') {
|
|
208
|
+
status = false;
|
|
209
|
+
} else if (minvalue == '') {
|
|
210
|
+
if (length <= maxvalue) {
|
|
211
|
+
status = false;
|
|
212
|
+
} else {
|
|
213
|
+
status = true;
|
|
214
|
+
}
|
|
215
|
+
} else if (maxvalue == '') {
|
|
216
|
+
if (length >= minvalue) {
|
|
217
|
+
status = false;
|
|
218
|
+
} else {
|
|
219
|
+
status = true;
|
|
220
|
+
}
|
|
221
|
+
} else {
|
|
222
|
+
if (length >= minvalue && length <= maxvalue) {
|
|
223
|
+
status = false;
|
|
224
|
+
} else {
|
|
225
|
+
status = true;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
status = true;
|
|
230
|
+
}
|
|
231
|
+
break;
|
|
232
|
+
case 'numeric':
|
|
233
|
+
let numericRegex = /^[0-9.]*$/;
|
|
234
|
+
if (numericRegex.exec(text)) {
|
|
235
|
+
if (data.minvalue == null && data.maxvalue == null) {
|
|
236
|
+
status = false;
|
|
237
|
+
} else if (data.minvalue == null) {
|
|
238
|
+
if (data.maxvalue == '') {
|
|
239
|
+
status = false;
|
|
240
|
+
} else {
|
|
241
|
+
if (text <= data.maxvalue) {
|
|
242
|
+
status = false;
|
|
243
|
+
} else {
|
|
244
|
+
status = true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} else if (data.maxvalue == null) {
|
|
248
|
+
if (data.minvalue == '') {
|
|
249
|
+
status = false;
|
|
250
|
+
} else {
|
|
251
|
+
if (text >= data.minvalue) {
|
|
252
|
+
status = false;
|
|
253
|
+
} else {
|
|
254
|
+
status = true;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
} else if (data.minvalue == '' && data.maxvalue == '') {
|
|
258
|
+
status = false;
|
|
259
|
+
} else if (data.minvalue == '') {
|
|
260
|
+
if (text <= data.maxvalue) {
|
|
261
|
+
status = false;
|
|
262
|
+
} else {
|
|
263
|
+
status = true;
|
|
264
|
+
}
|
|
265
|
+
} else if (data.maxvalue == '') {
|
|
266
|
+
if (text >= data.minvalue) {
|
|
267
|
+
status = false;
|
|
268
|
+
} else {
|
|
269
|
+
status = true;
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
if (text >= data.minvalue && text <= data.maxvalue) {
|
|
273
|
+
status = false;
|
|
274
|
+
} else {
|
|
275
|
+
status = true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
status = true;
|
|
280
|
+
}
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
return status;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
export default STextInput;
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { TextInput, StyleSheet } from 'react-native';
|
|
3
|
+
import { normalize } from '../CommonStyle/componentStyle';
|
|
4
|
+
|
|
5
|
+
const STextInputProps = (props) => {
|
|
6
|
+
const [colorBg, setColorBg] = useState(false);
|
|
7
|
+
function getFocusOut() {
|
|
8
|
+
setColorBg(false);
|
|
9
|
+
}
|
|
10
|
+
return (
|
|
11
|
+
<TextInput
|
|
12
|
+
style={[props.style, { borderColor: colorBg ? '#90ff00' : 'rgba(68, 60, 150,0.5)' }]}
|
|
13
|
+
keyboardType={props.keyboardType}
|
|
14
|
+
onChangeText={props.onChangeText}
|
|
15
|
+
placeholder={props.placeholder}
|
|
16
|
+
editable={props.editable}
|
|
17
|
+
onBlur={() => getFocusOut()}
|
|
18
|
+
onEndEditing={props.onEndEditing != undefined ? props.onEndEditing : null}
|
|
19
|
+
onFocus={() => setColorBg(true)}
|
|
20
|
+
>{props.value}</TextInput>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
function getFocusOut(params) {
|
|
24
|
+
setColorBg(false);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
input: {
|
|
30
|
+
height: normalize(40),
|
|
31
|
+
margin: 12,
|
|
32
|
+
borderWidth: 1,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export default STextInputProps;
|