Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to disable next/previous component onPressHandler ! #365

Open
kishan-wts opened this issue Feb 5, 2024 · 1 comment
Open

I want to disable next/previous component onPressHandler ! #365

kishan-wts opened this issue Feb 5, 2024 · 1 comment

Comments

@kishan-wts
Copy link

When i select date range i want to disable month change functionality....can anyone Help me out??

@kishan-wts
Copy link
Author

kishan-wts commented Feb 5, 2024


const DragSelectCalendar = ({
  onDateChange,
  onVisibleMonthsChange,
  allowRangeSelection = true,
  calenderRef,
  customDatesStyles,
  isLoading = false,
}) => {
  const minDate = new Date(); 
  const isDateSelected =
    calenderRef?.current?.state?.selectedStartDate != null ? true : false;

  const _renderArrow = direction => {
    let iconName = 'chevron-thin-right';
    if (direction == 'left') {
      iconName = 'chevron-thin-left';
    }

    return (
      <View style={isDateSelected ? styles.hideArrow : styles.arrowContainer}>
        <Entypo
          disabled={isDateSelected}
          name={iconName}
          size={normalizeText(16)}
          color={isDateSelected ? COLORS.gray_Superlite : COLORS.Black}
        />
      </View>
    );
  };

  return (
    <>
      <CalendarPicker
        maxRangeDuration={31}
        ref={calenderRef}
        width={screenWidth - 40}
        allowRangeSelection={allowRangeSelection}
        minDate={minDate}
        selectedDayColor={COLORS.primary}
        selectedDayTextColor={COLORS.white}
        onDateChange={onDateChange}
        nextComponent={_renderArrow('right')}
        previousComponent={_renderArrow('left')}
        onMonthChange={
          isDateSelected
            ? () => {
                console.log('***123');
                return;
              }
            : onVisibleMonthsChange
        }
        customDatesStyles={customDatesStyles}
      />
    </>
  );
};

export default DragSelectCalendar;

const styles = StyleSheet.create({
  arrowContainer: {
    height: 40,
    width: 40,
    justifyContent: 'center',
    alignItems: 'center',
  },
  hideArrow: {
    height: 40,
    width: 40,
    justifyContent: 'center',
    alignItems: 'center',
    zIndex: 1,
    backgroundColor: 'red',
    top: 500,
  },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant