<commit_before>/* @flow */
'use strict';

import React, {Image} from 'react-native';
import NativeBaseComponent from '../Base/NativeBaseComponent';
import _ from 'lodash';
import computeProps from '../../Utils/computeProps';
import Icon from './Icon';
import Text from './Text';
import View from './View';
import Button from './Button';
import Thumbnail from './Thumbnail';

export default class ListItemNB extends NativeBaseComponent {

    getInitialStyle() {
        return {
            listItem: {
                padding: 7,
                paddingRight: 10,
                paddingLeft: 10,
                flex: 1,
                flexDirection: 'row',
                justifyContent: 'space-between',
                alignItems: 'center'
            },
            listItemDivider: {
                borderBottomWidth: 1,
                padding: 7,
                backgroundColor: '#E8E6EF',
                flex: 1,
                flexDirection: 'row'
            },
            itemText: {
                fontSize: 18,  
            },
            itemIcon: {
                fontSize: 18,
                color: 'black'
            },
            itemButton: {
                width: 50
            },
            itemNote: {
                fontSize: 15,
                color: '#58575C',
                alignSelf: 'center',
                fontWeight: '100',
                flex: 1,
                textAlign: 'right',

            },
            itemSubNote: {
                fontSize: 15,
                color: '#999'
            },
            thumbnail: {

            },
            fullImage: {
                width: 300,
                height: 300
            }
        }
    }
    getRightStyle() {
        return {
            right : {
                flex: 1,
                paddingLeft: 15
                
            }
        }
    }

    thumbnailPresent() {
        var thumbnailComponentPresent = false;
        React.Children.forEach(this.props.children, function (child) {
            if(child.type == Thumbnail)
                thumbnailComponentPresent = true;
        })

        return thumbnailComponentPresent;
    }

    iconPresent() {
        var iconComponentPresent = false;
        React.Children.forEach(this.props.children, function (child) {
            if(child.type == Icon)
                iconComponentPresent = true;
        })

        return iconComponentPresent;
    }

    buttonPresent() {
        var buttonComponentPresent = false;
        React.Children.forEach(this.props.children, function (child) {
            if(child.type == Button)
                buttonComponentPresent = true;
        })

        return buttonComponentPresent;
    }

    getChildStyle(child) {
        var mergedStyle = {};
        if(child.type == Icon) {
            return _.merge(mergedStyle, this.getInitialStyle().itemIcon, child.props.style);
        }

        else if(child.type == Text) {
            if(child.props.note && this.thumbnailPresent())
                return _.merge(mergedStyle, this.getInitialStyle().itemSubNote, child.props.style);
            else if(child.props.note)
                return _.merge(mergedStyle, this.getInitialStyle().itemNote, child.props.style);
            else
                return _.merge(mergedStyle, this.getInitialStyle().itemText, child.props.style);
        }

        else if(child.type == Button) {
            return _.merge(mergedStyle, this.getInitialStyle().itemButton, child.props.style);
        }

        else if(child.type == Thumbnail) {
            return _.merge(mergedStyle, this.getInitialStyle().thumbnail, child.props.style);
        }

        else if(child.type == Image && !Array.isArray(this.props.children))
            return _.merge(mergedStyle, this.getInitialStyle().fullImage, child.props.style);
        else 
            return child.props.style;
    }

    getChildProps(child) {
        var defaultProps = {};
        if(child.type == Image && !Array.isArray(this.props.children)) {
            defaultProps = {
                resizeMode: 'stretch', 
                style: this.getChildStyle(child)
            }
        }
        else if(child.type == Button) {
            defaultProps = {
                small: true,
                style: this.getChildStyle(child)
            }
        }
        else {
            defaultProps = {
                style: this.getChildStyle(child)
            }
        }
<commit_msg>remove getChildStyle func<commit_after>/* @flow */
'use strict';

import React, {Image} from 'react-native';
import NativeBaseComponent from '../Base/NativeBaseComponent';
import _ from 'lodash';
import computeProps from '../../Utils/computeProps';
import Icon from './Icon';
import Text from './Text';
import View from './View';
import Button from './Button';
import Thumbnail from './Thumbnail';

export default class ListItemNB extends NativeBaseComponent {

    getInitialStyle() {
        return {
            listItem: {
                padding: 7,
                paddingRight: 10,
                paddingLeft: 10,
                flex: 1,
                flexDirection: 'row',
                justifyContent: 'space-between',
                alignItems: 'center'
            },
            listItemDivider: {
                borderBottomWidth: 1,
                padding: 7,
                backgroundColor: '#E8E6EF',
                flex: 1,
                flexDirection: 'row'
            },
            itemText: {
                fontSize: 18,  
            },
            itemIcon: {
                fontSize: 18,
                color: 'black'
            },
            itemButton: {
                width: 50
            },
            itemNote: {
                fontSize: 15,
                color: '#58575C',
                alignSelf: 'center',
                fontWeight: '100',
                flex: 1,
                textAlign: 'right',

            },
            itemSubNote: {
                fontSize: 15,
                color: '#999'
            },
            thumbnail: {

            },
            fullImage: {
                width: 300,
                height: 300
            }
        }
    }
    getRightStyle() {
        return {
            right : {
                flex: 1,
                paddingLeft: 15
                
            }
        }
    }

    thumbnailPresent() {
        var thumbnailComponentPresent = false;
        React.Children.forEach(this.props.children, function (child) {
            if(child.type == Thumbnail)
                thumbnailComponentPresent = true;
        })

        return thumbnailComponentPresent;
    }

    iconPresent() {
        var iconComponentPresent = false;
        React.Children.forEach(this.props.children, function (child) {
            if(child.type == Icon)
                iconComponentPresent = true;
        })

        return iconComponentPresent;
    }

    buttonPresent() {
        var buttonComponentPresent = false;
        React.Children.forEach(this.props.children, function (child) {
            if(child.type == Button)
                buttonComponentPresent = true;
        })

        return buttonComponentPresent;
    }

    getChildProps(child) {
        var defaultProps = {};
        if(child.type == Image && !Array.isArray(this.props.children)) {
            defaultProps = {
                resizeMode: 'stretch', 
                style: this.getInitialStyle().fullImage
            }
        }
        else if(child.type == Button) {
            defaultProps = {
                small: true,
                style: this.getInitialStyle().itemButton
            }
        }
        else if(child.type == Text) {
            if(child.props.note && this.thumbnailPresent()) {
                defaultProps = {
                    style: this.getInitialStyle().itemSubNote
                }
            }
            else if(child.props.note) {
                defaultProps = {
                    style: this.getInitialStyle().itemNote
                }
            }
            else {
                defaultProps = {
                    style: this.getInitialStyle().itemText
                }
            }
        }
        else if(child.type == Icon) {
            defaultProps = {
                style: this.getInitialStyle().itemIcon
            }
        }
        else if(child.type == Thumbnail) {
            defaultProps = {
                style: this.getInitialStyle().thumbnail
            }
        }
        else {
            defaultProps = {
                style: {}
            }
        }

{'fraction_non_alphanumeric': 0.10161609115219161, 'fraction_numerical': 0.009766306243460064, 'mean_word_length': 1.2786754966887417, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6934452', 'n_tokens_mistral': 2281, 'n_tokens_neox': 2094, 'n_words': 440}