<commit_before>import React, { Component, PropTypes } from 'react'
import {
    View,
    TouchableOpacity,
    StyleSheet,
    Text
} from 'react-native'

class SegmentedControlTab extends Component {

    constructor(props) {
        super(props)
        this.state = this.props.multiple ?
            {
                selectedIndices: this.props.selectedIndices,
            } : {
                selectedIndex: this.props.selectedIndex,
            }
    }

    onTabPress = (index) => {
        if (this.props.multiple) {
            if (this.state.selectedIndices.includes(index)) {
                this.setState({
                    selectedIndices: this.state.selectedIndices.
                        filter((ind) => ind !== index),
                });
            }
            else {
                this.setState({
                    selectedIndices: [
                        ...this.state.selectedIndices,
                        index,
                    ],
                }, () => this.props.onTabPress(index));
            }
        }
        else if (this.state.selectedIndex !== index) {
            this.setState({
                selectedIndex: index,
            }, () => this.props.onTabPress(index));
        }
    }

    renderTabOption(tab, index) {
        const {values, borderRadius, multiple} = this.props
        const isTabActive = multiple ?
            this.state.selectedIndices.includes(index) :
            this.state.selectedIndex === index
        const firstTabStyle = index === 0 ? [{ borderTopLeftRadius: borderRadius, borderBottomLeftRadius: borderRadius }] : {}
        const lastTabStyle = index === values.length - 1 ? [{ borderTopRightRadius: borderRadius, borderBottomRightRadius: borderRadius }] : {}

        return (
            <TouchableOpacity style={[styles.tabStyle,
            this.props.tabStyle,
            isTabActive ? styles.activeTabStyle : {},
            isTabActive ? this.props.activeTabStyle : {},
                firstTabStyle,
                lastTabStyle]}
                key={index}
                onPress={() => this.onTabPress(index)}
                activeOpacity={1}>
                <Text style={[styles.textStyle,
                this.props.tabTextStyle,
                isTabActive ? styles.activeTabTextStyle : {},
                isTabActive ? this.props.activeTabTextStyle : {}]}>{tab}</Text>
            </TouchableOpacity>
        )
    }

    render() {
        const {values} = this.props
        return (
            <View style={[styles.tabsContainerStyle, this.props.tabsContainerStyle]}
                removeClippedSubviews={true}>
                {values.map((item, index) => this.renderTabOption(item, index))}
            </View>
        )
    }
}

SegmentedControlTab.propTypes = Object.assign({}, Component.propTypes, {
    values: PropTypes.array,
    multiple: PropTypes.bool,<commit_msg>Removed contains() and used includes()<commit_after>import React, { Component, PropTypes } from 'react'
import {
    View,
    TouchableOpacity,
    StyleSheet,
    Text
} from 'react-native'

class SegmentedControlTab extends Component {

    constructor(props) {
        super(props)
        this.state = this.props.multiple ?
            {
                selectedIndices: this.props.selectedIndices,
            } : {
                selectedIndex: this.props.selectedIndex,
            }
    }

    onTabPress = (index) => {
        if (this.props.multiple) {
            if (this.state.selectedIndices.includes(index)) {
                this.setState({
                    selectedIndices: this.state.selectedIndices.
                        filter((ind) => ind !== index),
                });
            }
            else {
                this.setState({
                    selectedIndices: [
                        ...this.state.selectedIndices,
                        index,
                    ],
                }, () => this.props.onTabPress(index));
            }
        }
        else if (this.state.selectedIndex !== index) {
            this.setState({
                selectedIndex: index,
            }, () => this.props.onTabPress(index));
        }
    }

    renderTabOption(tab, index) {
        const { values, borderRadius, multiple } = this.props
        const isTabActive = multiple ?
            this.state.selectedIndices.includes(index) :
            this.state.selectedIndex === index

        const firstTabStyle = index === 0 ? [{ borderTopLeftRadius: borderRadius, borderBottomLeftRadius: borderRadius }] : {}
        const lastTabStyle = index === values.length - 1 ? [{ borderTopRightRadius: borderRadius, borderBottomRightRadius: borderRadius }] : {}

        return (
            <TouchableOpacity style={[styles.tabStyle,
            this.props.tabStyle,
            isTabActive ? styles.activeTabStyle : {},
            isTabActive ? this.props.activeTabStyle : {},
                firstTabStyle,
                lastTabStyle]}
                key={index}
                onPress={() => this.onTabPress(index)}
                activeOpacity={1}>
                <Text style={[styles.textStyle,
                this.props.tabTextStyle,
                isTabActive ? styles.activeTabTextStyle : {},
                isTabActive ? this.props.activeTabTextStyle : {}]}>{tab}</Text>
            </TouchableOpacity>
        )
    }

    render() {
        const { values } = this.props
        return (
            <View style={[styles.tabsContainerStyle, this.props.tabsContainerStyle]}
                removeClippedSubviews={true}>
                {values.map((item, index) => this.renderTabOption(item, index))}
            </View>
        )
    }
}

SegmentedControlTab.propTypes = Object.assign({}, Component.propTypes, {
    values: PropTypes.array,
    multiple: PropTypes.bool,
{'fraction_non_alphanumeric': 0.11344104503265727, 'fraction_numerical': 0.0010312822275696115, 'mean_word_length': 1.654653284671533, 'pattern_counts': {'":': 0, '<': 15, '<?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': '316667', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1469, 'n_words': 253}