@jescon-technologies/react-native-ui-kit 0.0.1 → 0.0.3
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 +25 -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,330 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { View, StyleSheet, TouchableOpacity, Dimensions, Text } from 'react-native';
|
|
3
|
+
import ComponentStyles, { normalize } from '../CommonStyle/componentStyle';
|
|
4
|
+
import { isBNUL, isNU, isNUQ, notifyMessage } from '../CommonStyle/ComponentFunctions';
|
|
5
|
+
import HeaderBlock from '../Screens/HeaderBlock';
|
|
6
|
+
import { useNavigation } from '../Navigation/useNavigation';
|
|
7
|
+
import { Camera, getCameraDevice, useCameraDevices, useCameraFormat, useCodeScanner } from 'react-native-vision-camera';
|
|
8
|
+
import CFooterView from '../CustomComponents/CFooterView';
|
|
9
|
+
import { Global } from '../Common/Global';
|
|
10
|
+
import HOCIcons from '../HOC/HOCIcons';
|
|
11
|
+
import PhotoEditor from 'react-native-photo-editor';
|
|
12
|
+
|
|
13
|
+
export default function CCaptureImageWithoutEdit(props) {
|
|
14
|
+
|
|
15
|
+
const [cameraType, setCameraType] = useState();
|
|
16
|
+
const [showCamera, setShowCamera] = useState(false);
|
|
17
|
+
const navigation = useNavigation();
|
|
18
|
+
const vcamera = useRef(null);
|
|
19
|
+
const vdevices = Camera.getAvailableCameraDevices();
|
|
20
|
+
const [vdevice, setVDevice] = useState();
|
|
21
|
+
// for video recording
|
|
22
|
+
const [isRecording, setIsRecording] = useState(false); // New state for recording
|
|
23
|
+
const [videoPath, setVideoPath] = useState(''); // To store the video path when recording is stopped
|
|
24
|
+
|
|
25
|
+
const codeScanner = useCodeScanner({
|
|
26
|
+
|
|
27
|
+
codeTypes: ['qr', 'ean-13','code-128','code-39','code-93'],
|
|
28
|
+
onCodeScanned: (codes) => {
|
|
29
|
+
if ((props.route?.params?.cameramoduletype == 2) && isBNUL(codes) && isNUQ(codes[0].value)) {
|
|
30
|
+
props.route.params.onSelect({
|
|
31
|
+
data: codes[0].value,
|
|
32
|
+
});
|
|
33
|
+
navigation.pop();
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
async function getPermission() {
|
|
40
|
+
const newCameraPermission = await Camera.requestCameraPermission();
|
|
41
|
+
if (newCameraPermission == 'granted') {
|
|
42
|
+
let cameraAngle = props.route?.params?.cameratype ? props.route?.params?.cameratype : 'back';
|
|
43
|
+
setCameraType(cameraAngle);
|
|
44
|
+
setVDevice(getCameraDevice(vdevices, cameraAngle));
|
|
45
|
+
setShowCamera(true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
getPermission();
|
|
49
|
+
}, [vdevices]);
|
|
50
|
+
|
|
51
|
+
function getCameraType(params, vdevices) {
|
|
52
|
+
|
|
53
|
+
if (params == 'back') {
|
|
54
|
+
console.log('getCameraType1111', params);
|
|
55
|
+
setCameraType('front');
|
|
56
|
+
setVDevice(getCameraDevice(vdevices, 'front'));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
console.log('getCameraType 222', params);
|
|
60
|
+
setCameraType('back');
|
|
61
|
+
setVDevice(getCameraDevice(vdevices, 'back'));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const capturePhoto = async () => {
|
|
66
|
+
if (vcamera.current !== null) {
|
|
67
|
+
|
|
68
|
+
const photo = await vcamera.current.takePhoto({
|
|
69
|
+
// qualityPrioritization: 'quality', // prioritize photo quality
|
|
70
|
+
// maxWidth: 640, // Decrease the width for lower resolution
|
|
71
|
+
// maxHeight: 480, // D
|
|
72
|
+
});
|
|
73
|
+
const photopath = `file://${photo.path}`;
|
|
74
|
+
// let imgPath = photopath.replace('file:///', '');
|
|
75
|
+
let fileName = photopath.substr(photopath.lastIndexOf('/') + 1);
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
PhotoEditor.Edit({
|
|
79
|
+
path: photo.path, hiddenControls: ['sticker', 'save'],
|
|
80
|
+
onDone: () => {
|
|
81
|
+
props.route.params.onSelect({
|
|
82
|
+
uri: photopath,
|
|
83
|
+
filename: fileName,
|
|
84
|
+
filetype: 'image/jpeg',
|
|
85
|
+
});
|
|
86
|
+
navigation.pop();
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// props.route.params.onSelect({
|
|
91
|
+
// uri: `file://${photo.path}`,
|
|
92
|
+
// filename: fileName,
|
|
93
|
+
// filetype: "image/jpeg",
|
|
94
|
+
// });
|
|
95
|
+
// navigation.pop();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const startRecording = async () => {
|
|
100
|
+
if (vcamera.current) {
|
|
101
|
+
try {
|
|
102
|
+
setIsRecording(true);
|
|
103
|
+
const video = await vcamera.current.startRecording({
|
|
104
|
+
onRecordingFinished: (uri) => {
|
|
105
|
+
setVideoPath(uri.path);
|
|
106
|
+
console.log('videoPath real ........', uri);
|
|
107
|
+
props.route.params.onSelect({
|
|
108
|
+
uri: `file://${uri.path}`,
|
|
109
|
+
filename: `${new Date().toISOString()}.mp4`,
|
|
110
|
+
filetype: 'video/mp4',
|
|
111
|
+
});
|
|
112
|
+
// console.log('videoPath............', videoPath);
|
|
113
|
+
navigation.pop();
|
|
114
|
+
},
|
|
115
|
+
onRecordingError: (error) => {
|
|
116
|
+
console.error(error);
|
|
117
|
+
setIsRecording(false);
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error('Error starting video recording:', error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const stopRecording = async () => {
|
|
127
|
+
if (vcamera.current) {
|
|
128
|
+
try {
|
|
129
|
+
setIsRecording(false);
|
|
130
|
+
await vcamera.current.stopRecording();
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error('Error stopping video recording:', error);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const format = useCameraFormat(vdevice, [
|
|
138
|
+
{
|
|
139
|
+
photoResolution: { width: 640, height: 480 },
|
|
140
|
+
},
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
// { videoResolution: { width: 3048, height: 2160 } },
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<View style={{ flex: 1 }}>
|
|
148
|
+
<HeaderBlock
|
|
149
|
+
/>
|
|
150
|
+
<View style={[layoutstyles.container]}>
|
|
151
|
+
{vdevice != null && showCamera ? (
|
|
152
|
+
<View style={{ flex: 1, borderWidth: 1 }}>
|
|
153
|
+
<Camera
|
|
154
|
+
ref={vcamera}
|
|
155
|
+
style={StyleSheet.absoluteFill}
|
|
156
|
+
device={vdevice}
|
|
157
|
+
// format={format}
|
|
158
|
+
isActive={showCamera}
|
|
159
|
+
photo={true}
|
|
160
|
+
codeScanner={codeScanner}
|
|
161
|
+
video={props.route?.params?.cameramoduletype === 1}
|
|
162
|
+
// format={''}
|
|
163
|
+
// videoBitRate={'extra-low'}
|
|
164
|
+
onInitialized={() => {
|
|
165
|
+
console.log('camera initialized.');
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
168
|
+
</View>
|
|
169
|
+
) : (
|
|
170
|
+
|
|
171
|
+
<View style={{ justifyContent: 'center', alignItems: 'center', flex: 1, borderWidth: 1 }}>
|
|
172
|
+
<Text>{'Camera Permission required.'}</Text>
|
|
173
|
+
</View>
|
|
174
|
+
)}
|
|
175
|
+
</View>
|
|
176
|
+
{
|
|
177
|
+
props.route?.params?.hidebuttons ?
|
|
178
|
+
null :
|
|
179
|
+
<CFooterView>
|
|
180
|
+
{isNU(cameraType) && isNU(vdevices) ?
|
|
181
|
+
<View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
|
|
182
|
+
<View style={{ flex: 2 }} />
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
{/* Start/Stop Video Recording Button */}
|
|
186
|
+
{props.route?.params?.cameramoduletype === 1 ?
|
|
187
|
+
<View style={{ borderWidth: 0, flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
188
|
+
<TouchableOpacity
|
|
189
|
+
onPress={() => {
|
|
190
|
+
if (isRecording) {
|
|
191
|
+
stopRecording();
|
|
192
|
+
} else {
|
|
193
|
+
startRecording();
|
|
194
|
+
}
|
|
195
|
+
}}
|
|
196
|
+
style={{
|
|
197
|
+
opacity: 1,
|
|
198
|
+
borderRadius: 100,
|
|
199
|
+
borderLeftWidth: 2,
|
|
200
|
+
borderBottomWidth: 2,
|
|
201
|
+
borderColor: Global.AppTheme.primary_color,
|
|
202
|
+
borderWidth: 0.5,
|
|
203
|
+
justifyContent: 'center',
|
|
204
|
+
alignItems: 'center',
|
|
205
|
+
margin: normalize(5),
|
|
206
|
+
height: normalize(60),
|
|
207
|
+
width: normalize(60),
|
|
208
|
+
backgroundColor: isRecording ? 'red' : 'white',
|
|
209
|
+
elevation: 2,
|
|
210
|
+
}}>
|
|
211
|
+
<HOCIcons.Icons
|
|
212
|
+
icongroup={5}
|
|
213
|
+
name={isRecording ? 'stop' : 'video'}
|
|
214
|
+
color={isRecording ? 'white' : Global.AppTheme.primary_color}
|
|
215
|
+
size={normalize(30)} style={{
|
|
216
|
+
marginHorizontal: normalize(3),
|
|
217
|
+
}}
|
|
218
|
+
/>
|
|
219
|
+
|
|
220
|
+
</TouchableOpacity>
|
|
221
|
+
<Text adjustsFontSizeToFit style={{
|
|
222
|
+
fontSize: normalize(8),
|
|
223
|
+
color: Global.AppTheme.primary_color,
|
|
224
|
+
textAlign: 'center',
|
|
225
|
+
fontWeight: 'bold',
|
|
226
|
+
}} >
|
|
227
|
+
{isRecording ? 'Stop' : 'Record'}
|
|
228
|
+
</Text>
|
|
229
|
+
</View>
|
|
230
|
+
:
|
|
231
|
+
<View style={{ borderWidth: 0, flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
232
|
+
<TouchableOpacity
|
|
233
|
+
onPress={() => {
|
|
234
|
+
capturePhoto();
|
|
235
|
+
}}
|
|
236
|
+
style={{
|
|
237
|
+
opacity: 1,
|
|
238
|
+
borderRadius: 100,
|
|
239
|
+
borderLeftWidth: 2,
|
|
240
|
+
borderBottomWidth: 2,
|
|
241
|
+
borderColor: Global.AppTheme.primary_color,
|
|
242
|
+
borderWidth: 0.5,
|
|
243
|
+
justifyContent: 'center',
|
|
244
|
+
alignItems: 'center',
|
|
245
|
+
margin: normalize(5),
|
|
246
|
+
height: normalize(60),
|
|
247
|
+
width: normalize(60),
|
|
248
|
+
backgroundColor: 'white',
|
|
249
|
+
elevation: 2,
|
|
250
|
+
}}>
|
|
251
|
+
<HOCIcons.Icons
|
|
252
|
+
icongroup={5}
|
|
253
|
+
name={'camera'}
|
|
254
|
+
color={Global.AppTheme.primary_color}
|
|
255
|
+
size={normalize(22)} style={{
|
|
256
|
+
marginHorizontal: normalize(3),
|
|
257
|
+
}}
|
|
258
|
+
/>
|
|
259
|
+
|
|
260
|
+
</TouchableOpacity>
|
|
261
|
+
<Text adjustsFontSizeToFit style={{
|
|
262
|
+
fontSize: normalize(8),
|
|
263
|
+
color: Global.AppTheme.primary_color,
|
|
264
|
+
textAlign: 'center',
|
|
265
|
+
fontWeight: 'bold',
|
|
266
|
+
}} >
|
|
267
|
+
{'Capture'}
|
|
268
|
+
</Text>
|
|
269
|
+
</View>
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
<View style={{ justifyContent: 'center', alignItems: 'center', flex: 2 }}>
|
|
273
|
+
{isRecording ?
|
|
274
|
+
null :
|
|
275
|
+
<>
|
|
276
|
+
<TouchableOpacity
|
|
277
|
+
onPress={() => {
|
|
278
|
+
getCameraType(cameraType, vdevices);
|
|
279
|
+
}}
|
|
280
|
+
style={{
|
|
281
|
+
opacity: 1,
|
|
282
|
+
borderRadius: 100,
|
|
283
|
+
borderLeftWidth: 2,
|
|
284
|
+
borderBottomWidth: 2,
|
|
285
|
+
borderColor: Global.AppTheme.primary_color,
|
|
286
|
+
borderWidth: 0.5,
|
|
287
|
+
justifyContent: 'center',
|
|
288
|
+
alignItems: 'center',
|
|
289
|
+
margin: normalize(5),
|
|
290
|
+
height: normalize(45),
|
|
291
|
+
width: normalize(45),
|
|
292
|
+
backgroundColor: 'white',
|
|
293
|
+
elevation: 2,
|
|
294
|
+
}}>
|
|
295
|
+
<HOCIcons.Icons
|
|
296
|
+
icongroup={2}
|
|
297
|
+
name={'flip-camera-ios'}
|
|
298
|
+
color={Global.AppTheme.primary_color}
|
|
299
|
+
size={normalize(22)} style={{
|
|
300
|
+
marginHorizontal: normalize(3),
|
|
301
|
+
}}
|
|
302
|
+
/>
|
|
303
|
+
|
|
304
|
+
</TouchableOpacity>
|
|
305
|
+
<Text adjustsFontSizeToFit style={{
|
|
306
|
+
fontSize: normalize(7),
|
|
307
|
+
color: Global.AppTheme.primary_color,
|
|
308
|
+
textAlign: 'center',
|
|
309
|
+
fontWeight: 'bold',
|
|
310
|
+
}} >
|
|
311
|
+
{'Rotate'}
|
|
312
|
+
</Text>
|
|
313
|
+
</>
|
|
314
|
+
}
|
|
315
|
+
</View>
|
|
316
|
+
</View>
|
|
317
|
+
: null}
|
|
318
|
+
</CFooterView>
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
</View>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const layoutstyles = StyleSheet.create({
|
|
326
|
+
container: {
|
|
327
|
+
flex: 1,
|
|
328
|
+
flexDirection: 'column',
|
|
329
|
+
},
|
|
330
|
+
});
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TouchableOpacity,
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
Image,
|
|
7
|
+
FlatList,
|
|
8
|
+
Dimensions,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import Carousel, { Pagination } from 'react-native-snap-carousel';
|
|
11
|
+
import ImageZoom from 'react-native-image-pan-zoom';
|
|
12
|
+
import Overlay from 'react-native-modal-overlay';
|
|
13
|
+
import CDetailView from '../CustomComponents/CDetailView';
|
|
14
|
+
import CContainerView from '../CustomComponents/CContainerView';
|
|
15
|
+
import HeaderBlock from '../Screens/HeaderBlock';
|
|
16
|
+
import { normalize } from '../CommonStyle/componentStyle';
|
|
17
|
+
import { imageURL } from '../Common/apiConstants';
|
|
18
|
+
import FastImage from 'react-native-fast-image';
|
|
19
|
+
import { Global } from '../Common/Global';
|
|
20
|
+
import { ArrayCheck, ValueCheck } from '../CommonStyle/ComponentFunctions';
|
|
21
|
+
const { width } = Dimensions.get('window');
|
|
22
|
+
const { height } = Dimensions.get('window');
|
|
23
|
+
const SPACING = normalize(10);
|
|
24
|
+
const THUMB_SIZE = normalize(80);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const CImageGallery = (props) => {
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
onSelectUseEffect(props.route.params.index);
|
|
32
|
+
onTouchThumbnailUseEffect(props.route.params.index);
|
|
33
|
+
//onSelect(props.route.params.index)
|
|
34
|
+
}, 1000);
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
// console.log("props of cimagegallery",JSON.stringify(props))
|
|
40
|
+
//console.log("indexxxxxxxxxxxxx",props.route.params.index)
|
|
41
|
+
const mappedimages = ValueCheck(props.route.params) && ArrayCheck(props.route.params.savedimages) ? props.route.params.savedimages.map(item => {
|
|
42
|
+
return {
|
|
43
|
+
uri: item.filename,
|
|
44
|
+
};
|
|
45
|
+
}) : [];
|
|
46
|
+
// console.log("mappedimages",JSON.stringify(mappedimages));
|
|
47
|
+
const IMAGES = {
|
|
48
|
+
image1: 'https://i.ibb.co/7nPcjFN/amalalogo.jpg',
|
|
49
|
+
image2: 'https://i.ibb.co/7nPcjFN/amalalogo.jpg',
|
|
50
|
+
image3: 'https://i.ibb.co/7nPcjFN/amalalogo.jpg',
|
|
51
|
+
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const carouselRef = useRef();
|
|
55
|
+
//console.log("carouselref",carouselRef)
|
|
56
|
+
const flatListRef = useRef();
|
|
57
|
+
//console.log("flatlistref",flatListRef)
|
|
58
|
+
const [images, setImages] = useState(props.route.params.savedimages);
|
|
59
|
+
//console.log("imagessssss",JSON.stringify(images))
|
|
60
|
+
const [indexSelected, setIndexSelected] = useState(props.route.params.index);
|
|
61
|
+
const [isloading, setIsLoading] = useState(true);
|
|
62
|
+
//const firstitem = props.route.params.index - 1;
|
|
63
|
+
//console.log("firstitem",firstitem)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const onSelectUseEffect = (indexSelected) => {
|
|
67
|
+
console.log('onselectuseeffect', indexSelected);
|
|
68
|
+
setIndexSelected(indexSelected);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* if you want to position the thumbnail in * the middle of the screen on selection
|
|
72
|
+
* do the following
|
|
73
|
+
* Calculation done by awesome Catalin Miron
|
|
74
|
+
* Source: https://www.youtube.com/watch?v=gjC2oUJhePE&t=1097s
|
|
75
|
+
*/
|
|
76
|
+
// if (indexSelected * (THUMB_SIZE + 10) - THUMB_SIZE / 2 > width / 2) {
|
|
77
|
+
// flatListRef?.current?.scrollToOffset({
|
|
78
|
+
// offset: indexSelected * (THUMB_SIZE + 10) - width / 2 + THUMB_SIZE / 2,
|
|
79
|
+
// animated: true,
|
|
80
|
+
// });
|
|
81
|
+
// } else {
|
|
82
|
+
// flatListRef?.current?.scrollToOffset({
|
|
83
|
+
// offset: 0,
|
|
84
|
+
// animated: true,
|
|
85
|
+
// });
|
|
86
|
+
// }
|
|
87
|
+
|
|
88
|
+
// my initial solution
|
|
89
|
+
flatListRef?.current?.scrollToOffset({
|
|
90
|
+
// offset: indexSelected * (normalize(50) + 10) - normalize(50) / 2 + normalize(50) / 2,
|
|
91
|
+
//offset: indexSelected * (normalize(60)+ normalize(10)),
|
|
92
|
+
|
|
93
|
+
offset: indexSelected * (normalize(50) + normalize(10)),
|
|
94
|
+
//offset:indexSelected * (normalize(50)),
|
|
95
|
+
animated: true,
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const onSelect = (indexSelected) => {
|
|
100
|
+
console.log('onselect', indexSelected);
|
|
101
|
+
setIndexSelected(indexSelected);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* if you want to position the thumbnail in * the middle of the screen on selection
|
|
105
|
+
* do the following
|
|
106
|
+
* Calculation done by awesome Catalin Miron
|
|
107
|
+
* Source: https://www.youtube.com/watch?v=gjC2oUJhePE&t=1097s
|
|
108
|
+
*/
|
|
109
|
+
// if (indexSelected * (THUMB_SIZE + 10) - THUMB_SIZE / 2 > width / 2) {
|
|
110
|
+
// flatListRef?.current?.scrollToOffset({
|
|
111
|
+
// offset: indexSelected * (THUMB_SIZE + 10) - width / 2 + THUMB_SIZE / 2,
|
|
112
|
+
// animated: true,
|
|
113
|
+
// });
|
|
114
|
+
// } else {
|
|
115
|
+
// flatListRef?.current?.scrollToOffset({
|
|
116
|
+
// offset: 0,
|
|
117
|
+
// animated: true,
|
|
118
|
+
// });
|
|
119
|
+
// }
|
|
120
|
+
|
|
121
|
+
// my initial solution
|
|
122
|
+
// flatListRef?.current?.scrollToOffset({
|
|
123
|
+
// //offset: indexSelected * (images.length) - width / 2 + images.length / 2,
|
|
124
|
+
// offset: normalize(indexSelected) * normalize(57),
|
|
125
|
+
// //offset:indexSelected * THUMB_SIZE,
|
|
126
|
+
// animated: true,
|
|
127
|
+
// });
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const onTouchThumbnail = (touched) => {
|
|
131
|
+
carouselRef?.current?.snapToItem(touched);
|
|
132
|
+
//setIndexSelected(touched);
|
|
133
|
+
//onSelect(touched)
|
|
134
|
+
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
const onTouchThumbnailUseEffect = (touched) => {
|
|
140
|
+
console.log('toucheduseeffect', touched),
|
|
141
|
+
|
|
142
|
+
carouselRef?.current?.snapToItem(touched);
|
|
143
|
+
|
|
144
|
+
// [1,2,3,4].map(number => {
|
|
145
|
+
|
|
146
|
+
// setTimeout(() => {
|
|
147
|
+
// carouselRef?.current?.snapToItem(touched)
|
|
148
|
+
// console.log("n",number)
|
|
149
|
+
// }, 500)
|
|
150
|
+
// })
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
function getOverlayContainerStyle() {
|
|
156
|
+
return (
|
|
157
|
+
{
|
|
158
|
+
// ...ComponentStyles.View_col_center,
|
|
159
|
+
backgroundColor: '#fff',
|
|
160
|
+
height: height, width: width,
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
function logOutZoomState(event, gestureState, zoomableViewEventObject) {
|
|
165
|
+
//console.log('');
|
|
166
|
+
// console.log('');
|
|
167
|
+
//console.log('-------------');
|
|
168
|
+
//console.log('Event: ', event);
|
|
169
|
+
//console.log('GestureState: ', gestureState);
|
|
170
|
+
//console.log('ZoomableEventObject: ', zoomableViewEventObject);
|
|
171
|
+
//console.log('');
|
|
172
|
+
// console.log(
|
|
173
|
+
// `Zoomed from ${zoomableViewEventObject.lastZoomLevel} to ${zoomableViewEventObject.zoomLevel}`,
|
|
174
|
+
//);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
// <Overlay
|
|
179
|
+
// visible={isloading}
|
|
180
|
+
// //onClose={() => props.visibility(false)}
|
|
181
|
+
// //transparent={true}
|
|
182
|
+
// //containerStyle={getOverlayContainerStyle()}
|
|
183
|
+
// //animationDuration={500}
|
|
184
|
+
// //closeOnTouchOutside={true}
|
|
185
|
+
// >
|
|
186
|
+
<CContainerView>
|
|
187
|
+
<HeaderBlock/>
|
|
188
|
+
<CDetailView>
|
|
189
|
+
<View style={{ flex: 1, backgroundColor: 'white', alignItems: 'center' }}>
|
|
190
|
+
<View style={{ flex: 2, marginTop: 1 }}>
|
|
191
|
+
<View>
|
|
192
|
+
<Carousel
|
|
193
|
+
ref={carouselRef}
|
|
194
|
+
layout={'default'}
|
|
195
|
+
data={props.route.params.savedimages}
|
|
196
|
+
sliderWidth={width * 10}
|
|
197
|
+
itemWidth={width}
|
|
198
|
+
//initialScrollIndex={props.route.params.index}
|
|
199
|
+
//firstItem={indexSelected}
|
|
200
|
+
onSnapToItem={(index) => onSelect(index)}
|
|
201
|
+
renderItem={({ item, index }) => (
|
|
202
|
+
<ImageZoom
|
|
203
|
+
cropWidth={width * 1}
|
|
204
|
+
cropHeight={height * 0.8}
|
|
205
|
+
imageWidth={width * 1}
|
|
206
|
+
imageHeight={height * 0.8}
|
|
207
|
+
enableSwipeDown={false}
|
|
208
|
+
panToMove={true}
|
|
209
|
+
>
|
|
210
|
+
<FastImage
|
|
211
|
+
key={index}
|
|
212
|
+
style={{ width: '100%', height: '80%' }}
|
|
213
|
+
resizeMode="contain"
|
|
214
|
+
source={{
|
|
215
|
+
uri: item && item.filename && item.filename != null && item.filename != undefined && item.filename.length > 0 && typeof item.filename === 'string' ? imageURL + item.filename : 'https://icon-library.com/images/no-image-icon/no-image-icon-0.jpg',
|
|
216
|
+
headers: {
|
|
217
|
+
Authorization: `Bearer ${Global.JWTToken}`,
|
|
218
|
+
},
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
</ImageZoom>
|
|
222
|
+
)}
|
|
223
|
+
/>
|
|
224
|
+
</View>
|
|
225
|
+
|
|
226
|
+
{/* <Pagination
|
|
227
|
+
inactiveDotColor="grey"
|
|
228
|
+
dotColor={'darkblue'}
|
|
229
|
+
activeDotIndex={indexSelected}
|
|
230
|
+
dotsLength={images.length}
|
|
231
|
+
animatedDuration={150}
|
|
232
|
+
inactiveDotScale={0.5}
|
|
233
|
+
/> */}
|
|
234
|
+
</View>
|
|
235
|
+
<View
|
|
236
|
+
style={{
|
|
237
|
+
marginTop: 20,
|
|
238
|
+
paddingHorizontal: 32,
|
|
239
|
+
alignSelf: 'flex-end',
|
|
240
|
+
}}
|
|
241
|
+
>
|
|
242
|
+
<Text style={{ color: 'black', fontSize: normalize(25), fontWeight: 'bold' }}>
|
|
243
|
+
{indexSelected + 1}/{images.length}
|
|
244
|
+
</Text>
|
|
245
|
+
</View>
|
|
246
|
+
{/* Thumbnail component using FlatList */}
|
|
247
|
+
<FlatList
|
|
248
|
+
ref={flatListRef}
|
|
249
|
+
initialNumToRender={50}
|
|
250
|
+
maxToRenderPerBatch={50}
|
|
251
|
+
horizontal={true}
|
|
252
|
+
data={props.route.params.savedimages}
|
|
253
|
+
style={{ position: 'absolute', bottom: normalize(30) }}
|
|
254
|
+
showsHorizontalScrollIndicator={false}
|
|
255
|
+
contentContainerStyle={{
|
|
256
|
+
//paddingHorizontal: SPACING,
|
|
257
|
+
}}
|
|
258
|
+
keyExtractor={(item, index) => 'key' + index}
|
|
259
|
+
renderItem={({ item, index }) => (
|
|
260
|
+
<TouchableOpacity
|
|
261
|
+
onPress={() => onTouchThumbnail(index)}
|
|
262
|
+
activeOpacity={0.3}
|
|
263
|
+
>
|
|
264
|
+
<FastImage
|
|
265
|
+
style={{
|
|
266
|
+
width: normalize(50),
|
|
267
|
+
height: normalize(50),
|
|
268
|
+
marginRight: normalize(10),
|
|
269
|
+
borderRadius: 16,
|
|
270
|
+
borderWidth: index === indexSelected ? 4 : 0.75,
|
|
271
|
+
borderColor: index === indexSelected ? 'darkblue' : 'grey',
|
|
272
|
+
}}
|
|
273
|
+
source={{
|
|
274
|
+
uri: item.filename && item.filename != null && item.filename != undefined && item.filename.length > 0 && typeof item.filename === 'string' ? imageURL + item.filename : 'https://icon-library.com/images/no-image-icon/no-image-icon-0.jpg',
|
|
275
|
+
headers: {
|
|
276
|
+
Authorization: `Bearer ${Global.JWTToken}`,
|
|
277
|
+
},
|
|
278
|
+
}}
|
|
279
|
+
/>
|
|
280
|
+
</TouchableOpacity>
|
|
281
|
+
)}
|
|
282
|
+
/>
|
|
283
|
+
</View>
|
|
284
|
+
</CDetailView>
|
|
285
|
+
</CContainerView>
|
|
286
|
+
);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export default CImageGallery;
|