<commit_before>import React, {
  PropTypes
} from 'react';

import {
  Picker as RNPicker,
  Text
} from 'react-native';

import AbstractFormComponent from './AbstractFormComponent';
import PickerContainer from './PickerContainer';

/**
 * @author 田尘殇Sean(<EMAIL>)
 * @date 16/5/8
 */
class Picker extends AbstractFormComponent {

  static propTypes = {
    children: PropTypes.node,
    selectedValue: PropTypes.string
  };

  static defaultProps = {
    selectedValue: ''
  };

  constructor(props) {
    super(props);
    let {form, name} = props;
    name && form && form.putFormValue(name, props.selectedValue);
    ['onValueChange'].forEach(f => this[f] = this[f].bind(this));
  }

  state = {
    selectedValue: this.props.selectedValue
  };

  onValueChange(selectedValue) {
    this.setState({selectedValue});
    let {form, name} = this.props;
    name && form && form.putFormValue(name, selectedValue);
  }

  getValue() {
    return this.state.selectedValue;
  }

  valid() {
    return false;
  }

  render() {
    let {children} = this.props;
    return (
      <PickerContainer>
        <RNPicker onValueChange={this.onValueChange}
                  selectedValue={this.state.selectedValue}>
          {children}
        </RNPicker>
      </PickerContainer>
    );
  }


}

Picker.Item = RNPicker.Item;

export default Picker;<commit_msg>基本功能完成<commit_after>import React, { PropTypes } from 'react';
import {
  Picker as RNPicker,
  PickerIOS,
  Platform,
  TouchableOpacity,
  StyleSheet,
  Text,
  View
} from 'react-native';
import { View as AnimatableView } from 'react-native-animatable';
import AbstractFormComponent from './AbstractFormComponent';
import Dialog from '../Dialog';
import Input from './Input';
import { Colors } from '../styles';

const styles = StyleSheet.create({
  dialogContainer: {
    backgroundColor: 'rgba(0,0,0,.4)',
    justifyContent: 'flex-end'
  },
  picker: {
    backgroundColor: '#fff'
  },
  header: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    height: 35,
    paddingHorizontal: 15,
    borderBottomWidth: 1,
    borderColor: Colors.separator,
    backgroundColor: Colors.underlay
  },
  finish: {}
});


const PickerComponent = Platform.OS === 'ios' ? PickerIOS : RNPicker;

const showAnimation = {
  animation: 'fadeIn',
  duration: 200
};
const hideAnimation = {
  animation: 'fadeOut',
  duration: 500
};

/**
 * @author 田尘殇Sean(<EMAIL>)
 * @date 16/5/8
 */
class Picker extends AbstractFormComponent {

  static propTypes = {
    children: PropTypes.node
  };

  state = {
    visible: false
  };

  contentShowAnimation = {
    animation: 'fadeInUpBig',
    duration: 500
  };

  contentHideAnimation = {
    animation: 'fadeOutDownBig',
    duration: 500
  };

  handleValueChange(selectedValue) {
    this.setState({selectedValue});
  }

  handleDialogSwitch() {
    this.setState({visible: !this.state.visible});
  }

  getValue() {
    return this.state.selectedValue;
  }

  valid() {
    return true;
  }

  renderHeader() {
    const {renderHeader, placeholder} = this.props;
    if (renderHeader) {
      return renderHeader();
    }
    return (
      <View style={styles.header}>
        <Text>{placeholder}</Text>
        <TouchableOpacity onPress={this.handleDialogSwitch}
                          style={styles.finish}
        >
          <Text style={{color: '#0977FF', fontSize: 14}}>完成</Text>
        </TouchableOpacity>
      </View>
    );
  }

  render() {
    let {children, editable, ...other} = this.props;
    let props = this.state.visible ? this.contentShowAnimation : this.contentHideAnimation;
    return (
      <TouchableOpacity disabled={editable}
                        onPress={this.handleDialogSwitch}
      >
        <Input {...other}
          defaultValue={this.state.selectedValue}
          editable={false}

        />
        <Dialog hideAnimation={hideAnimation}
                showAnimation={showAnimation}
                statusBarAutoHidden={false}
                style={styles.dialogContainer}
                visible={this.state.visible}
        >
          <AnimatableView {...props}
            style={styles.picker}
          >
            {this.renderHeader()}
            <PickerComponent onValueChange={this.handleValueChange}
                             selectedValue={this.state.selectedValue}
            >
              {children}
            </PickerComponent>
          </AnimatableView>
        </Dialog>
      </TouchableOpacity>
    );
  }


}

Picker.Item = PickerComponent.Item;

export default Picker;
{'fraction_non_alphanumeric': 0.12835625409299278, 'fraction_numerical': 0.007640253219821, 'mean_word_length': 2.6078740157480316, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5345117', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1370, 'n_words': 272}