-
Notifications
You must be signed in to change notification settings - Fork 3k
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
base: master
Are you sure you want to change the base?
Feat on press year #482
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
@@ -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>); | ||
|
There was a problem hiding this comment.
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
.