<commit_before>import Menu from './Menu/Menu';
import React, { Component, PropTypes, StyleSheet, View, Text, TextInput } from 'react-native';
import { TYPO, PRIMARY, THEME_NAME, PRIMARY_COLORS } from './config';
import { getColor } from './helpers';
import Icon from './Icon';
import IconToggle from './IconToggle';
import isFunction from './utils';

const MenuItem = Menu.Item;

export default class Toolbar extends Component {

    static propTypes = {
        title: PropTypes.string,
        theme: PropTypes.oneOf(THEME_NAME),
        primary: PropTypes.oneOf(PRIMARY_COLORS),
        style: PropTypes.object,
        leftIconStyle: PropTypes.object,
        rightIconStyle: PropTypes.object,
        elevation: PropTypes.number,
        overrides: PropTypes.shape({
            backgroundColor: PropTypes.string,
            titleColor: PropTypes.string,
            leftIconColor: PropTypes.string,
            rightIconColor: PropTypes.string
        }),
        icon: PropTypes.string,
        onIconPress: PropTypes.func,
        actions: PropTypes.arrayOf(PropTypes.shape({
            icon: PropTypes.string.isRequired,
            onPress: PropTypes.func,
            counter: PropTypes.shape()
        })),
        menuActions: PropTypes.arrayOf(PropTypes.shape({
            icon: PropTypes.string,
            onPress: PropTypes.func,
            label: PropTypes.string,
            value: PropTypes.object
        })),
        searchable: PropTypes.shape({
            onChangeText: PropTypes.func,
            onSearchClosed: PropTypes.func,
            placeholder: PropTypes.string
        })

    };

    static defaultProps = {
        theme: 'dark',
        primary: PRIMARY,
        elevation: 4
    };

    constructor(props){
        super(props);

        this.state = {
            isSearchActive: false,
            searchValue: ''
        }
    }



    render() {
        const {
            title,
            theme,
            primary,
            style,
            leftIconStyle,
            rightIconStyle,
            elevation,
            overrides,
            icon,
            onIconPress,
            actions ,
            menuActions,
            searchable
        } = this.props;

        const themeMap = {
            light: {
                backgroundColor: '#ffffff',
                color: 'rgba(0,0,0,.87)',
                leftIconColor: 'rgba(0,0,0,.54)',
                rightIconColor: 'rgba(0,0,0,.54)'
            },
            dark: {
                backgroundColor: getColor(primary),
                color: 'rgba(255,255,255,.87)',
                leftIconColor: 'rgba(255,255,255,.87)',
                rightIconColor: 'rgba(255,255,255,.87)'
            }
        };

        const opacityMap = {
            light: .38,
            dark: .30
        };

        const styleMap = {
            backgroundColor: overrides && overrides.backgroundColor ? getColor(overrides.backgroundColor) : themeMap[theme].backgroundColor,
            color: overrides && overrides.color ? getColor(overrides.color) : themeMap[theme].color,
            leftIconColor: overrides && overrides.leftIconColor ? getColor(overrides.leftIconColor) : themeMap[theme].leftIconColor,
            rightIconColor: overrides && overrides.rightIconColor ? getColor(overrides.rightIconColor) : themeMap[theme].rightIconColor
        };

        let iconMap = icon;
        let onIconPressMap = onIconPress;
        let actionsMap = actions;
        let menuActionsMap = menuActions;

        if(this.state.isSearchActive){
            iconMap = 'keyboard-backspace';
            onIconPressMap = this._onSearchClosePressed;
            styleMap.backgroundColor = getColor('paperGrey100');
            styleMap.color = themeMap.light.color;
            styleMap.leftIconColor = themeMap.light.leftIconColor;
            styleMap.rightIconColor = themeMap.light.rightIconColor;
            actionsMap = [{
                icon: 'clear',
                onPress: () => this._onSearchTextChanged('')
            }]
            menuActionsMap = null;
        }

        return (
            <View style={[styles.toolbar, { backgroundColor :styleMap.backgroundColor, elevation }, style]}>
                {
                    iconMap && (
                        <IconToggle
                            color={styleMap.leftIconColor}
                            onPress={onIconPressMap}
                        >
                            <Icon name={iconMap || 'menu'}
                                  size={24}
                                  color={styleMap.leftIconColor}
                                  style={[styles.leftIcon, leftIconStyle]}
                            />
                        </IconToggle>
                    )
                }
                {
                    !this.state.isSearchActive &&
                    <Text
                        numberOfLines={1}
                        style={[styles.title, TYPO.paperFontTitle, {
                            color: styleMap.color,
                            marginLeft: iconMap ? styles.title.marginLeft : 16
                        }]}
                    >
                        {title}
                    </Text>
                }
                {
                    this.state.isSearchActive &&
                    <TextInput
                        autoFocus={true}
                        onChangeText={this._onSearchTextChanged}
                        placeholder={searchable.placeholder}
                        style={[styles.title, TYPO.paperFontTitle, {
                            color: styleMap.color,
                            marginLeft: iconMap ? styles.title.marginLeft : 16
                        }]}
                        underlineColorAndroid='transparent'
                        value={this.state.searchValue}
                    />
                }
                {
                    actionsMap &&
                    actionsMap.map((action, i) => {
                        return (
                            <IconToggle
                                key={i}
                                color={styleMap.rightIconColor}
                                badge={action.badge}<commit_msg>Fix font of search text<commit_after>import Menu from './Menu/Menu';
import React, { Component, PropTypes, StyleSheet, View, Text, TextInput } from 'react-native';
import { TYPO, PRIMARY, THEME_NAME, PRIMARY_COLORS } from './config';
import { getColor } from './helpers';
import Icon from './Icon';
import IconToggle from './IconToggle';
import isFunction from './utils';

const MenuItem = Menu.Item;

export default class Toolbar extends Component {

    static propTypes = {
        title: PropTypes.string,
        theme: PropTypes.oneOf(THEME_NAME),
        primary: PropTypes.oneOf(PRIMARY_COLORS),
        style: PropTypes.object,
        leftIconStyle: PropTypes.object,
        rightIconStyle: PropTypes.object,
        elevation: PropTypes.number,
        overrides: PropTypes.shape({
            backgroundColor: PropTypes.string,
            titleColor: PropTypes.string,
            leftIconColor: PropTypes.string,
            rightIconColor: PropTypes.string
        }),
        icon: PropTypes.string,
        onIconPress: PropTypes.func,
        actions: PropTypes.arrayOf(PropTypes.shape({
            icon: PropTypes.string.isRequired,
            onPress: PropTypes.func,
            counter: PropTypes.shape()
        })),
        menuActions: PropTypes.arrayOf(PropTypes.shape({
            icon: PropTypes.string,
            onPress: PropTypes.func,
            label: PropTypes.string,
            value: PropTypes.object
        })),
        searchable: PropTypes.shape({
            onChangeText: PropTypes.func,
            onSearchClosed: PropTypes.func,
            placeholder: PropTypes.string
        })

    };

    static defaultProps = {
        theme: 'dark',
        primary: PRIMARY,
        elevation: 4
    };

    constructor(props){
        super(props);

        this.state = {
            isSearchActive: false,
            searchValue: ''
        }
    }



    render() {
        const {
            title,
            theme,
            primary,
            style,
            leftIconStyle,
            rightIconStyle,
            elevation,
            overrides,
            icon,
            onIconPress,
            actions ,
            menuActions,
            searchable
        } = this.props;

        const themeMap = {
            light: {
                backgroundColor: '#ffffff',
                color: 'rgba(0,0,0,.87)',
                leftIconColor: 'rgba(0,0,0,.54)',
                rightIconColor: 'rgba(0,0,0,.54)'
            },
            dark: {
                backgroundColor: getColor(primary),
                color: 'rgba(255,255,255,.87)',
                leftIconColor: 'rgba(255,255,255,.87)',
                rightIconColor: 'rgba(255,255,255,.87)'
            }
        };

        const opacityMap = {
            light: .38,
            dark: .30
        };

        const styleMap = {
            backgroundColor: overrides && overrides.backgroundColor ? getColor(overrides.backgroundColor) : themeMap[theme].backgroundColor,
            color: overrides && overrides.color ? getColor(overrides.color) : themeMap[theme].color,
            leftIconColor: overrides && overrides.leftIconColor ? getColor(overrides.leftIconColor) : themeMap[theme].leftIconColor,
            rightIconColor: overrides && overrides.rightIconColor ? getColor(overrides.rightIconColor) : themeMap[theme].rightIconColor
        };

        let iconMap = icon;
        let onIconPressMap = onIconPress;
        let actionsMap = actions;
        let menuActionsMap = menuActions;

        if(this.state.isSearchActive){
            iconMap = 'keyboard-backspace';
            onIconPressMap = this._onSearchClosePressed;
            styleMap.backgroundColor = getColor('paperGrey100');
            styleMap.color = themeMap.light.color;
            styleMap.leftIconColor = themeMap.light.leftIconColor;
            styleMap.rightIconColor = themeMap.light.rightIconColor;
            actionsMap = [{
                icon: 'clear',
                onPress: () => this._onSearchTextChanged('')
            }]
            menuActionsMap = null;
        }

        return (
            <View style={[styles.toolbar, { backgroundColor :styleMap.backgroundColor, elevation }, style]}>
                {
                    iconMap && (
                        <IconToggle
                            color={styleMap.leftIconColor}
                            onPress={onIconPressMap}
                        >
                            <Icon name={iconMap || 'menu'}
                                  size={24}
                                  color={styleMap.leftIconColor}
                                  style={[styles.leftIcon, leftIconStyle]}
                            />
                        </IconToggle>
                    )
                }
                {
                    !this.state.isSearchActive &&
                    <Text
                        numberOfLines={1}
                        style={[styles.title, TYPO.paperFontTitle, {
                            color: styleMap.color,
                            marginLeft: iconMap ? styles.title.marginLeft : 16
                        }]}
                    >
                        {title}
                    </Text>
                }
                {
                    this.state.isSearchActive &&
                    <TextInput
                        autoFocus={true}
                        onChangeText={this._onSearchTextChanged}
                        placeholder={searchable.placeholder}
                        style={[styles.title, TYPO.paperFontTitle, {
                            fontWeight: 'normal',
                            color: styleMap.color,
                            marginLeft: iconMap ? styles.title.marginLeft : 16
                        }]}
                        underlineColorAndroid='transparent'
                        value={this.state.searchValue}
                    />
                }
                {
                    actionsMap &&
                    actionsMap.map((action, i) => {
                        return (
                            <IconToggle
                                key={i}
                                color={styleMap.rightIconColor}
                                badge={action.badge}
{'fraction_non_alphanumeric': 0.09344157911493155, 'fraction_numerical': 0.01002865329512894, 'mean_word_length': 1.2966550904770608, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6386176', 'n_tokens_mistral': 3138, 'n_tokens_neox': 2998, 'n_words': 539}