@jescon-technologies/react-native-ui-kit 0.0.6 → 0.0.8

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.
Files changed (191) hide show
  1. package/index.d.ts +2 -66
  2. package/index.js +1 -66
  3. package/package.json +1 -1
  4. package/src/Alerts/AAlert.js +0 -137
  5. package/src/Alerts/AAlertIOS.js +0 -97
  6. package/src/Alerts/ABlink.js +0 -40
  7. package/src/Common/Icons.js +0 -49
  8. package/src/Common/NetworkServiceCall.js +0 -265
  9. package/src/CommonStyle/CommonTheme.js +0 -11
  10. package/src/CommonStyle/ComponentFunctions.js +0 -632
  11. package/src/CommonStyle/PopupStyle.js +0 -146
  12. package/src/CommonStyle/commonStyle.js +0 -93
  13. package/src/CommonStyle/componentStyle.js +0 -545
  14. package/src/CommonStyle/optionListStyles.js +0 -175
  15. package/src/Components/ByProductPage.js +0 -200
  16. package/src/Components/CDropDownListNew.js +0 -153
  17. package/src/Components/CSupplierList.js +0 -88
  18. package/src/Components/CVerificationCard.js +0 -2822
  19. package/src/Components/CustomButton.js +0 -67
  20. package/src/Components/CustomCard.js +0 -127
  21. package/src/Components/CustomTextInput.js +0 -47
  22. package/src/Components/EquipmentPage.js +0 -313
  23. package/src/Components/FilterInput.Copy.js +0 -723
  24. package/src/Components/FilterInput.js +0 -569
  25. package/src/Components/HSubHeading.js +0 -68
  26. package/src/Components/HeaderCard.js +0 -40
  27. package/src/Components/MoreOptionsScreen.js +0 -251
  28. package/src/Components/NonSwipableProductCard.js +0 -226
  29. package/src/Components/NonSwipableSupplierCard.js +0 -348
  30. package/src/Components/ProductCard.js +0 -1336
  31. package/src/Components/QualityProductCard.js +0 -1059
  32. package/src/Components/RateProductCard.js +0 -1452
  33. package/src/Components/RawMaterial.js +0 -261
  34. package/src/Components/SDropDownEdited.js +0 -549
  35. package/src/Components/SDropDownNew.js +0 -529
  36. package/src/Components/SHelpDescription.js +0 -147
  37. package/src/Components/STextInputNew.js +0 -510
  38. package/src/Components/SearchProductCard.js +0 -470
  39. package/src/Components/StageByProduct.js +0 -199
  40. package/src/Components/SupplierCard.js +0 -243
  41. package/src/Components/SupplierInvoiceCard.js +0 -405
  42. package/src/Components/SwipableSupplierCard.js +0 -136
  43. package/src/Components/TagTemplate.js +0 -74
  44. package/src/Components/WrappedComponent.js +0 -25
  45. package/src/Custom/CBooking.js +0 -944
  46. package/src/Custom/CBookingPostpone.js +0 -1822
  47. package/src/Custom/CCalendar.js +0 -560
  48. package/src/Custom/CCard.js +0 -880
  49. package/src/Custom/CDetailCard.js +0 -205
  50. package/src/Custom/CHelpImage.js +0 -52
  51. package/src/Custom/CReport.js +0 -569
  52. package/src/Custom/CScrollView.js +0 -73
  53. package/src/Custom/CSignature.js +0 -112
  54. package/src/Custom/CSliderMenu.js +0 -339
  55. package/src/Custom/CSupplierCard.js +0 -99
  56. package/src/Custom/CTemplateCard.js +0 -438
  57. package/src/Custom/CTokenAllocation.js +0 -1402
  58. package/src/Custom/CTokenListOverlay.js +0 -122
  59. package/src/Custom/CWardStatus.js +0 -444
  60. package/src/Custom/Charts/CBarChart.js +0 -218
  61. package/src/Custom/Charts/CDashBoardList.js +0 -133
  62. package/src/Custom/Charts/CDashBoardTable.js +0 -172
  63. package/src/Custom/Charts/CLineChart.js +0 -193
  64. package/src/Custom/Charts/CPieChart.js +0 -186
  65. package/src/Custom/Loader.js +0 -182
  66. package/src/Custom/OUserView.js +0 -1121
  67. package/src/Custom/PreviewDosage.js +0 -115
  68. package/src/Custom/SearchLoader.js +0 -32
  69. package/src/Custom/TableComponent/CActivityTable.js +0 -707
  70. package/src/Custom/TableComponent/CMoreButtonTable.js +0 -197
  71. package/src/Custom/TableComponent/CTable.js +0 -185
  72. package/src/Custom/TableComponent/CTextBody.js +0 -40
  73. package/src/Custom/TableComponent/CTextHeader.js +0 -17
  74. package/src/Custom/TableComponent/PreviewPrescriptionNew.js +0 -1011
  75. package/src/Custom/TableComponent/SDropdownTable.js +0 -491
  76. package/src/Custom/TableComponent/TagTable.js +0 -1200
  77. package/src/CustomComponents/CAddColumn.js +0 -140
  78. package/src/CustomComponents/CAssessmentDelete.js +0 -307
  79. package/src/CustomComponents/CAwesomeButton.js +0 -83
  80. package/src/CustomComponents/CAwesomeMoreButton.js +0 -54
  81. package/src/CustomComponents/CBackHandler.js +0 -273
  82. package/src/CustomComponents/CCalendar.js +0 -243
  83. package/src/CustomComponents/CCommentOverlay.js +0 -202
  84. package/src/CustomComponents/CComments.js +0 -162
  85. package/src/CustomComponents/CContainerView.js +0 -24
  86. package/src/CustomComponents/CCustomTextInput.js +0 -336
  87. package/src/CustomComponents/CDetailView.js +0 -40
  88. package/src/CustomComponents/CDropDownList.js +0 -153
  89. package/src/CustomComponents/CDropdownSelect.js +0 -555
  90. package/src/CustomComponents/CFooterView.js +0 -42
  91. package/src/CustomComponents/CImagePickerSave.js +0 -316
  92. package/src/CustomComponents/CModalOverlay.js +0 -91
  93. package/src/CustomComponents/CNetworkStatus.js +0 -327
  94. package/src/CustomComponents/CNotesInstructions.js +0 -1000
  95. package/src/CustomComponents/COverlay.js +0 -81
  96. package/src/CustomComponents/CRemarks.js +0 -176
  97. package/src/CustomComponents/CRowAdd.js +0 -143
  98. package/src/CustomComponents/CSummaryDropDown.js +0 -327
  99. package/src/CustomComponents/CText.js +0 -9
  100. package/src/CustomComponents/CVectorIcon.js +0 -34
  101. package/src/CustomComponents/HtmlContentViewer.js +0 -65
  102. package/src/CustomComponents/PdfContentViewer.js +0 -90
  103. package/src/CustomComponents/SDropDownDosage.js +0 -1087
  104. package/src/CustomComponents/SwipableProductCard.js +0 -246
  105. package/src/CustomComponents/SwipableProductImageCard.js +0 -254
  106. package/src/CustomComponents/WorkOrderDetails.js +0 -1216
  107. package/src/CustomComponents/WorkOrderDetailsPage.js +0 -1213
  108. package/src/HOC/ConfirmOverlay.js +0 -192
  109. package/src/HOC/HHeading.js +0 -70
  110. package/src/HOC/HMoreButton.js +0 -88
  111. package/src/HOC/HNatureHeading.js +0 -402
  112. package/src/HOC/HOCIcons.js +0 -80
  113. package/src/HOC/HOverlayCentered.js +0 -140
  114. package/src/HOC/HShadowButton.js +0 -45
  115. package/src/HOC/HShadowCountButton.js +0 -82
  116. package/src/HOC/OptionOverlay.js +0 -48
  117. package/src/Json/Chart.json +0 -818
  118. package/src/Json/Consultation.json +0 -622
  119. package/src/Json/CreditBill.json +0 -490
  120. package/src/Json/Dropdown.json +0 -216
  121. package/src/Json/DropdownConsultation.json +0 -228
  122. package/src/Json/DynamicReports.json +0 -623
  123. package/src/Json/Footer.json +0 -79
  124. package/src/Media/AudioScreen.js +0 -342
  125. package/src/Media/BarcodeScan.js +0 -145
  126. package/src/Media/CAudioPlay.js +0 -228
  127. package/src/Media/CCaptureImageWithoutEdit.js +0 -330
  128. package/src/Media/CImageGallery.js +0 -289
  129. package/src/Media/CImageZoom.js +0 -82
  130. package/src/Media/CSingleImage.js +0 -391
  131. package/src/Media/CSketchCanvas.js +0 -76
  132. package/src/Media/CVideoPlay.js +0 -31
  133. package/src/Media/DocumentScreen.js +0 -362
  134. package/src/Media/DrawingScreen.js +0 -578
  135. package/src/Media/ImageScreen.js +0 -309
  136. package/src/Media/RecordAudio.js +0 -250
  137. package/src/Media/RecordVideo.js +0 -223
  138. package/src/Media/VideoScreen.js +0 -378
  139. package/src/Navigation/PageNavigation.js +0 -224
  140. package/src/Navigation/useFocusEffect.js +0 -2
  141. package/src/Navigation/useFocusEffect.native.js +0 -1
  142. package/src/Navigation/useFocusEffect.web.js +0 -1
  143. package/src/Navigation/useIsFocused.js +0 -1
  144. package/src/Navigation/useIsFocused.native.js +0 -1
  145. package/src/Navigation/useIsFocused.web.js +0 -1
  146. package/src/Navigation/useNavigation.js +0 -2
  147. package/src/Navigation/useNavigation.native.js +0 -1
  148. package/src/Navigation/useNavigation.web.js +0 -1
  149. package/src/Screens/CMedications.js +0 -528
  150. package/src/Screens/CWebViewGallery.js +0 -203
  151. package/src/Screens/ChartScan.js +0 -279
  152. package/src/Screens/ChartScreenNew.js +0 -1579
  153. package/src/Screens/Consultation.js +0 -1500
  154. package/src/Screens/Dashboard.js +0 -778
  155. package/src/Screens/FileExplorer.js +0 -288
  156. package/src/Screens/Footer.js +0 -340
  157. package/src/Screens/ForgotPassword.js +0 -288
  158. package/src/Screens/HeaderBlock.js +0 -353
  159. package/src/Screens/Login.js +0 -328
  160. package/src/Screens/Notification.js +0 -149
  161. package/src/Screens/OcrScreen.js +0 -20
  162. package/src/Screens/PdfPreview.js +0 -507
  163. package/src/Screens/RegistrationDetails.js +0 -467
  164. package/src/Screens/SearchScreen.js +0 -582
  165. package/src/Screens/Splash.js +0 -788
  166. package/src/Screens/SwipeLeftView.js +0 -1867
  167. package/src/StaticComponents/SAlphabet.js +0 -47
  168. package/src/StaticComponents/SCheckBox.js +0 -42
  169. package/src/StaticComponents/SDatePicker.js +0 -208
  170. package/src/StaticComponents/SDatePickerLabel.js +0 -253
  171. package/src/StaticComponents/SDatePickerNew.js +0 -258
  172. package/src/StaticComponents/SDateTimePickerNew.js +0 -381
  173. package/src/StaticComponents/SDropDownGenerate.js +0 -450
  174. package/src/StaticComponents/SDropDownHoc.js +0 -636
  175. package/src/StaticComponents/SDropDownIcon.js +0 -500
  176. package/src/StaticComponents/SMenuBox.js +0 -131
  177. package/src/StaticComponents/SOverlay.js +0 -177
  178. package/src/StaticComponents/SOverlayTextInput.js +0 -109
  179. package/src/StaticComponents/SSearch.js +0 -438
  180. package/src/StaticComponents/SSearchBar.js +0 -53
  181. package/src/StaticComponents/SSpeedDial.js +0 -303
  182. package/src/StaticComponents/STextInput.js +0 -289
  183. package/src/StaticComponents/STextInputProps.js +0 -36
  184. package/src/StaticComponents/STimePicker.js +0 -171
  185. package/src/StaticComponents/STimingDropDownNew.js +0 -1585
  186. package/src/StaticComponents/STimingSwitch.js +0 -34
  187. package/src/layout/CContainerView.js +0 -21
  188. package/src/layout/CDetailView.js +0 -81
  189. package/src/layout/HeaderBlock.js +0 -353
  190. package/src/layout/INVLoginLayout.js +0 -657
  191. package/src/layout/Loader.js +0 -176
@@ -1,309 +0,0 @@
1
- import React, { useContext, useEffect, useState } from 'react';
2
- import {
3
- StyleSheet,
4
- FlatList,
5
- Dimensions,
6
- Text,
7
- View,
8
- TouchableOpacity,
9
- ActivityIndicator,
10
- PermissionsAndroid,
11
- RefreshControl,
12
- Platform,
13
- Image,
14
- } from 'react-native';
15
- import Fontisto from 'react-native-vector-icons/Fontisto';
16
- import CImageZoom from '../Media/CImageZoom';
17
- import AntDesign from 'react-native-vector-icons/AntDesign';
18
- import { APIURL, imageURLHIS } from '../../../../../src/Common/apiConstants';
19
- import DocumentPicker from 'react-native-document-picker';
20
- import { normalize } from '../CommonStyle/componentStyle';
21
- import { useNavigation } from '../Navigation/useNavigation';
22
-
23
- import { notifyMessage } from '../CommonStyle/ComponentFunctions';
24
- import PhotoEditor from 'react-native-photo-editor';
25
- import ReactNativeBlobUtil from 'react-native-blob-util';
26
- import { Global } from '../../../../../src/Common/Global';
27
- import NetworkServiceCall from '../Common/NetworkServiceCall';
28
- import SSpeedDial from '../StaticComponents/SSpeedDial';
29
-
30
- /*---------------------------------------------------------------------------------------*/
31
- function ImageScreen(props) {
32
- const navigation = useNavigation();
33
- const windowWidth = Dimensions.get('window').width;
34
- const windowHeight = Dimensions.get('window').height;
35
-
36
- const [data, setData] = useState(props.data?.savedimages || []);
37
- const [isImageShow, setImageShow] = useState(false);
38
- const [mediaUrlLink, setMediaUrlLink] = useState(false);
39
- const [refreshCount, setrefreshCount] = useState(1);
40
- const [pulltorefresh, setPullToRefresh] = useState(false);
41
- const [deleteImage, setDeleteImage] = useState(false);
42
- const [loading, setLoading] = useState(false);
43
-
44
- useEffect(() => {
45
- props.setData(data);
46
- }, [data]);
47
-
48
- /*---------------------------------------------------------------------------------------*/
49
- function deleteSelectedImage() {
50
- const updated = data.filter(item => !item.deletestatus);
51
- setData(updated);
52
- props.editStatus(1);
53
- setDeleteImage(false);
54
- setrefreshCount(refreshCount + 1);
55
- }
56
-
57
- function changeStatus(renderdata) {
58
- renderdata.item.deletestatus = !renderdata.item.deletestatus;
59
- setrefreshCount(refreshCount + 1);
60
- }
61
-
62
- function renderImage(renderdata) {
63
- const image = imageURLHIS + renderdata.item;
64
-
65
- return (
66
- <View>
67
- <TouchableOpacity
68
- style={styles.imageBox(windowHeight, windowWidth)}
69
- onPress={() =>
70
- navigation.navigate('CImageGallery', {
71
- savedimages: data,
72
- index: renderdata.index,
73
- })
74
- }
75
- onLongPress={() => setDeleteImage(true)}
76
- >
77
- <Image
78
- style={styles.fastImage}
79
- source={{
80
- uri:
81
- renderdata.item && renderdata.item !== null
82
- ? image
83
- : 'https://icon-library.com/images/no-image-icon/no-image-icon-0.jpg',
84
- headers: { Authorization: `Bearer ${Global.JWTToken}` },
85
- priority: FastImage.priority.high,
86
- cache: FastImage.cacheControl.web,
87
- }}
88
- />
89
- </TouchableOpacity>
90
-
91
- {isImageShow && (
92
- <CImageZoom
93
- image={mediaUrlLink}
94
- navigation={navigation}
95
- visibility={val => (val ? setImageShow(val) : null)}
96
- mediaupload={Media_Upload}
97
- />
98
- )}
99
-
100
- {deleteImage && (
101
- <TouchableOpacity onPress={() => changeStatus(renderdata)}>
102
- <View style={styles.checkboxContainer}>
103
- <Fontisto
104
- name={!renderdata.item.deletestatus ? 'checkbox-passive' : 'checkbox-active'}
105
- size={25}
106
- color={!renderdata.item.deletestatus ? 'lightgrey' : 'blue'}
107
- />
108
- </View>
109
- </TouchableOpacity>
110
- )}
111
- </View>
112
- );
113
- }
114
-
115
- /*---------------------------------------------------------------------------------------*/
116
- const getResolvedPath = async (uri, filen) => {
117
- const fileBase64 = await ReactNativeBlobUtil.fs.readFile(uri, 'base64');
118
- const relativePath = ReactNativeBlobUtil.fs.dirs.CacheDir;
119
- const path = `${relativePath}/${filen}`;
120
- await ReactNativeBlobUtil.fs.writeFile(path, fileBase64, 'base64');
121
- return { relativePath, fileName: filen, path };
122
- };
123
-
124
- /*---------------------------------------------------------------------------------------*/
125
- const firebasebrowse = async () => {
126
- try {
127
- const fileDetails = await DocumentPicker.pick({
128
- type: [DocumentPicker.types.images],
129
- });
130
-
131
- const picked = fileDetails[0];
132
- const extension = picked.name.split('.').pop().toLowerCase();
133
- const mimeType =
134
- picked.type ||
135
- (extension === 'png' ? 'image/png' : 'image/jpeg');
136
-
137
- const { path } = await getResolvedPath(picked.uri, picked.name);
138
-
139
- const dataset = {
140
- fileid: data.length + 1,
141
- uri: 'file://' + path,
142
- filename: picked.name,
143
- filetype: mimeType,
144
- uritype: false,
145
- };
146
-
147
- PhotoEditor.Edit({
148
- path: path,
149
- hiddenControls: ['sticker', 'save'],
150
- onDone: () => Media_Upload(dataset),
151
- });
152
- } catch (error) {
153
- notifyMessage(
154
- DocumentPicker.isCancel(error) ? 'Canceled' : 'Unknown Error: ' + JSON.stringify(error),
155
- 2
156
- );
157
- }
158
- };
159
-
160
- /*---------------------------------------------------------------------------------------*/
161
- async function Media_Upload(image) {
162
- setLoading(true);
163
-
164
- const dataset2 = {
165
- fileid: data.length + 1,
166
- filename: image.filename,
167
- filetype: image.filetype,
168
- uri: image.uri,
169
- uritype: false,
170
- };
171
-
172
- if (!dataset2.uritype && dataset2.uri) {
173
- const formData = new FormData();
174
- formData.append('file', {
175
- uri: dataset2.uri,
176
- type: dataset2.filetype,
177
- name: dataset2.filename,
178
- });
179
-
180
- try {
181
- const responsedata = await NetworkServiceCall(
182
- 'multiform',
183
- APIURL + 'invfile/fileupload/emr/image',
184
- formData
185
- );
186
-
187
- if (responsedata.httpstatus === 200) {
188
- dataset2.filename = responsedata.data.fileuri;
189
-
190
- setData(prev => [...prev, dataset2.filename]);
191
- props.editStatus(1);
192
- props.data.usertype =
193
- Global.PatientDetails?.usertype ?? 'Z';
194
- props.data.suuser = Global.userData?.suuser ?? 0;
195
- }
196
- } catch (error) {
197
- console.log('Upload error:', error);
198
- } finally {
199
- setLoading(false);
200
- }
201
- }
202
- }
203
-
204
- /*---------------------------------------------------------------------------------------*/
205
- function CaptureImageWithoutEdit() {
206
- navigation.navigate('CCaptureImageWithoutEdit', { onSelect: Media_Upload });
207
- }
208
-
209
- /*---------------------------------------------------------------------------------------*/
210
- return (
211
- <View style={{ flex: 1 }}>
212
- <View style={styles.itemContainer}>
213
- {deleteImage && (
214
- <TouchableOpacity
215
- style={{ alignItems: 'center', padding: 10 }}
216
- onPress={deleteSelectedImage}
217
- >
218
- <AntDesign name="delete" size={30} color={'red'} />
219
- </TouchableOpacity>
220
- )}
221
-
222
- <FlatList
223
- data={data}
224
- contentContainerStyle={{ alignItems: 'center', marginTop: 10 }}
225
- renderItem={renderImage}
226
- keyExtractor={(item, index) => index.toString()}
227
- numColumns={3}
228
- removeClippedSubviews={true}
229
- initialNumToRender={50}
230
- maxToRenderPerBatch={10}
231
- refreshControl={
232
- <RefreshControl
233
- refreshing={pulltorefresh}
234
- size={'large'}
235
- tintColor={'blue'}
236
- colors={['red', 'green', 'cyan', 'black']}
237
- progressBackgroundColor={'white'}
238
- onRefresh={() => setrefreshCount(refreshCount + 1)}
239
- />
240
- }
241
- />
242
-
243
- <View style={{ alignSelf: 'center' }}>
244
- <Text style={{ fontSize: normalize(16) }}>
245
- {data?.length > 0 ? `${data.length} IMAGE(S)` : null}
246
- </Text>
247
- </View>
248
-
249
- {loading && (
250
- <View style={styles.loadingBox}>
251
- <ActivityIndicator size="large" color="#0000ff" />
252
- </View>
253
- )}
254
-
255
- <SSpeedDial
256
- buttons={[
257
- { functionid: 1, color: 'darkblue', iconname: 'add', title: 'Browse' },
258
- { functionid: 2, color: 'darkblue', iconname: 'camera', title: 'Capture & edit' },
259
- ]}
260
- callBack={val => (val ? getFunctions(val) : null)}
261
- />
262
- </View>
263
- </View>
264
- );
265
-
266
- /*---------------------------------------------------------------------------------------*/
267
- function getFunctions(key) {
268
- switch (key) {
269
- case 1:
270
- firebasebrowse();
271
- break;
272
- case 2:
273
- CaptureImageWithoutEdit();
274
- break;
275
- }
276
- }
277
- }
278
-
279
- /*---------------------------------------------------------------------------------------*/
280
- const styles = StyleSheet.create({
281
- itemContainer: {
282
- flex: 1,
283
- backgroundColor: 'transparent',
284
- },
285
- imageBox: (windowHeight, windowWidth) => ({
286
- height: windowHeight * 0.15,
287
- width: windowWidth * 0.3,
288
- margin: 5,
289
- backgroundColor: '#e1e4e8',
290
- borderRadius: 5,
291
- }),
292
- fastImage: {
293
- width: '100%',
294
- height: '100%',
295
- borderRadius: normalize(10),
296
- },
297
- checkboxContainer: {
298
- justifyContent: 'center',
299
- alignItems: 'center',
300
- },
301
- loadingBox: {
302
- flex: 1,
303
- backgroundColor: '#fff',
304
- alignItems: 'center',
305
- padding: 10,
306
- },
307
- });
308
- /*---------------------------------------------------------------------------------------*/
309
- export default ImageScreen;
@@ -1,250 +0,0 @@
1
-
2
- import React from 'react';
3
- import {
4
- AppRegistry,
5
- StyleSheet,
6
- Text,
7
- TouchableOpacity,
8
- View,
9
- ActivityIndicator,
10
- Dimensions,
11
- KeyboardAvoidingView,
12
- TouchableHighlight,
13
- Image, Platform, PermissionsAndroid,
14
- } from 'react-native';
15
- // import AudioRecorderPlayer from 'react-native-audio-recorder-player';
16
- import Ionicons from 'react-native-vector-icons/Ionicons';
17
- // import { AudioRecorder, AudioUtils } from 'react-native-audio';
18
- import { Stopwatch, Timer } from 'react-native-stopwatch-timer';
19
- import FontAwesome from 'react-native-vector-icons/FontAwesome';
20
- // const audioRecorderPlayer = new AudioRecorderPlayer();
21
- export default class RecordAudio extends React.Component {
22
- constructor(props) {
23
- super(props);
24
- this.state = {
25
- recordSecs: null,
26
- recordTime: null,
27
- currentPositionSec: null,
28
- currentDurationSec: null,
29
- playTime: null,
30
- duration: null,//startAudio: false,playAudio:false,
31
-
32
- messages: [],
33
- startAudio: false,
34
- hasPermission: false,
35
- audioPath: `${
36
- AudioUtils.DocumentDirectoryPath
37
- }/${this.messageIdGenerator()}test.aac`,
38
- playAudio: false,
39
- fetchChats: false,
40
- audioFile: '',
41
- AudFileName: null,
42
- audioSettings: {
43
- SampleRate: 22050,
44
- Channels: 1,
45
- AudioQuality: 'Low',
46
- AudioEncoding: 'aac',
47
- MeteringEnabled: true,
48
- IncludeBase64: true,
49
- AudioEncodingBitRate: 32000,
50
- },
51
-
52
- stopwatchStart: false,
53
- stopwatchReset: false,
54
- };
55
- this.toggleStopwatch = this.toggleStopwatch.bind(this);
56
- this.resetStopwatch = this.resetStopwatch.bind(this);
57
- }
58
- componentWillMount() {
59
-
60
- }
61
- componentDidMount() {
62
- this.checkPermission().then(async hasPermission => {
63
- this.setState({ hasPermission });
64
- if (!hasPermission) {return;}
65
- await AudioRecorder.prepareRecordingAtPath(
66
- this.state.audioPath,
67
- this.state.audioSettings
68
- );
69
- AudioRecorder.onProgress = data => {
70
-
71
- };
72
- AudioRecorder.onFinished = data => {
73
- let fileName = data.audioFileURL.substr(data.audioFileURL.lastIndexOf('/') + 1);
74
- this.props.navigation.goBack();
75
- this.props.route.params.onSelect({
76
- // uri: data.audioFileURL,
77
- uri: data.audioFileURL,
78
- filename: fileName,
79
- type: 'audio/mpeg',
80
- });
81
- };
82
- });
83
- }
84
- componentWillUnmount() {
85
- this.setState({
86
- messages: [],
87
- });
88
- }
89
- checkPermission() {
90
- if (Platform.OS !== 'android') {
91
- return Promise.resolve(true);
92
- }
93
- const rationale = {
94
- title: 'Microphone Permission',
95
- message:
96
- 'AudioExample needs access to your microphone so you can record audio.',
97
- };
98
- return PermissionsAndroid.request(
99
- PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
100
- rationale
101
- ).then(result => {
102
-
103
- return result === true || result === PermissionsAndroid.RESULTS.GRANTED;
104
- });
105
- }
106
-
107
-
108
-
109
- handleAvatarPress = props => {
110
- // add navigation to user's profile
111
- };
112
- handleAudio = async () => {
113
- this.setState({ stopwatchStart: !this.state.stopwatchStart, stopwatchReset: false });
114
- const { user } = this.props;
115
- if (!this.state.startAudio) {
116
- this.setState({
117
- startAudio: true,
118
- });
119
- await AudioRecorder.startRecording();
120
- } else {
121
- this.setState({ startAudio: false });
122
- await AudioRecorder.stopRecording();
123
- const { audioPath } = this.state;
124
- const fileName = `${this.messageIdGenerator()}.aac`;
125
- const file = {
126
- uri: audioPath,// Platform.OS === "ios" ? audioPath : `file://${audioPath}`,
127
- name: fileName,
128
- type: 'audio/aac',
129
- };
130
- this.setState({ audioFile: file.uri, AudFileName: file.name });
131
- }
132
- };
133
- messageIdGenerator() {
134
- // generates uuid.
135
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
136
- let r = (Math.random() * 16) | 0,
137
- v = c == 'x' ? r : (r & 0x3) | 0x8;
138
- return v.toString(16);
139
- });
140
- }
141
-
142
- renderAndroidMicrophone() {
143
- if (Platform.OS === 'android') {
144
- return (
145
- <Ionicons
146
- name="ios-mic"
147
- size={35}
148
- hitSlop={{ top: 20, bottom: 20, left: 50, right: 50 }}
149
- color={this.state.startAudio ? 'red' : 'black'}
150
- style={{
151
- bottom: 50,
152
- right: Dimensions.get('window').width / 2,
153
- position: 'absolute',
154
- shadowColor: '#000',
155
- shadowOffset: { width: 0, height: 0 },
156
- shadowOpacity: 0.5,
157
- zIndex: 2,
158
- backgroundColor: 'transparent',
159
- }}
160
- onPress={this.handleAudio}
161
- />
162
- );
163
- }
164
- }
165
- renderLoading() {
166
- if (!this.state.messages.length && !this.state.fetchChats) {
167
- return (
168
- <View style={{ marginTop: 100 }}>
169
- {/* <ActivityIndicator color="black" animating size="large" /> */}
170
- </View>
171
- );
172
- }
173
- }
174
- toggleStopwatch() {
175
- this.setState({ stopwatchStart: !this.state.stopwatchStart, stopwatchReset: false });
176
- }
177
-
178
- resetStopwatch() {
179
- this.setState({ stopwatchStart: false, stopwatchReset: true });
180
- }
181
-
182
- render() {
183
- return (
184
- <TouchableOpacity style={layoutstyles.main_container}
185
- onPress={() => this.props.navigation.goBack()}
186
- >
187
- <TouchableOpacity style={layoutstyles.child_container}>
188
- {this.state.stopwatchStart ?
189
- <View style={layoutstyles.stop_watch_container}>
190
- <Stopwatch laps msecs start={this.state.stopwatchStart}
191
- reset={this.state.stopwatchReset}
192
- options={options}
193
- />
194
- </View>
195
- : null
196
- }
197
- <View style={layoutstyles.start_or_stop_container}>
198
- <TouchableHighlight underlayColor={'transparent'} onPress={this.handleAudio}>
199
- {!this.state.stopwatchStart ?
200
- <View style={layoutstyles.start_or_stop_icon}>
201
- <FontAwesome name="circle" size={70} color={'red'} />
202
- <Text>START</Text>
203
- </View>
204
- :
205
- <View style={layoutstyles.start_or_stop_icon}>
206
- <FontAwesome name="stop" size={60} color={'black'} />
207
- <Text>STOP</Text>
208
- </View>
209
- }
210
- </TouchableHighlight>
211
- </View>
212
- </TouchableOpacity>
213
- </TouchableOpacity>
214
- );
215
- }
216
- }
217
- const options = {
218
- text: {
219
- fontSize: 40,
220
- color: '#000',
221
- },
222
- };
223
- const layoutstyles = StyleSheet.create({
224
- main_container: {
225
- flex: 1,
226
- backgroundColor: 'rgba(0,0,0,0.50)',
227
- justifyContent: 'center', alignItems: 'center',
228
- },
229
- stop_watch_container: {
230
- flex: 2,
231
- width: '100%',
232
- height: 200,
233
- justifyContent: 'center',
234
- alignItems: 'center',
235
- },
236
-
237
- child_container: {
238
- flex: 0.25,// 0.3
239
- backgroundColor: '#fff', width: '100%',
240
- borderRadius: 7, borderWidth: 0.5, borderColor: 'black',
241
- },
242
- start_or_stop_container: {
243
- flex: 3, width: '100%', height: 200,
244
- justifyContent: 'center', alignItems: 'center',
245
- },
246
- start_or_stop_icon: {
247
- justifyContent: 'center',
248
- alignItems: 'center',
249
- },
250
- });