<commit_before>/* @flow */
import { connect } from 'react-redux';

import React, { PureComponent } from 'react';
import { View } from 'react-native';
import type { ChildrenArray } from 'react';

import type { Dispatch, Context, GlobalState, LocalizableText, Style } from '../types';
import { NAVBAR_SIZE } from '../styles';
import Label from '../common/Label';
import { getCanGoBack } from '../selectors';
import NavButton from './NavButton';
import { navigateBack } from '../actions';
import { connectPreserveOnBackOption } from '../utils/redux';

type Props = {
  dispatch: Dispatch,
  canGoBack: boolean,
  title?: LocalizableText,
  titleColor?: string,
  itemsColor: string,
  rightItem?: Object,
  style: Style,
  children: ChildrenArray<*>,
  childrenStyle?: Style,
};

class ModalNavBar extends PureComponent<Props> {
  context: Context;
  props: Props;

  static contextTypes = {
    styles: () => null,
  };

  render() {
    const { styles } = this.context;
    const {
      dispatch,
      canGoBack,
      title,
      titleColor,
      itemsColor,
      rightItem,
      style,
      childrenStyle,
    } = this.props;
    const textStyle = [
      styles.navTitle,
      canGoBack ? { marginRight: NAVBAR_SIZE } : { marginLeft: 16 },
      rightItem ? { marginLeft: NAVBAR_SIZE } : {},
      titleColor ? { color: titleColor } : {},
    ];
    const content =
      React.Children.count(this.props.children) === 0 ? (
        <Label style={textStyle} text={title} numberOfLines={1} ellipsizeMode="tail" />
      ) : (
        this.props.children
      );

    return (
      <View style={[styles.navBar, style]}>
        {canGoBack && (
          <NavButton
            name="arrow-left"
            color={itemsColor}
            onPress={() => {
              dispatch(navigateBack());
            }}
          />
        )}
        <View style={[styles.flexedLeftAlign, childrenStyle]}>{content}</View>
        {rightItem && <NavButton color={itemsColor} {...rightItem} />}
      </View>
    );
  }
}

export default connect(<commit_msg>ModalNavBar: Cut a whole bunch of dead logic.<commit_after>/* @flow */
import { connect } from 'react-redux';

import React, { PureComponent } from 'react';
import { View } from 'react-native';

import type { Dispatch, Context, GlobalState, LocalizableText } from '../types';
import { NAVBAR_SIZE } from '../styles';
import Label from '../common/Label';
import { getCanGoBack } from '../selectors';
import NavButton from './NavButton';
import { navigateBack } from '../actions';
import { connectPreserveOnBackOption } from '../utils/redux';

type Props = {|
  dispatch: Dispatch,
  canGoBack: boolean,
  title?: LocalizableText,
|};

class ModalNavBar extends PureComponent<Props> {
  context: Context;
  props: Props;

  static contextTypes = {
    styles: () => null,
  };

  render() {
    const { styles } = this.context;
    const { dispatch, canGoBack, title } = this.props;
    const textStyle = [
      styles.navTitle,
      canGoBack ? { marginRight: NAVBAR_SIZE } : { marginLeft: 16 },
    ];

    return (
      <View style={[styles.navBar]}>
        {canGoBack && (
          <NavButton
            name="arrow-left"
            onPress={() => {
              dispatch(navigateBack());
            }}
          />
        )}
        <View style={styles.flexedLeftAlign}>
          <Label style={textStyle} text={title} numberOfLines={1} ellipsizeMode="tail" />
        </View>
      </View>
    );
  }
}

export default connect(
{'fraction_non_alphanumeric': 0.14555333142693738, 'fraction_numerical': 0.0020017157563625965, 'mean_word_length': 2.632398753894081, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '3912536', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1029, 'n_words': 254}