web-ridge / react-native-paper-dates

Smooth and fast cross platform Material Design date and time picker for React Native Paper
https://www.reactnativepaperdates.com
MIT License
638 stars 161 forks source link

With Date Range, lighter color not applied on days between the range #85

Open mashaalmemon opened 2 years ago

mashaalmemon commented 2 years ago

We're using react-native-paper in our project and have a custom theme.

We're finding that:

Is there another color we have to specify in the react-native-paper theme to get this working right?

colinmatthewlee commented 2 years ago

I've been experiencing this issue too, specifically when I set the primary color in theme to "#5F53FC", a lighter color connecting the two dates does not show up for me.

mashaalmemon commented 2 years ago

@chakrihacker @RichardLindhout @nandorojo Any guidance you can give us on this would be fantastic.

chakrihacker commented 2 years ago

Can you share a code snippet that I can try locally

iM-GeeKy commented 2 years ago

I only tested this on the iPhone simulator, it should at least demonstrate the issue at hand. (https://snack.expo.dev/2IrVHMYvU)

mashaalmemon commented 2 years ago

@iM-GeeKy thanks for taking the time to setup the snack example and demonstrate the issue we're facing here. Much appreciated.

@chakrihacker, if you look at @iM-GeeKy 's example project, when selecting a range there is no light-blue highlight between the date ranges; you'll notice he specified a primary color in the react-native-paper theme. But as soon as you delete that custom primary color, the light purple highlight works!

chakrihacker commented 2 years ago

@mashaalmemon and @iM-GeeKy test my branch and verify if it's working or not?

iM-GeeKy commented 2 years ago

@chakrihacker I tried your branch and it didn't seem to resolve the issue. As a sanity check, are you (@mashaalmemon) seeing the same behavior?

RichardLindhout commented 2 years ago

I already merged it but haven't tested it yet, if somebody has a fix I'll merge it into main

chakrihacker commented 2 years ago

@iM-GeeKy thanks for taking the time to setup the snack example and demonstrate the issue we're facing here. Much appreciated.

@chakrihacker, if you look at @iM-GeeKy 's example project, when selecting a range there is no light-blue highlight between the date ranges; you'll notice he specified a primary color in the react-native-paper theme. But as soon as you delete that custom primary color, the light purple highlight works!

How did you test my branch?

iM-GeeKy commented 2 years ago

In one of my private repositories I pointed to your branch in my package.json, deleted node_modules, and did a fresh install. I will add that I think the fix did help to a degree, but for lighter colors (ie. #2979FF, #5F53FC) the highlight is so faint it appears almost white. Thanks for the quick response times! Perhaps the ratio in your changes needs to be tweaked to accommodate for lighter hues.

chakrihacker commented 2 years ago

I think we can introduce a prop for the user to set the ratio of color lightness, right now it's 90% lightness of the primary color, so It depends on the primary color. Having hardcoded values might not be the best way. What are your thoughts @RichardLindhout ?

RichardLindhout commented 2 years ago

checking if it's light or dark I think there is something in the color for that or in the react-native-paper codebase already

RichardLindhout commented 2 years ago

I don't know if anything is written on it in the Material Design Spec

crussell122 commented 2 years ago

I just submitted a pr for the new rangeOpacity prop that I added in my branch. Please let me know if it works for you all.

RichardLindhout commented 2 years ago

I think we should check the darkness of the primary color to use different opacties if color is dark

RichardLindhout commented 2 years ago

But not let the user set it since it'll be extra work for the library user

chakrihacker commented 2 years ago

Let me give a try tweaking different colors

chakrihacker commented 2 years ago

What do you think of this approach of tint color @RichardLindhout ?

https://codesandbox.io/s/friendly-brattain-s1n7z?file=/src/App.js

RichardLindhout commented 2 years ago

I think it's good but it has to take in account the following things Dark theme RNN Primary color etc

iM-GeeKy commented 2 years ago

I think it's good but it has to take in account the following things Dark theme RNN Primary color etc

Is that not what @chakrihacker is mocking with his demo above? Where "Tinted Color" would correspond to dark theme color and so on...

SharfMohiuddin commented 11 months ago

Any solution? I'm facing the same issue. Selected range color is dark as it should be light and selected dates behind the selected range is hiding.

 const customDarkTheme = {
    ...DarkTheme,
    roundness: 2,
    colors: {
      ...DarkTheme.colors,
      primary: Colors.PRIMARY_GREEN,
      background: Colors.background,
      accent: "#ff1744",
      text: Colors.WHITE,
      surface: Colors.card_bg,
    },
    fonts: {
      regular: {
        fontFamily: typography.font_monsterrat_regular,
      },
    },
  };

  <PaperProvider theme={customDarkTheme}>
        <>
          <DatePickerModal
            saveLabel={
              <Text style={{ color: Colors.PRIMARY_GREEN, fontWeight: "bold" }}>
                Done
              </Text>
            }
            locale="en"
            mode="range"
            visible={open}
            onDismiss={onDismiss}
            startDate={range.startDate}
            endDate={range.endDate ? range.endDate : range.startDate} // Set the end date to the start date by default
            onConfirm={handleDateRangeSelect}
            validRange={{
              startDate: new Date(2021, 1, 2), // optional
              endDate: new Date(), // optional
            }}
            editIcon={false}
            label="Select Date"
            animationType="fade"
            startLabel=""
            endLabel=""
          />
        </>
      </PaperProvider>

Simulator Screenshot - iPhone 14 Pro Max - 2023-07-31 at 11 19 43

iM-GeeKy commented 11 months ago

@SharfMohiuddin PR's are welcome! As a temporary fix you can always create a patch using patch-package.

jhsu98 commented 1 month ago

I'm running into this same issue. When I override the theme.colors.primary default value I'm missing the tinted background for the dates between start and end. Has anybody found a reliable solution?