wix / react-native-calendars

React Native Calendar Components 🗓️ 📆
MIT License
9.54k stars 2.95k forks source link

MarkedType='custom' with multi dots #2313

Open omzoSamb opened 1 year ago

omzoSamb commented 1 year ago

Hello,

when we use the parameter markedType='custom', the dots parmeters do not work when we want to hide them, and we do not have the possibilities to custom the style of markedDate.

check the exemple below and the result :

  const [currentDate, setCurrentDate] = useState(moment().format('YYYY-MM-DD'));
  const [selectedDate, setSelectedDate] = useState(currentDate);
  let res:ISomeObject = {};
  (dates? dates : []).forEach(it => {
    res[it] = {
      marked: true, 
      selected: true, 
      customStyles: {
        container: {
          backgroundColor: COLORS.pictonBlue,
          borderRadius: 5
      }
    }};
  })
  const marked = {
    ...res,
    [selectedDate]: { 
      dots: [],
      disableTouchEvent: false,
      selected: true,
      selectedColor: COLORS.greenConifer,
      customStyles: {
        container: {
          backgroundColor: COLORS.greenConifer,
          borderRadius: 5
        }
      }
    },
    '2023-08-11': {
      marked: true,
      dotColor: 'red',
      selected: true,
      dots: [
        {key: 'entrainement', color: 'white', selectedDotColor: 'magenta'},
        {key: 'compétition', color: 'red', selectedDotColor: 'black'}
      ]
    },
  };

  const onDayPress = useCallback((day: any) => {
      setSelectedDate(day.dateString);
    }, [selectedDate]);

  const displaySessionDay = console.log('Afficher les sessions du jour')

  return (
    <>   
      <Calendar
        markingType={'custom'}
        current={currentDate}
        onDayPress={onDayPress}
        markedDates={marked}
        firstDay= {1}
        style={CustomCalendarStyle.calendarStyle}
        hideExtraDays
        theme={{
          monthTextColor: COLORS.calendarTextDayColor,
          arrowColor: COLORS.astronautBlue,
          dayTextColor: COLORS.calendarTextDayColor,
          backgroundColor: COLORS.pictonBlue,
          textSectionTitleColor: COLORS.astronautBlue,
          textDayFontSize: 14,
          textDayFontWeight: '400',
          textDayFontFamily: 'OpenSans',
          textMonthFontSize: 16,
          textMonthFontWeight: '600',
          textMonthFontFamily: 'OpenSans',
          textDayHeaderFontSize: 16,
          textDayHeaderFontWeight: '600',
          textDayHeaderFontFamily: 'OpenSans'
        }}
      />
    </>
  );

};

Simulator Screenshot - iPhone 14 Pro - 2023-08-21 at 18 30 30

Br Thank you!

minhasmaqsood commented 9 months ago

I am facing the same issue +1

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.