<commit_before>import React, {
  View,
  Text,
  Image,
  ListView,
  StyleSheet,
  TouchableHighlight,
  RecyclerViewBackedScrollView
} from 'react-native'

import UIExplorerPage from '../UIExplorerPage'

const ds = new ListView.DataSource({
  rowHasChanged: (r1, r2) => r1 !== r2
})

export const title = '<ListView>'
export const description = 'Performat, scrollable list of data.'
export default class ListViewExample extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      dataSource: ds.cloneWithRows(this._getRows({}))
    }
  }

  componentWillMount () {
    this._pressData = {}
  }

  render () {
    return (
      <UIExplorerPage
        title={this.props.navigator ? null : title}
        onSpacer={true}
        onScroll={true}>
        <ListView
          dataSource={this.state.dataSource}
          renderRow={this._renderRow.bind(this)}
          renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
          renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator} />}
        />
      </UIExplorerPage>
    )
  }

  _renderRow (rowData, sectionID, rowID) {
    const rowHash = Math.abs(hashCode(rowData))
    const imgSource = THUMB_URLS[rowHash % THUMB_URLS.length]
    return (
      <TouchableHighlight onPress={() => this._pressRow(rowID)}>
        <View>
          <View style={styles.row}>
            <Image style={styles.thumb} source={imgSource}/>
            <Text style={styles.text}>
              {rowData + ' _ ' + LOREM_IPSUM.substr(0, rowHash % 301 + 10)}
            </Text>
          </View>
        </View>
      </TouchableHighlight>
    )
  }

  _getRows (pressData) {
    const dataBlob = []
    for (let i = 0; i < 100; i++) {
      let pressedText = pressData[i] ? ' (pressed)' : ''
      dataBlob.push('Row ' + i + pressedText)
    }
    return dataBlob
  }

  _pressRow (rowID) {
    this._pressData[rowID] = !this._pressData[rowID]
    this.setState({
      dataSource: this.state.dataSource.cloneWithRows(
        this._getRows(this._pressData)
      )
    })
  }
}

const THUMB_URLS = [
  require('../../styles/img/Thumbnails/like.png'),
  require('../../styles/img/Thumbnails/dislike.png'),
  require('../../styles/img/Thumbnails/call.png'),
  require('../../styles/img/Thumbnails/fist.png'),
  require('../../styles/img/Thumbnails/bandaged.png'),
  require('../../styles/img/Thumbnails/flowers.png'),
  require('../../styles/img/Thumbnails/heart.png'),
  require('../../styles/img/Thumbnails/liking.png'),
  require('../../styles/img/Thumbnails/party.png'),
  require('../../styles/img/Thumbnails/poke.png'),
  require('../../styles/img/Thumbnails/superlike.png'),
  require('../../styles/img/Thumbnails/victory.png')
]

const LOREM_IPSUM = 'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare'

const hashCode = function (str) {
  let hash = 15
  for (let i = str.length - 1; i >= 0; i--) {
    hash = ((hash << 5) - hash) + str.charCodeAt(i)
  }
  return hash
}

const styles = StyleSheet.create({
  row: {
    flexDirection: 'row',
    justifyContent: 'center',
    padding: 10,
    backgroundColor: '#F6F6F6'
  },
  separator: {
    height: 1,
    backgroundColor: '#CCCCCC'<commit_msg>item垂直居中<commit_after>import React, {
  View,
  Text,
  Image,
  ListView,
  StyleSheet,
  TouchableHighlight,
  RecyclerViewBackedScrollView
} from 'react-native'

import UIExplorerPage from '../UIExplorerPage'

const ds = new ListView.DataSource({
  rowHasChanged: (r1, r2) => r1 !== r2
})

export const title = '<ListView>'
export const description = 'Performat, scrollable list of data.'
export default class ListViewExample extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      dataSource: ds.cloneWithRows(this._getRows({}))
    }
  }

  componentWillMount () {
    this._pressData = {}
  }

  render () {
    return (
      <UIExplorerPage
        title={this.props.navigator ? null : title}
        onSpacer={true}
        onScroll={true}>
        <ListView
          dataSource={this.state.dataSource}
          renderRow={this._renderRow.bind(this)}
          renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
          renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator} />}
        />
      </UIExplorerPage>
    )
  }

  _renderRow (rowData, sectionID, rowID) {
    const rowHash = Math.abs(hashCode(rowData))
    const imgSource = THUMB_URLS[rowHash % THUMB_URLS.length]
    return (
      <TouchableHighlight onPress={() => this._pressRow(rowID)}>
        <View style={styles.row}>
          <Image style={styles.thumb} source={imgSource}/>
          <Text style={styles.text}>
            {rowData + ' _ ' + LOREM_IPSUM.substr(0, rowHash % 301 + 10)}
          </Text>
        </View>
      </TouchableHighlight>
    )
  }

  _getRows (pressData) {
    const dataBlob = []
    for (let i = 0; i < 100; i++) {
      let pressedText = pressData[i] ? ' (pressed)' : ''
      dataBlob.push('Row ' + i + pressedText)
    }
    return dataBlob
  }

  _pressRow (rowID) {
    this._pressData[rowID] = !this._pressData[rowID]
    this.setState({
      dataSource: this.state.dataSource.cloneWithRows(
        this._getRows(this._pressData)
      )
    })
  }
}

const THUMB_URLS = [
  require('../../styles/img/Thumbnails/like.png'),
  require('../../styles/img/Thumbnails/dislike.png'),
  require('../../styles/img/Thumbnails/call.png'),
  require('../../styles/img/Thumbnails/fist.png'),
  require('../../styles/img/Thumbnails/bandaged.png'),
  require('../../styles/img/Thumbnails/flowers.png'),
  require('../../styles/img/Thumbnails/heart.png'),
  require('../../styles/img/Thumbnails/liking.png'),
  require('../../styles/img/Thumbnails/party.png'),
  require('../../styles/img/Thumbnails/poke.png'),
  require('../../styles/img/Thumbnails/superlike.png'),
  require('../../styles/img/Thumbnails/victory.png')
]

const LOREM_IPSUM = 'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare'

const hashCode = function (str) {
  let hash = 15
  for (let i = str.length - 1; i >= 0; i--) {
    hash = ((hash << 5) - hash) + str.charCodeAt(i)
  }
  return hash
}

const styles = StyleSheet.create({
  row: {
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    padding: 10,
    backgroundColor: '#F6F6F6'
  },
  separator: {
    height: 1,
    backgroundColor: '#CCCCCC'
{'fraction_non_alphanumeric': 0.16676932553125962, 'fraction_numerical': 0.0076994148444718205, 'mean_word_length': 2.7805587892898718, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6975677', 'n_tokens_mistral': 2255, 'n_tokens_neox': 2192, 'n_words': 389}