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

Added locale config for iOS DatePicker #556

Open
wants to merge 2 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ The bundled template will render an iOS `UIDatePicker` component, but collapsed
| `animationConfig` | The animation configuration object. Defaults to `{duration: 200}` for the default animation. |
| `format` | A `(date) => String(date)` kind of function to provide a custom date format parsing to display the value. Optional, defaults to `(date) => String(date)`.
| `defaultValueText` | An `string` to customize the default value of the `null` date value text. |
| `locale` | An `string` to set the locale for the component. |

For the collapsible customization, look at the `dateTouchable` and `dateValue` keys in the stylesheet file.

Expand Down
5 changes: 5 additions & 0 deletions lib/templates/bootstrap/datepicker.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class CollapsibleDatePickerIOS extends React.Component {
}

let formattedValue = locals.value ? String(locals.value) : "";
let locale = "en";
if (locals.config) {
if (locals.config.format && formattedValue) {
formattedValue = locals.config.format(locals.value);
Expand All @@ -79,6 +80,9 @@ class CollapsibleDatePickerIOS extends React.Component {
? locals.config.defaultValueText
: "Tap here to select a date";
}
if (locals.config.locale) {
locale = locals.config.locale;
}
}
const height = this.state.isCollapsed ? 0 : UIPICKER_HEIGHT;
return (
Expand All @@ -105,6 +109,7 @@ class CollapsibleDatePickerIOS extends React.Component {
onDateChange={this._onDateChange}
timeZoneOffsetInMinutes={locals.timeZoneOffsetInMinutes}
style={[datepickerStyle, { height: height }]}
locale={locale}
/>
</Animated.View>
</View>
Expand Down