react-native-calendars icon indicating copy to clipboard operation
react-native-calendars copied to clipboard

selected day background color and text color not changing on press

Open cgrady3 opened this issue 3 years ago • 8 comments

Description

doing calendar with multi dot marking. selectedDayBackgroundColor and selectedDayTextColor not changing on day press

no error messages

Environment

Please run these commands in the project folder and fill in their results:

Also specify:

  1. Device/emulator/simulator & OS version: working on expo go

cgrady3 avatar Mar 28 '22 00:03 cgrady3

@cgrady3 Hi. Please add a snippet of your code and try new version to see if fixed.

Inbal-Tish avatar Mar 28 '22 07:03 Inbal-Tish

I also encountered this problem, I directly used <Calendar/>,but it can display but cannot select the day number

Joseph-LouisLagrange avatar Apr 03 '22 02:04 Joseph-LouisLagrange

hi also facing this issue.

Nadeemkhan122 avatar May 13 '22 17:05 Nadeemkhan122

Also facing this issue. has it been solved?

DejiAwoniyi avatar Jun 23 '22 06:06 DejiAwoniyi

i have to switch libraries because of this issue

FaysalBsata avatar Jul 22 '22 12:07 FaysalBsata

I am also having the same issue!

Nziranziza avatar Aug 08 '22 18:08 Nziranziza

@cgrady3 @Joseph-LouisLagrange @Nadeemkhan122 @DejiAwoniyi @Nziranziza Can someone please provide a code snippet so I can have an example to work with? I need to see what you're doing to give an answer/solution.

Inbal-Tish avatar Aug 09 '22 07:08 Inbal-Tish

@cgrady3 If you're passing these keys in the theme prop you should know that it's not dynamic. The theme prop is passed once to the stylesheet and is not updated by a state change. In your case, where you want to change the SELECTED day background and text colors, I'll suggest using the markedDates prop. To the selected date you can pass selectedColor and selectedTextColor keys which will change dynamically as the selected date changes. For example:

  const [selected, setSelected] = useState(INITIAL_DATE);
  const [bgColor, setBgColor] = useState('blue');
  const [textColor, setTextColor] = useState('red');

  const onDayPress = useCallback((day) => {
    setSelected(day.dateString);
    setBgColor('orange');
    setTextColor('black');
  }, []);

  const markedDates = useMemo(() => {
    return {
      [selected]: {
        selected: true,
        disableTouchEvent: true,
        selectedColor: bgColor,
        selectedTextColor: textColor
      },
      ['2022-07-22']: {
        dotColor: 'red',
        marked: true
      }
    };
  }, [selected]);

Inbal-Tish avatar Aug 10 '22 09:08 Inbal-Tish

@Inbal-Tish just simple used, and it cannot show the selected <Calendar />

WhiteClouds2009 avatar Oct 16 '22 05:10 WhiteClouds2009

@Inbal-Tish just simple used, and it cannot show the selected <Calendar />

Of course not, the selected date is controlled by the user, meaning you need to mark it if you want.

Inbal-Tish avatar Oct 18 '22 05:10 Inbal-Tish

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.

stale[bot] avatar Jan 20 '23 20:01 stale[bot]