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

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

Open
mashaalmemon opened this issue Jul 20, 2021 · 22 comments · Fixed by #95
Open

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

mashaalmemon opened this issue Jul 20, 2021 · 22 comments · Fixed by #95
Labels
enhancement New feature or request

Comments

@mashaalmemon
Copy link

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

We're finding that:

  • When we use our custom primary color in the theme, when selecting date ranges the lighter color does not show up between the date range - only the start/end date have a circle with the primary color selected, and everything in between is the same color as the rest of the calendar.
  • When we comment out our primary color in the theme, the date picker works exactly as it should, using the default purple primary color for the dates selected, and having the lighter purple for the dates in between start/end dates selected.

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

@colinmatthewlee
Copy link

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
Copy link
Author

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

@chakrihacker
Copy link
Contributor

Can you share a code snippet that I can try locally

@iM-GeeKy
Copy link
Collaborator

iM-GeeKy commented Aug 1, 2021

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

@mashaalmemon
Copy link
Author

@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
Copy link
Contributor

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

@iM-GeeKy
Copy link
Collaborator

iM-GeeKy commented Aug 2, 2021

@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
Copy link
Member

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

@chakrihacker
Copy link
Contributor

@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
Copy link
Collaborator

iM-GeeKy commented Aug 3, 2021

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
Copy link
Contributor

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
Copy link
Member

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
Copy link
Member

RichardLindhout commented Aug 4, 2021

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

crussell122 added a commit to crussell122/react-native-paper-dates that referenced this issue Aug 13, 2021
@crussell122
Copy link

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
Copy link
Member

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

@RichardLindhout
Copy link
Member

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

@RichardLindhout RichardLindhout added the enhancement New feature or request label Oct 20, 2021
@chakrihacker
Copy link
Contributor

Let me give a try tweaking different colors

@chakrihacker
Copy link
Contributor

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

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

@RichardLindhout
Copy link
Member

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

@iM-GeeKy
Copy link
Collaborator

iM-GeeKy commented Nov 9, 2021

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
Copy link
Contributor

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
Copy link
Collaborator

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

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

Successfully merging a pull request may close this issue.

7 participants