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

How to add different colors for startdate and enddate when enable range selection #261

Closed
kobagapu opened this issue Dec 24, 2020 · 14 comments

Comments

@kobagapu
Copy link

onDateChange(date, type) {
if (type === 'END_DATE') {
this.setState({
selectedEndDate: date,
});
} else {
this.setState({
selectedStartDate: date,
selectedEndDate: date,
});
}
}

<CalendarPicker
dayLabelsWrapper = {{borderTopWidth:0}}
startFromMonday={true}
allowRangeSelection={true}
minDate={minDate}
weekdays={['S', 'M', 'T', 'W', 'T', 'F', 'Sat']}
maxDate={maxDate}
//previousTitle=" <"
//nextTitle="> "
previousTitleStyle={{ marginLeft: 30, fontSize: 30 }}
//customDatesStyles={customDatesStyles}
nextTitleStyle = {{fontSize: 30,marginRight:30}}
todayBackgroundColor={'#E9EFF4'}
selectedDayColor={'#E9EFF4'}
selectedDayTextColor="#242E42"
scaleFactor={450}
width={450}
allowBackwardRangeSelect = {true}
textStyle={{
fontFamily: Fonts.latoMedium,
color: '#242E42',
}}
onDateChange={this.onDateChange}
/>

@kobagapu
Copy link
Author

Screen.Recording.2020-12-24.at.3.00.49.PM.mov

@peacechen
Copy link
Collaborator

Try passing styles to these props:

selectedRangeStartStyle | ViewStyle | Optional. Style for range selected start day.
selectedRangeEndStyle | ViewStyle | Optional. Style for range selected end day.
selectedRangeStyle | ViewStyle | Optional. Style for all days in range selection.

@kobagapu
Copy link
Author

kobagapu commented Dec 28, 2020

Thanks @peacechen its working but is there any prop? changing text color in selectedRangeStartStyle and selectedRangeEndStyle

selectedRangeStartStyle = {{ backgroundColor: '#3A61A8'}}
Screenshot 2020-12-28 at 11 00 07 AM

@kobagapu kobagapu reopened this Dec 28, 2020
@peacechen
Copy link
Collaborator

Try the prop selectedDayTextStyle

@kobagapu
Copy link
Author

Try the prop selectedDayTextStyle

No its not working it does not change text color in selectedRangeStartStyle

selectedRangeStartStyle = {{ backgroundColor: Colors.themePrimary,selectedDayTextStyle:'#fff'}}

@peacechen
Copy link
Collaborator

peacechen commented Dec 29, 2020

That looks like a bug due to the order of styles in the array.

selectedDayTextStyle = [propSelectedDayTextStyle, styles.selectedDayLabel];

If you have time, please submit a PR that moves propSelectedDayTextStyle to the end. It should look like this on the 7 lines that use it:

          selectedDayTextStyle = [styles.selectedDayLabel, propSelectedDayTextStyle];

peacechen added a commit that referenced this issue Jan 1, 2021
@peacechen
Copy link
Collaborator

Published in 7.0.7
Happy New Year 🎆

@kobagapu
Copy link
Author

kobagapu commented Jan 4, 2021

Thanks @peacechen
<CalendarPicker
dayLabelsWrapper = {{borderTopWidth:0}}
startFromMonday={true}
allowRangeSelection={true}
minDate={minDate}
weekdays={['S', 'M', 'T', 'W', 'T', 'F', 'Sat']}
maxDate={maxDate}
previousTitle=" <"
nextTitle="> "
previousTitleStyle={{ marginLeft: 30, fontSize: 30 }}
//customDatesStyles={customDatesStyles}
nextTitleStyle = {{fontSize: 30,marginRight:30}}
todayBackgroundColor={'#E9EFF4'}
selectedDayColor={'#E9EFF4'}
selectedDayTextColor="#242E42"
//scaleFactor={400}
width={450}
height = {350}
allowBackwardRangeSelect={true}
selectedRangeStartStyle = {{ backgroundColor: Colors.themePrimary,selectedDayTextColor:'white'}}
selectedRangeEndStyle={{ backgroundColor: Colors.themePrimary}}
textStyle={{
fontFamily: Fonts.latoMedium,
color: '#242E42',
}}
onDateChange={this.onDateChange}
/>
its not working when add this prop selectedDayTextColor:'white'

@peacechen
Copy link
Collaborator

peacechen commented Jan 4, 2021

Pass a style to selectedDayTextStyle. It's a separate prop.

@kobagapu
Copy link
Author

kobagapu commented Jan 4, 2021

@peacechen selectedDayTextStyle pass it changes all selected days but i want to change selectedRangeStartStyle and selectedRangeEndStyle

@peacechen
Copy link
Collaborator

I see what you mean. selectedRangeStartStyle applies to the container View, not the Text within it, so it's unable to change the text color. New props selectedRangeStartTextStyle and selectedRangeEndTextStyle will need to be added. Please submit a PR that adds them.

@kobagapu
Copy link
Author

kobagapu commented Jan 4, 2021

#261 (comment)

peacechen added a commit that referenced this issue Jan 4, 2021
@peacechen
Copy link
Collaborator

The new props have been published in 7.0.8

I recommend that you learn how to submit Pull Requests (PR) to contribute to this library. You wouldn't need to wait around for someone else to make the change for you.

@kobagapu
Copy link
Author

kobagapu commented Jan 5, 2021

Thank you @peacechen

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

2 participants