/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @flow * @providesModule DatePickerIOSExample */ 'use strict'; var React = require('react'); var ReactNative = require('react-native'); var { DatePickerIOS, StyleSheet, Text, TextInput, View, } = ReactNative; class DatePickerExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> { static defaultProps = { date: new Date(), timeZoneOffsetInHours: (-1) * (new Date()).getTimezoneOffset() / 60, }; state = { date: this.props.date, timeZoneOffsetInHours: this.props.timeZoneOffsetInHours, }; onDateChange = (date) => { this.setState({date: date}); }; onTimezoneChange = (event) => { var offset = parseInt(event.nativeEvent.text, 10); if (isNaN(offset)) { return; } this.setState({timeZoneOffsetInHours: offset}); }; render() { // Ideally, the timezone input would be a picker rather than a // text input, but we don't have any pickers yet :( return ( { this.state.date.toLocaleDateString() + ' ' + this.state.date.toLocaleTimeString() } hours from UTC ); } } class WithLabel extends React.Component<$FlowFixMeProps> { render() { return ( {this.props.label} {this.props.children} ); } } class Heading extends React.Component<$FlowFixMeProps> { render() { return ( {this.props.label} ); } } exports.displayName = (undefined: ?string); exports.title = ''; exports.description = 'Select dates and times using the native UIDatePicker.'; exports.examples = [ { title: '', render: function(): React.Element { return ; }, }]; var styles = StyleSheet.create({ textinput: { height: 26, width: 50, borderWidth: 0.5, borderColor: '#0f0f0f', padding: 4, fontSize: 13, }, labelContainer: { flexDirection: 'row', alignItems: 'center', marginVertical: 2, }, labelView: { marginRight: 10, paddingVertical: 2, }, label: { fontWeight: '500', }, headingContainer: { padding: 4, backgroundColor: '#f6f7f8', }, heading: { fontWeight: '500', fontSize: 14, }, });