Skip to content

Feat on press year #482

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/calendar/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ class CalendarHeader extends Component {
<View>
<View style={this.style.header}>
{leftArrow}
<View style={{ flexDirection: 'row' }}>
<Text allowFontScaling={false} style={this.style.monthText} accessibilityTraits='header'>
{this.props.month.toString(this.props.monthFormat ? this.props.monthFormat : 'MMMM yyyy')}
</Text>
{indicator}
</View>
<TouchableOpacity disabled={!this.props.onPressYear} onPress={this.props.onPressYear}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the condition on the 'disabled' prop I would condition the Component used, meaning const Component = this.props.onPressYear ? TouchableOpacity : View.

Copy link
Collaborator

@Inbal-Tish Inbal-Tish Jan 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please declare 'onPressYear' prop in the CalendarHeader's propTypes.

<View style={{ flexDirection: 'row' }}>
<Text allowFontScaling={false} style={this.style.monthText} accessibilityTraits='header'>
{this.props.month.toString(this.props.monthFormat ? this.props.monthFormat : 'MMMM yyyy')}
</Text>
{indicator}
</View>
</TouchableOpacity>
{rightArrow}
</View>
{
Expand Down
5 changes: 4 additions & 1 deletion src/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class Calendar extends Component {
// Handler which gets executed when press arrow icon left. It receive a callback can go back month
onPressArrowLeft: PropTypes.func,
// Handler which gets executed when press arrow icon left. It receive a callback can go next month
onPressArrowRight: PropTypes.func
onPressArrowRight: PropTypes.func,
// Handler which gets executed when press on Year / Month in header
onPressYear: PropTypes.func
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this component named 'onPressYear'? The press is on both year and month. How about 'onPressHeader'?

};

constructor(props) {
Expand Down Expand Up @@ -271,6 +273,7 @@ class Calendar extends Component {
weekNumbers={this.props.showWeekNumbers}
onPressArrowLeft={this.props.onPressArrowLeft}
onPressArrowRight={this.props.onPressArrowRight}
onPressYear={this.props.onPressYear}
/>
<View style={this.style.monthView}>{weeks}</View>
</View>);
Expand Down