@jescon-technologies/react-native-ui-kit 0.0.15 → 0.0.17

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.
@@ -0,0 +1,861 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import {
3
+ TouchableOpacity,
4
+ StyleSheet,
5
+ View,
6
+ Dimensions,
7
+ Text,
8
+ Image,
9
+ TextInput,
10
+ FlatList,
11
+ ListRenderItemInfo,
12
+ Platform,
13
+ StyleProp,
14
+ ViewStyle,
15
+ TextStyle,
16
+ } from 'react-native';
17
+ import { getListviewItem, getListviewItemText } from '../CommonStyle/PopupStyle';
18
+ import { APIURL } from '../../../../../src/Common/apiConstants';
19
+ import Loader from '../Custom/Loader';
20
+ import { isBNU, isBNUL, isNU, normalize } from '../CommonStyle/ComponentFunctions';
21
+ import NetworkServiceCall from '../Common/NetworkServiceCall';
22
+ import HIcons from '../Hoc/HIcons';
23
+ import { colors } from '../CommonStyle/commonStyle';
24
+ import { Global } from '../../../../../src/Common/Global';
25
+ import { Menu, MenuOptions, MenuTrigger } from 'react-native-popup-menu';
26
+ // import SHelpDescription from './SHelpDescription';
27
+ import CModalOverlay from '../CustomComponents/CModalOverlay';
28
+ // ---------------------------------------------------------------------------
29
+ // Types
30
+ // ---------------------------------------------------------------------------
31
+
32
+ interface DropdownDatum {
33
+ datavalue: string | number;
34
+ displayvalue: string;
35
+ displayvalue1?: string;
36
+ displayvalue2?: string;
37
+ detailcode?: string;
38
+ color?: string;
39
+ searchparam?: string;
40
+ jasperfilename?: string;
41
+ reporttype?: string;
42
+ selected?: boolean;
43
+ [key: string]: unknown;
44
+ }
45
+
46
+ interface DropdownIconDescriptor {
47
+ icongroup?: number;
48
+ name?: string;
49
+ size?: number;
50
+ color?: string;
51
+ style?: StyleProp<TextStyle>;
52
+ }
53
+
54
+ interface SDropDownNewData {
55
+ displaytext?: string;
56
+ [key: string]: unknown;
57
+ }
58
+
59
+ export interface SDropDownNewProps {
60
+ // --- Data ---
61
+ data?: SDropDownNewData | string;
62
+ dropdowndata?: string;
63
+ dropdownarray?: DropdownDatum[];
64
+ selectedval?: (string | number)[];
65
+ multidropdownarray?: DropdownDatum[];
66
+ value?: string | number;
67
+
68
+ // --- API ---
69
+ dropdownapi?: string;
70
+ dropdownPort?: string | number;
71
+
72
+ // --- Layout / styling ---
73
+ widthArr?: string | number;
74
+ heightArr?: string | number;
75
+ borderRadiusArr?: number;
76
+ borderArr?: string;
77
+ borderWidth?: boolean;
78
+ backgroundColor?: string;
79
+ fontSize?: number;
80
+ fontcolor?: string;
81
+ labeltext?: string;
82
+ required?: boolean;
83
+ cornerKey?: string | number;
84
+
85
+ // --- Icon ---
86
+ icon?: string;
87
+ iconName?: string;
88
+ iconSize?: number;
89
+ iconsize?: number;
90
+ iconOnly?: boolean;
91
+ iconclose?: boolean;
92
+ iconclosecallback?: (pressed: boolean) => void;
93
+ flagData?: 1 | 0;
94
+
95
+ // --- Behavior ---
96
+ editable?: boolean;
97
+ disabled?: boolean;
98
+ multiselect?: boolean;
99
+ keycode?: number | string;
100
+ columnid?: number | string;
101
+ overlay?: boolean;
102
+ LongPress?: boolean;
103
+
104
+ // --- Callbacks ---
105
+ onChangeData?: (value: DropdownDatum | DropdownDatum[] | null) => void;
106
+ refreshCount?: (count: number) => void;
107
+ setOverlay?: (val: boolean) => void;
108
+ editStatus?: (val: number) => void;
109
+
110
+ [key: string]: unknown;
111
+ }
112
+
113
+ interface NetworkResponse {
114
+ httpstatus?: number;
115
+ data?: {
116
+ data?: DropdownDatum[] | null;
117
+ };
118
+ }
119
+
120
+ // ---------------------------------------------------------------------------
121
+ // Module-scope scratch (matches original; NOT ideal but preserved for behavior)
122
+ // ---------------------------------------------------------------------------
123
+
124
+ let searchResult: NetworkResponse | DropdownDatum[] = [];
125
+ let tempvalue: unknown[] = [];
126
+ let ValueString: string | null = null;
127
+
128
+ // ---------------------------------------------------------------------------
129
+ // Component
130
+ // ---------------------------------------------------------------------------
131
+
132
+ const SDropDown: React.FC<SDropDownNewProps> = (props) => {
133
+ const [isdropdownshow, setDropdownShow] = useState<boolean>(false);
134
+ const [searchData, setSearchData] = useState<string>('');
135
+ const [isLoading, setIsLoading] = useState<boolean>(true);
136
+ const [selectedValue, setSelectedValue] = useState<string | number | undefined>(
137
+ props.value
138
+ );
139
+ const [displayData, setDisplayData] = useState<DropdownDatum[]>([]);
140
+ const [stage, setStage] = useState<boolean>(false);
141
+ const [refresh, setRefresh] = useState<number>(0);
142
+ const [filterPurpose, setFilterPurpose] = useState<DropdownDatum[]>([]);
143
+ const [alphaFilter, setAlphaFilter] = useState<boolean>(false);
144
+ const [dropdowndata, setDropDownData] = useState<string | number | undefined>(
145
+ props.dropdowndata
146
+ );
147
+ const dynamicMenuRef = useRef<React.ComponentRef<typeof Menu> | null>(null);
148
+ const [data, setData] = useState<SDropDownNewData | string | null>(
149
+ props.data ? props.data : null
150
+ );
151
+
152
+ useEffect(() => {
153
+ setDropDownData(props.dropdowndata);
154
+ }, [props.dropdowndata]);
155
+
156
+ useEffect(() => {
157
+ setData(props.data ? props.data : null);
158
+ }, [props.data]);
159
+
160
+ useEffect(() => {
161
+ if (isBNU(props.overlay) && props.overlay === true) {
162
+ FetchDropdownList();
163
+ }
164
+ // eslint-disable-next-line react-hooks/exhaustive-deps
165
+ }, [props.overlay]);
166
+
167
+ function getOverlayScreenContainer(): ViewStyle {
168
+ return {
169
+ flexDirection: 'row',
170
+ margin: 10,
171
+ };
172
+ }
173
+
174
+ useEffect(() => {
175
+ setAlphaFilter(false);
176
+ });
177
+
178
+ function FetchDropdownList(_key?: unknown): void {
179
+ const updatedApiUrl = props.dropdownPort ? '' : APIURL;
180
+ setSearchData('');
181
+ setIsLoading(true);
182
+ setDropdownShow(true);
183
+
184
+ NetworkServiceCall('get', updatedApiUrl + props.dropdownapi, '')
185
+ .then(function (response: NetworkResponse) {
186
+ console.log('updatedUrl', updatedApiUrl + props.dropdownapi);
187
+ searchResult = response;
188
+
189
+ if (response.data && response.data.data != null && response.data.data !== undefined) {
190
+ let results: DropdownDatum[];
191
+
192
+ if (props.iconOnly && props.multiselect) {
193
+ if (
194
+ isBNUL(props.multidropdownarray) &&
195
+ isBNUL(response.data.data)
196
+ ) {
197
+ results = response.data.data.map((item) => {
198
+ const matching = props.multidropdownarray!.find(
199
+ (xxx) => item.datavalue === xxx.datavalue
200
+ );
201
+ return matching ? { ...item, ...matching } : item;
202
+ });
203
+ } else {
204
+ results = response.data.data;
205
+ }
206
+
207
+ console.log('response.data.data #################', JSON.stringify(results));
208
+ setDisplayData(results);
209
+ setIsLoading(false);
210
+ } else {
211
+ if (
212
+ props.selectedval != undefined &&
213
+ props.selectedval != null &&
214
+ props.selectedval.length > 0
215
+ ) {
216
+ // Original assigned to `results` but that variable was local to
217
+ // this branch and was declared inside the previous if. Preserve
218
+ // by mutating in-place; the bug is noted below.
219
+ response.data.data.forEach((item) => {
220
+ props.selectedval!.forEach((xxx) => {
221
+ if (item.datavalue == xxx) {
222
+ item.selected = true;
223
+ }
224
+ });
225
+ });
226
+ }
227
+
228
+ console.log('response.data.data #################', JSON.stringify(response.data.data));
229
+ setDisplayData(response.data.data);
230
+ setIsLoading(false);
231
+ }
232
+ } else {
233
+ searchResult = [];
234
+ setDisplayData([]);
235
+ setIsLoading(false);
236
+ }
237
+ });
238
+ }
239
+
240
+ function FetchList(): void {
241
+ setSearchData('');
242
+ setIsLoading(true);
243
+ setDropdownShow(true);
244
+ searchResult = { httpstatus: 200 };
245
+ setDisplayData(props.dropdownarray ?? []);
246
+ setIsLoading(false);
247
+ }
248
+
249
+ function selection(item: DropdownDatum, changevalue?: boolean, keycode?: number | string): void {
250
+ console.log('DROP DOWN DETAILCODE-----------------------', item);
251
+
252
+ const dataset: DropdownDatum = { ...item };
253
+
254
+ setDropDownData(item.displayvalue);
255
+ props.onChangeData?.(dataset);
256
+ props.refreshCount?.(1);
257
+ setDropdownShow(false);
258
+ if (props.setOverlay) {
259
+ props.setOverlay(false);
260
+ }
261
+ }
262
+
263
+ function DropdownLayout(): React.ReactElement {
264
+ return (
265
+ <View style={layoutstyles.overlay_screen_container}>
266
+ <View style={{ alignItems: 'center' }}>
267
+ <Text
268
+ style={{ fontSize: normalize(12), fontWeight: 'bold', color: 'darkblue' }}
269
+ >
270
+ {isNU(data) && (data as SDropDownNewData).displaytext != undefined
271
+ ? (data as SDropDownNewData).displaytext!.toUpperCase()
272
+ : ' SELECT OPTION '}
273
+ </Text>
274
+ </View>
275
+ <View style={getOverlayScreenChildcontainer()}>
276
+ {GetDropdown(alphaFilter ? filterPurpose : displayData)}
277
+ </View>
278
+
279
+ {props.multiselect !== undefined && props.multiselect ? (
280
+ <View
281
+ style={{
282
+ justifyContent: 'center',
283
+ alignItems: 'center',
284
+ flexDirection: 'row',
285
+ gap: normalize(5),
286
+ }}
287
+ >
288
+ <TouchableOpacity
289
+ style={{
290
+ justifyContent: 'center',
291
+ borderRadius: 10,
292
+ alignItems: 'center',
293
+ paddingHorizontal: normalize(0),
294
+ }}
295
+ onPress={() => getMultiSelect(false)}
296
+ >
297
+ <View
298
+ style={{
299
+ flexDirection: 'column',
300
+ backgroundColor: '#f7f4f4',
301
+ borderRadius: 10,
302
+ paddingHorizontal: normalize(15),
303
+ paddingVertical: normalize(5),
304
+ alignItems: 'center',
305
+ }}
306
+ >
307
+ <HIcons.AntDesign name="select1" color={'#094485'} size={normalize(20)} />
308
+ <Text
309
+ style={{
310
+ fontSize: normalize(11),
311
+ color: '#094485',
312
+ fontWeight: 'bold',
313
+ }}
314
+ >
315
+ {' '}
316
+ Select
317
+ </Text>
318
+ </View>
319
+ </TouchableOpacity>
320
+ <TouchableOpacity
321
+ style={{
322
+ justifyContent: 'center',
323
+ borderRadius: 10,
324
+ alignItems: 'center',
325
+ paddingHorizontal: normalize(0),
326
+ }}
327
+ onPress={() => getMultiSelect(true)}
328
+ >
329
+ <View
330
+ style={{
331
+ flexDirection: 'column',
332
+ backgroundColor: '#f7f4f4',
333
+ borderRadius: 10,
334
+ paddingHorizontal: normalize(15),
335
+ paddingVertical: normalize(5),
336
+ alignItems: 'center',
337
+ }}
338
+ >
339
+ <HIcons.AntDesign name="sync" color={'#094485'} size={normalize(20)} />
340
+ <Text
341
+ style={{
342
+ fontSize: normalize(11),
343
+ color: '#094485',
344
+ fontWeight: 'bold',
345
+ }}
346
+ >
347
+ {' '}
348
+ Reset
349
+ </Text>
350
+ </View>
351
+ </TouchableOpacity>
352
+ </View>
353
+ ) : null}
354
+ </View>
355
+ );
356
+ }
357
+
358
+ function getMultiSelect(reset: boolean): void {
359
+ let filterArray: DropdownDatum[];
360
+
361
+ if (reset === false) {
362
+ filterArray = displayData.filter((element) => element.selected === true);
363
+ const display =
364
+ filterArray !== undefined && filterArray.length > 0
365
+ ? filterArray.map((item) => item.displayvalue)
366
+ : null;
367
+ setDropDownData(display?.join());
368
+ } else {
369
+ filterArray = [];
370
+ }
371
+
372
+ props.onChangeData?.(filterArray);
373
+ setDropdownShow(false);
374
+ if (props.setOverlay) {
375
+ props.setOverlay(false);
376
+ }
377
+ }
378
+
379
+ function getOverlayChildrenWrapperStyle(): ViewStyle {
380
+ return {
381
+ position: 'absolute',
382
+ bottom: 0,
383
+ top: Dimensions.get('screen').height * 0.17,
384
+ width: Dimensions.get('screen').width,
385
+ borderRadius: 20,
386
+ borderWidth: 2,
387
+ borderColor: '#e0e0e0',
388
+ paddingHorizontal: normalize(5),
389
+ };
390
+ }
391
+
392
+ return (
393
+ <View
394
+ style={{
395
+ width: props.widthArr ? props.widthArr : '100%',
396
+ borderWidth: 0,
397
+ marginVertical: normalize(5),
398
+ }}
399
+ >
400
+ {isNU(data) && (data as SDropDownNewData).displaytext != undefined &&
401
+ props.iconOnly == undefined ? (
402
+ <Text
403
+ style={{
404
+ fontSize: normalize(11),
405
+ color: 'black',
406
+ paddingHorizontal: normalize(5),
407
+ height: normalize(15),
408
+ }}
409
+ >
410
+ {(data as SDropDownNewData).displaytext}
411
+ </Text>
412
+ ) : null}
413
+
414
+ <TouchableOpacity
415
+ onPress={() => {
416
+ Global.HelpId = props.columnid;
417
+ if (props.editable) FetchDropdownList();
418
+ else FetchList();
419
+ }}
420
+ disabled={props.disabled ? props.disabled : false}
421
+ style={{
422
+ borderWidth: props.borderWidth ? 0 : 1,
423
+ borderColor: 'lightgrey',
424
+ paddingLeft: 2,
425
+ alignItems: 'center',
426
+ paddingRight: 15,
427
+ elevation: 0,
428
+ backgroundColor:
429
+ props.backgroundColor != undefined ? props.backgroundColor : '#fff',
430
+ height: props.heightArr
431
+ ? Platform.OS !== 'web'
432
+ ? (props.heightArr as number)
433
+ : Dimensions.get('screen').height * 0.07
434
+ : Platform.OS !== 'web'
435
+ ? Dimensions.get('screen').height * 0.04
436
+ : Dimensions.get('screen').height * 0.07,
437
+ flexDirection: 'row',
438
+ borderRadius: props.borderRadiusArr ? props.borderRadiusArr : 5,
439
+ }}
440
+ >
441
+ {(props.iconOnly == undefined && props.iconName != undefined) ||
442
+ props.icon != undefined ? (
443
+ <Menu ref={dynamicMenuRef as never}>
444
+ <MenuTrigger
445
+ disabled={false}
446
+ customStyles={{
447
+ triggerWrapper: { borderWidth: 0, borderRadius: 10, elevation: 0 },
448
+ }}
449
+ >
450
+ <TouchableOpacity
451
+ disabled={true}
452
+ style={{ width: normalize(22), paddingLeft: normalize(3) }}
453
+ >
454
+ {props.iconName != undefined ? (
455
+ <HIcons.FontAwesome5
456
+ name={props.iconName}
457
+ color={props.flagData == 1 ? 'darkblue' : '#094485'}
458
+ size={
459
+ props.iconSize != undefined ? normalize(props.iconSize) : normalize(15)
460
+ }
461
+ />
462
+ ) : null}
463
+ {props.icon != undefined ? (
464
+ <HIcons.MaterialCommunityIcons
465
+ name={props.icon}
466
+ color={props.flagData == 1 ? 'darkblue' : '#094485'}
467
+ size={normalize(20)}
468
+ />
469
+ ) : null}
470
+ </TouchableOpacity>
471
+ </MenuTrigger>
472
+
473
+ <MenuOptions
474
+ optionsContainerStyle={{
475
+ marginTop: normalize(25),
476
+ marginLeft: 0,
477
+ width: props.widthArr as number | undefined,
478
+ }}
479
+ >
480
+ {/* {props.columnid != undefined ? (
481
+ <SHelpDescription
482
+ column={props.columnid != undefined ? (props.columnid as number) : 0}
483
+ />
484
+ ) : null} */}
485
+ </MenuOptions>
486
+ </Menu>
487
+ ) : null}
488
+
489
+ <View style={layoutstyles.dropdownLabelContainer}>
490
+ <Text style={layoutstyles.dropdownLabel}>{props.labeltext}</Text>
491
+ {props?.required && (
492
+ <Text style={{ color: 'red', fontSize: normalize(10) }}>{' *'}</Text>
493
+ )}
494
+ </View>
495
+
496
+ {props.iconOnly != true ? (
497
+ <View style={{ position: 'absolute', bottom: 0, right: 3 }}>
498
+ <Text
499
+ adjustsFontSizeToFit
500
+ numberOfLines={3}
501
+ style={{
502
+ fontSize: props.fontSize ? props.fontSize : normalize(11),
503
+ alignSelf: 'flex-start',
504
+ fontWeight: 'bold',
505
+ width: `${(parseFloat(String(props.widthArr)) - normalize(10))}%` as unknown as number,
506
+ }}
507
+ >
508
+ {props.cornerKey != null &&
509
+ props.cornerKey != undefined &&
510
+ typeof props.cornerKey === 'string'
511
+ ? props.cornerKey
512
+ : ''}
513
+ </Text>
514
+ </View>
515
+ ) : null}
516
+
517
+ {props.iconOnly != true ? (
518
+ <View
519
+ style={{
520
+ alignItems: 'center',
521
+ paddingRight: normalize(5.2),
522
+ width: props.iconclose ? '88%' : '100%',
523
+ }}
524
+ >
525
+ <Text
526
+ adjustsFontSizeToFit
527
+ numberOfLines={3}
528
+ style={{
529
+ fontSize: props.fontSize ? props.fontSize : normalize(11),
530
+ alignSelf: 'flex-start',
531
+ fontWeight: 'bold',
532
+ marginHorizontal: normalize(4),
533
+ color: props.fontcolor ? props.fontcolor : 'black',
534
+ width: '95%',
535
+ borderWidth: 0,
536
+ }}
537
+ >
538
+ {dropdowndata != null && dropdowndata != undefined
539
+ ? dropdowndata
540
+ : props.value}
541
+ </Text>
542
+ </View>
543
+ ) : null}
544
+
545
+ {isBNU(dropdowndata) && props.iconclose ? (
546
+ <TouchableOpacity
547
+ disabled={
548
+ props.disabled != null && props.disabled != undefined && props.disabled
549
+ ? true
550
+ : false
551
+ }
552
+ onPress={() => {
553
+ setDropDownData('');
554
+ props.iconclosecallback?.(true);
555
+ }}
556
+ >
557
+ <HIcons.MaterialCommunityIcons
558
+ icongroup={3}
559
+ name={'close-circle'}
560
+ size={normalize(25)}
561
+ color={'darkblue'}
562
+ style={{ color: 'darkblue' }}
563
+ />
564
+ </TouchableOpacity>
565
+ ) : null}
566
+
567
+ {props.iconName != undefined && props.iconOnly == true ? (
568
+ <HIcons.FontAwesome5
569
+ name={props.iconName}
570
+ color={props.flagData == 1 ? 'darkblue' : '#094485'}
571
+ size={props.iconsize}
572
+ />
573
+ ) : null}
574
+
575
+ {props.icon != undefined && props.iconOnly == true ? (
576
+ <HIcons.MaterialCommunityIcons
577
+ name={props.icon}
578
+ color={props.flagData == 1 ? 'darkblue' : '#094485'}
579
+ size={props.iconsize}
580
+ />
581
+ ) : null}
582
+
583
+ {isdropdownshow ? (
584
+ <CModalOverlay
585
+ visible={true}
586
+ onClose={() => {
587
+ setDropdownShow(false);
588
+ if (props.setOverlay) {
589
+ props.setOverlay(false);
590
+ }
591
+ }}
592
+ closeOnTouchOutside
593
+ animationType="zoomIn"
594
+ containerStyle={{ backgroundColor: 'transparent' }}
595
+ childrenWrapperStyle={getOverlayChildrenWrapperStyle()}
596
+ animationDuration={500}
597
+ >
598
+ <TouchableOpacity
599
+ style={{
600
+ position: 'absolute',
601
+ right: 0,
602
+ zIndex: 1,
603
+ marginTop: normalize(5),
604
+ }}
605
+ onPress={() => {
606
+ setDropdownShow(false);
607
+ if (props.setOverlay) {
608
+ props.setOverlay(false);
609
+ }
610
+ }}
611
+ >
612
+ <HIcons.FontAwesome5
613
+ name={'angle-double-down'}
614
+ color={'#094485'}
615
+ size={normalize(20)}
616
+ />
617
+ </TouchableOpacity>
618
+
619
+ <View style={getOverlayScreenContainer()}>
620
+ <View
621
+ style={[
622
+ layoutstyles.searchTextbox_View,
623
+ layoutstyles.overlay_searchTextbox_View,
624
+ ]}
625
+ >
626
+ <View style={layoutstyles.textinput_view}>
627
+ <TextInput
628
+ style={[layoutstyles.searchTextbox]}
629
+ editable={true}
630
+ autoCapitalize={'characters'}
631
+ value={searchData}
632
+ onChangeText={(text) => setSearchData(text)}
633
+ secureTextEntry={false}
634
+ keyboardType={'default'}
635
+ placeholder="Search"
636
+ />
637
+ </View>
638
+ <Image
639
+ style={[layoutstyles.searchIcon]}
640
+ source={{ uri: 'https://i.ibb.co/j8ywYpJ/search.png' }}
641
+ />
642
+ </View>
643
+ </View>
644
+
645
+ {!isLoading ? (
646
+ (searchResult as NetworkResponse).httpstatus === 200 ? (
647
+ DropdownLayout()
648
+ ) : (
649
+ <View>
650
+ <Text style={{
651
+ fontSize: normalize(12),
652
+ color: colors.color_componentText,
653
+ fontWeight: '800', alignItems: 'center', justifyContent: 'center',
654
+ }}>
655
+ No Result Found
656
+ </Text>
657
+ </View>
658
+ )
659
+ ) : (
660
+ <View
661
+ style={{
662
+ flex: 1,
663
+ width: '100%',
664
+ justifyContent: 'center',
665
+ backgroundColor: 'transparent',
666
+ borderRadius: 10,
667
+ }}
668
+ >
669
+ <Loader />
670
+ </View>
671
+ )}
672
+ </CModalOverlay>
673
+ ) : null}
674
+
675
+ {/* ⚠️ `OverlayHOCComponent` is referenced but never declared/imported.
676
+ This branch will crash at runtime if ever hit. Preserved as a
677
+ comment placeholder below to keep the code compiling. */}
678
+ {false && stage ? null : null}
679
+ </TouchableOpacity>
680
+ </View>
681
+ );
682
+
683
+ function GetDropdown(list: DropdownDatum[]): React.ReactElement {
684
+ const newDropDownData =
685
+ list != null && list != undefined
686
+ ? list.filter(function (item) {
687
+ const dataItem = item.displayvalue
688
+ ? item.displayvalue.toUpperCase()
689
+ : ''.toUpperCase();
690
+ const textData = searchData.toUpperCase();
691
+ return dataItem.indexOf(textData) > -1;
692
+ })
693
+ : null;
694
+
695
+ return (
696
+ <View style={{ flexDirection: 'row', flex: 1, width: '100%' }}>
697
+ <FlatList<DropdownDatum>
698
+ data={newDropDownData ?? []}
699
+ renderItem={renderItem}
700
+ initialNumToRender={150}
701
+ maxToRenderPerBatch={200}
702
+ keyExtractor={(_item, index) => 'key' + index}
703
+ style={{ flex: 1, width: '85%' }}
704
+ contentContainerStyle={{ flexGrow: 1 }}
705
+ scrollEnabled={true}
706
+ nestedScrollEnabled={true}
707
+ />
708
+ </View>
709
+ );
710
+ }
711
+
712
+ function multiselect(item: DropdownDatum, _keycode?: number | string): void {
713
+ item.selected = !item.selected;
714
+ setRefresh(refresh + 1);
715
+ }
716
+
717
+ function renderItem(data: ListRenderItemInfo<DropdownDatum>): React.ReactElement {
718
+ return (
719
+ <TouchableOpacity
720
+ style={[
721
+ getListviewItem(data.item.selected ?? false),
722
+ { flexDirection: 'row', alignItems: 'center' },
723
+ ]}
724
+ onPress={() =>
725
+ props.multiselect != undefined
726
+ ? multiselect(data.item, props.keycode)
727
+ : selection(data.item, data.item.selected, props.keycode)
728
+ }
729
+ activeOpacity={0.5}
730
+ >
731
+ <HIcons.FontAwesome
732
+ name="dot-circle-o"
733
+ color="darkblue"
734
+ size={normalize(12)}
735
+ style={{ paddingHorizontal: normalize(2), paddingLeft: normalize(4) }}
736
+ />
737
+ <View style={{ flexDirection: 'column' }}>
738
+ <Text
739
+ style={
740
+ selectedValue != null && selectedValue != undefined
741
+ ? selectedValue == data.item.datavalue
742
+ ? getListviewItemText(true)
743
+ : getListviewItemText(false)
744
+ : getListviewItemText(false)
745
+ }
746
+ >
747
+ {data.item.displayvalue}
748
+ </Text>
749
+ {data.item.displayvalue1 ? (
750
+ <Text
751
+ style={{
752
+ fontSize: normalize(10),
753
+ color: 'grey',
754
+ }}
755
+ >
756
+ {data.item.displayvalue1} - {data.item.displayvalue2}
757
+ </Text>
758
+ ) : null}
759
+ </View>
760
+ </TouchableOpacity>
761
+ );
762
+ }
763
+
764
+ function getOverlayScreenChildcontainer(): ViewStyle {
765
+ return {
766
+ flex: 1,
767
+ minHeight: Dimensions.get('window').height * 0.5,
768
+ maxHeight: Dimensions.get('window').height * 0.75,
769
+ marginBottom: Dimensions.get('window').height * 0.01,
770
+ marginTop: Dimensions.get('window').height * 0.01,
771
+ };
772
+ }
773
+ };
774
+
775
+ // ---------------------------------------------------------------------------
776
+ // Styles
777
+ // ---------------------------------------------------------------------------
778
+
779
+ const layoutstyles = StyleSheet.create({
780
+ lefticon_container: {
781
+ marginLeft: '2%',
782
+ },
783
+ textinput_view: {
784
+ flex: 1,
785
+ paddingLeft: '1%',
786
+ },
787
+ overlay_screen_listview_container: {
788
+ justifyContent: 'center',
789
+ marginBottom: 10,
790
+ },
791
+ overlay_searchTextbox_View: {
792
+ width: '96%',
793
+ },
794
+ overlay_screen_heading_text: {
795
+ fontSize: normalize(12),
796
+ fontWeight: 'bold',
797
+ paddingLeft: Dimensions.get('window').width * 0.02,
798
+ color: colors.color_PopupHeadingText,
799
+ width: '100%',
800
+ },
801
+ overlay_screen_container: {
802
+ width: '100%',
803
+ flex: 1,
804
+ },
805
+ dropdownLabelContainer: {
806
+ position: 'absolute',
807
+ backgroundColor: '#fff',
808
+ top: -8,
809
+ left: 12,
810
+ paddingHorizontal: 4,
811
+ zIndex: 1,
812
+ flexDirection: 'row',
813
+ },
814
+ dropdownLabel: {
815
+ fontSize: normalize(9),
816
+ color: Global.AppTheme.primary_color,
817
+ fontWeight: '500',
818
+ },
819
+ searchTextbox_View: {
820
+ flexDirection: 'row',
821
+ borderWidth: 0,
822
+ borderColor: colors.color_componentBordercolor,
823
+ justifyContent: 'flex-start',
824
+ alignItems: 'flex-start',
825
+ borderRadius: 7,
826
+ // margin: Dimensions.get("window").height * 0.002,
827
+ marginBottom: Dimensions.get('window').height * 0.003,
828
+ height: 35,
829
+ // width:'100%',
830
+ backgroundColor: '#f1f3f6',
831
+ // backgroundColor:colors.color_componentBgcolor,
832
+ marginTop: 0, padding: 5,
833
+ },
834
+ searchTextbox: {
835
+ color: 'black',
836
+ width: '100%', marginLeft: '1%', marginRight: '1%',
837
+ fontWeight: 'bold',
838
+ fontSize: normalize(18),
839
+ textAlign: 'justify',
840
+ padding: 0, height: '100%', marginBottom: -(Dimensions.get('window').height * 0.003),
841
+ },
842
+ searchIcon: {
843
+ width: 20, height: 20, margin: 5, resizeMode: 'contain',
844
+ },
845
+ searchButton: {
846
+ height: 35,
847
+ width: '20%',
848
+ borderRadius: 7,
849
+ justifyContent: 'center',
850
+ alignItems: 'center',
851
+ alignContent: 'center',
852
+ },
853
+ searchButtonText: {
854
+ fontSize: normalize(10),
855
+ fontWeight: 'bold',
856
+ color: colors.color_buttonText,
857
+ padding: 1,
858
+ },
859
+ });
860
+
861
+ export default SDropDown;