Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ yarn add react-native-month-selector
| containerStyle | ViewStyle | null | custom style for the container |
| yearTextStyle | TextStyle | null | custom style for the year text |
| monthTextStyle | TextStyle | null | custom style of the text for the months |
| monthWidth | number | 40 | custom width and height for months. BorderRadius will be adjusted
| currentMonthTextStyle | TextStyle | null | custom style for the current month text |
| initialView | moment.Moment | moment() | which month should be selected initially |
| onMonthTapped | (month: moment.Moment) => any | (month) => {} | function called when month is pressed |
Expand Down
17 changes: 17 additions & 0 deletions src/MonthSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface MonthSelectorProps {
yearTextStyle: TextStyle
monthTextStyle: TextStyle
currentMonthTextStyle: TextStyle
monthWidth: number
monthFormat: string
initialView: moment.Moment
onMonthTapped: (month: moment.Moment) => any
Expand Down Expand Up @@ -82,6 +83,7 @@ class MonthSelector extends React.Component<
monthTextStyle: PropTypes.any,
currentMonthTextStyle: PropTypes.any,
monthFormat: PropTypes.string,
monthWidth: PropTypes.number,
initialView: PropTypes.any,
onMonthTapped: PropTypes.func,
onYearChanged: PropTypes.func,
Expand Down Expand Up @@ -114,6 +116,7 @@ class MonthSelector extends React.Component<
color: "#22ee11",
},
monthTextStyle: { color: "#000" },
monthWidth: 40,
initialView: moment(),
onMonthTapped: month => {},
onYearChanged: year => {},
Expand Down Expand Up @@ -162,12 +165,26 @@ class MonthSelector extends React.Component<
return {}
}

getSelectedMonthWidth() {
if (this.props.monthWidth) {
return {
height: this.props.monthWidth,
width: this.props.monthWidth,
borderRadius: this.props.monthWidth /2,
}
}
else {
return {};
}
}

getMonthActualComponent(month: moment.Moment, isDisabled: boolean = false) {
return (
<View
style={[
isDisabled === true && { flex: 1, alignItems: "center" },
styles.monthStyle,
this.getSelectedMonthWidth(),
this.getSelectedBackgroundColor(month),
]}
>
Expand Down