@@ -41,7 +41,10 @@ const NewCalendarScreen = () => {
41
41
const [ disableArrowRight , setDisableArrowRight ] = useState ( false ) ;
42
42
43
43
const toggleMinAndMax = useCallback ( ( ) => setMinAndMax ( ! minAndMax ) , [ minAndMax ] ) ;
44
- const toggleAllowSelectionOutOfRange = useCallback ( ( ) => setAllowSelectionOutOfRange ( ! allowSelectionOutOfRange ) , [ allowSelectionOutOfRange ] ) ;
44
+ const toggleAllowSelectionOutOfRange = useCallback (
45
+ ( ) => setAllowSelectionOutOfRange ( ! allowSelectionOutOfRange ) ,
46
+ [ allowSelectionOutOfRange ]
47
+ ) ;
45
48
const toggleEnableSwipeMonths = useCallback ( ( ) => setEnableSwipeMonths ( ! enableSwipeMonths ) , [ enableSwipeMonths ] ) ;
46
49
const toggleDisableMonthChange = useCallback ( ( ) => setDisableMonthChange ( ! disableMonthChange ) , [ disableMonthChange ] ) ;
47
50
const toggleShowWeekNumbers = useCallback ( ( ) => setShowWeekNumbers ( ! showWeekNumbers ) , [ showWeekNumbers ] ) ;
@@ -50,28 +53,40 @@ const NewCalendarScreen = () => {
50
53
const toggleHideDayNames = useCallback ( ( ) => setHideDayNames ( ! hideDayNames ) , [ hideDayNames ] ) ;
51
54
const toggleHideArrows = useCallback ( ( ) => setHideArrows ( ! hideArrows ) , [ hideArrows ] ) ;
52
55
const toggleDisabledByDefault = useCallback ( ( ) => setDisabledByDefault ( ! disabledByDefault ) , [ disabledByDefault ] ) ;
53
- const toggleDisableAllTouchEventsForDisabledDays = useCallback ( ( ) => setDisableAllTouchEventsForDisabledDays ( ! disableAllTouchEventsForDisabledDays ) , [ disableAllTouchEventsForDisabledDays ] ) ;
54
- const toggleDisableAllTouchEventsForInactiveDays = useCallback ( ( ) => setDisableAllTouchEventsForInactiveDays ( ! disableAllTouchEventsForInactiveDays ) , [ disableAllTouchEventsForInactiveDays ] ) ;
55
- const toggleDisplayLoadingIndicator = useCallback ( ( ) => setDisplayLoadingIndicator ( ! displayLoadingIndicator ) , [ displayLoadingIndicator ] ) ;
56
- const toggleDisabledDaysIndexes = useCallback ( ( ) => setDisabledDaysIndexes ( ! disabledDaysIndexes ) , [ disabledDaysIndexes ] ) ;
56
+ const toggleDisableAllTouchEventsForDisabledDays = useCallback (
57
+ ( ) => setDisableAllTouchEventsForDisabledDays ( ! disableAllTouchEventsForDisabledDays ) ,
58
+ [ disableAllTouchEventsForDisabledDays ]
59
+ ) ;
60
+ const toggleDisableAllTouchEventsForInactiveDays = useCallback (
61
+ ( ) => setDisableAllTouchEventsForInactiveDays ( ! disableAllTouchEventsForInactiveDays ) ,
62
+ [ disableAllTouchEventsForInactiveDays ]
63
+ ) ;
64
+ const toggleDisplayLoadingIndicator = useCallback (
65
+ ( ) => setDisplayLoadingIndicator ( ! displayLoadingIndicator ) ,
66
+ [ displayLoadingIndicator ]
67
+ ) ;
68
+ const toggleDisabledDaysIndexes = useCallback (
69
+ ( ) => setDisabledDaysIndexes ( ! disabledDaysIndexes ) ,
70
+ [ disabledDaysIndexes ]
71
+ ) ;
57
72
const toggleDayComponent = useCallback ( ( ) => setDayComponent ( ! dayComponent ) , [ dayComponent ] ) ;
58
73
const toggleCustomHeader = useCallback ( ( ) => setCustomHeader ( ! customHeader ) , [ customHeader ] ) ;
59
74
const toggleCustomHeaderTitle = useCallback ( ( ) => setCustomHeaderTitle ( ! customHeaderTitle ) , [ customHeaderTitle ] ) ;
60
75
const toggleRenderArrow = useCallback ( ( ) => setRenderArrow ( ! renderArrow ) , [ renderArrow ] ) ;
61
76
const toggleDisableArrowLeft = useCallback ( ( ) => setDisableArrowLeft ( ! disableArrowLeft ) , [ disableArrowLeft ] ) ;
62
77
const toggleDisableArrowRight = useCallback ( ( ) => setDisableArrowRight ( ! disableArrowRight ) , [ disableArrowRight ] ) ;
63
78
64
- const getDate = ( count ) => {
79
+ const getDate = count => {
65
80
const date = new Date ( INITIAL_DATE ) ;
66
81
const newDate = date . setDate ( date . getDate ( ) + count ) ;
67
82
return CalendarUtils . getCalendarDateString ( newDate ) ;
68
83
} ;
69
84
70
- const onDayPress = useCallback ( ( day ) => {
85
+ const onDayPress = useCallback ( day => {
71
86
setSelected ( day . dateString ) ;
72
87
} , [ ] ) ;
73
88
74
- const onDayLongPress = useCallback ( ( day ) => {
89
+ const onDayLongPress = useCallback ( day => {
75
90
Alert . alert ( `Date: ${ day . dateString } ` ) ;
76
91
} , [ ] ) ;
77
92
@@ -139,7 +154,14 @@ const NewCalendarScreen = () => {
139
154
140
155
const periodWithDotsMarks = useMemo ( ( ) => {
141
156
return {
142
- [ getDate ( - 3 ) ] : { marked : true , dotColor : 'white' , startingDay : true , endingDay : true , color : '#50cebb' , textColor : 'white' } ,
157
+ [ getDate ( - 3 ) ] : {
158
+ marked : true ,
159
+ dotColor : 'white' ,
160
+ startingDay : true ,
161
+ endingDay : true ,
162
+ color : '#50cebb' ,
163
+ textColor : 'white'
164
+ } ,
143
165
[ INITIAL_DATE ] : { marked : true , dotColor : '#50cebb' } ,
144
166
[ getDate ( 1 ) ] : { disabled : true , marked : true , dotColor : '#50cebb' } ,
145
167
[ getDate ( 2 ) ] : { startingDay : true , color : '#50cebb' , textColor : 'white' } ,
@@ -370,7 +392,7 @@ const NewCalendarScreen = () => {
370
392
371
393
const CustomHeader = React . forwardRef ( ( props , ref ) => {
372
394
customHeaderProps . current = props ;
373
-
395
+
374
396
return (
375
397
// @ts -expect-error
376
398
< View ref = { ref } { ...props } style = { styles . customHeader } >
@@ -420,27 +442,23 @@ const NewCalendarScreen = () => {
420
442
421
443
const CustomHeaderTitle = (
422
444
< TouchableOpacity style = { styles . customTitleContainer } onPress = { ( ) => console . warn ( 'Tapped!' ) } >
423
- < Text style = { styles . customTitle } > { selectedValue . getMonth ( ) + 1 } -{ selectedValue . getFullYear ( ) } </ Text >
445
+ < Text style = { styles . customTitle } >
446
+ { selectedValue . getMonth ( ) + 1 } -{ selectedValue . getFullYear ( ) }
447
+ </ Text >
424
448
</ TouchableOpacity >
425
449
) ;
426
450
427
451
/** Custom Arrow */
428
- const _renderArrow = useCallback ( ( direction ) => {
452
+ const _renderArrow = useCallback ( direction => {
429
453
const text = direction === 'left' ? '<<' : '>>' ;
430
- return (
431
- < Text > { text } </ Text >
432
- ) ;
454
+ return < Text > { text } </ Text > ;
433
455
} , [ ] ) ;
434
456
435
457
/** Props Switches */
436
458
const renderSwitch = ( label : string , state : any , toggleSwitch : any ) => {
437
459
return (
438
460
< View style = { styles . switchContainer } >
439
- < Switch
440
- value = { state }
441
- onValueChange = { toggleSwitch }
442
- trackColor = { { true : GREEN } }
443
- />
461
+ < Switch value = { state } onValueChange = { toggleSwitch } trackColor = { { true : GREEN } } />
444
462
< Text style = { [ styles . switchText , styles . text ] } > { label } </ Text >
445
463
</ View >
446
464
) ;
@@ -451,7 +469,8 @@ const NewCalendarScreen = () => {
451
469
< View >
452
470
{ renderSwitch ( 'Min and Max Dates' , minAndMax , toggleMinAndMax ) }
453
471
< View style = { styles . subSwitchContainer } >
454
- { minAndMax && renderSwitch ( 'Allow Selection Out Of Range' , allowSelectionOutOfRange , toggleAllowSelectionOutOfRange ) }
472
+ { minAndMax &&
473
+ renderSwitch ( 'Allow Selection Out Of Range' , allowSelectionOutOfRange , toggleAllowSelectionOutOfRange ) }
455
474
</ View >
456
475
{ renderSwitch ( 'Enable Swipe Months' , enableSwipeMonths , toggleEnableSwipeMonths ) }
457
476
{ renderSwitch ( 'Disable Month Change' , disableMonthChange , toggleDisableMonthChange ) }
@@ -460,8 +479,16 @@ const NewCalendarScreen = () => {
460
479
{ renderSwitch ( 'Hide Extra Days' , hideExtraDays , toggleHideExtraDays ) }
461
480
{ renderSwitch ( 'Hide Day Names' , hideDayNames , toggleHideDayNames ) }
462
481
{ renderSwitch ( 'Disabled By Default' , disabledByDefault , toggleDisabledByDefault ) }
463
- { renderSwitch ( 'Disable All Touch Events For Disabled Days' , disableAllTouchEventsForDisabledDays , toggleDisableAllTouchEventsForDisabledDays ) }
464
- { renderSwitch ( 'Disable All Touch Events For Inactive Days' , disableAllTouchEventsForInactiveDays , toggleDisableAllTouchEventsForInactiveDays ) }
482
+ { renderSwitch (
483
+ 'Disable All Touch Events For Disabled Days' ,
484
+ disableAllTouchEventsForDisabledDays ,
485
+ toggleDisableAllTouchEventsForDisabledDays
486
+ ) }
487
+ { renderSwitch (
488
+ 'Disable All Touch Events For Inactive Days' ,
489
+ disableAllTouchEventsForInactiveDays ,
490
+ toggleDisableAllTouchEventsForInactiveDays
491
+ ) }
465
492
{ renderSwitch ( 'Display Loading Indicator' , displayLoadingIndicator , toggleDisplayLoadingIndicator ) }
466
493
{ renderSwitch ( 'Disabled Days Indexes' , disabledDaysIndexes , toggleDisabledDaysIndexes ) }
467
494
{ renderSwitch ( 'Hide Arrows' , hideArrows , toggleHideArrows ) }
@@ -492,11 +519,9 @@ const NewCalendarScreen = () => {
492
519
return (
493
520
< TouchableOpacity onPress = { ( ) => setType ( index ) } key = { index } style = { styles . radioButtonContainer } >
494
521
< View style = { styles . radioButton } >
495
- { selectedButtonIndex === index &&
496
- < View style = { styles . selectedRadioButton } />
497
- }
522
+ { selectedButtonIndex === index && < View style = { styles . selectedRadioButton } /> }
498
523
</ View >
499
- < Text > { value } </ Text >
524
+ < Text > { value } </ Text >
500
525
</ TouchableOpacity >
501
526
) ;
502
527
} ;
@@ -563,8 +588,8 @@ const styles = StyleSheet.create({
563
588
alignItems : 'center'
564
589
} ,
565
590
text : {
566
- fontSize : 14 ,
567
- fontWeight : 'bold'
591
+ fontSize : 14 ,
592
+ fontWeight : 'bold'
568
593
} ,
569
594
buttonText : {
570
595
color : GREEN ,
@@ -628,8 +653,8 @@ const styles = StyleSheet.create({
628
653
padding : 8
629
654
} ,
630
655
customTitleContainer : {
631
- flexDirection : 'row' ,
632
- alignItems : 'center' ,
656
+ flexDirection : 'row' ,
657
+ alignItems : 'center' ,
633
658
padding : 10
634
659
} ,
635
660
customTitle : {
0 commit comments