<commit_before>import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Navigator,
  NavigatorIOS,
  TabBarIOS,
  TouchableHighlight,
} from 'react-native';

/*
 * This is a component for a navigation bar at the top of the page.
 * It includes a back button on the left-hand side of the navbar.
 * It has a page title that is centered
 * To add stuff after the page title, just nest a child (e.g an Edit button)
 * in the component like: <Navbar ...> NestedChildHere </Navbar>
 *
 * Note: you have to pass the navigator as props in order for the component
 * back button to work
 */
class Navbar extends Component {

  componentDidMount() {
    console.log("Navbar: props: ");
    for (var key in this.props) {
      console.log("+" + key + ": " + this.props[key]);
    }
    console.log("// state: " + this.state);
  }

  goBack() {
    this.props.navigator.pop();
  }

  render() {
    return (
      <View style={styles.navbar}>
        <TouchableHighlight style={styles.backButton} onPress={() => this.goBack()}>
          <Text>Back</Text>
        </TouchableHighlight>
        <Text style={styles.pageTitle}>{this.props.title}</Text>
        {this.props.children}
      </View>
    );
  }
}

const styles = StyleSheet.create({
  navbar: {
    flex: 1,
    marginTop: 20,
    backgroundColor: 'skyblue',
    marginBottom: 6,
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  backButton: {
    borderWidth: 1,
    padding: 10,
    alignSelf: 'flex-start'
  },
  editButton: {
    borderWidth: 1,
    padding: 10,
    alignSelf: 'flex-end',
  },
  pageTitle: {
    fontSize: 18,
    fontWeight: 'bold',
    alignSelf: 'center',
  },
});

module.exports = Navbar;<commit_msg>Update Navbar component to hide back button if given a property hasBackButton<commit_after>import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Navigator,
  NavigatorIOS,
  TabBarIOS,
  TouchableHighlight,
} from 'react-native';

/*
 * This is a component for a navigation bar at the top of the page.
 * It includes a back button on the left-hand side of the navbar.
 * It has a page title that is centered
 * To add stuff after the page title, just nest a child (e.g an Edit button)
 * in the component like: <Navbar ...> NestedChildHere </Navbar>
 *
 * Note: you have to pass the navigator as props in order for the component
 * back button to work
 */
class Navbar extends Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    console.log("Navbar: props: ");
    for (var key in this.props) {
      console.log("+" + key + ": " + this.props[key]);
    }
    console.log("// state: " + this.state);
  }

  goBack() {
    this.props.navigator.pop();
  }

  backButton() {
    console.log("Adding backButton . . .");
    return (
      <TouchableHighlight style={styles.backButton} onPress={() => this.goBack()}>
        <Text>Back</Text>
      </TouchableHighlight>
    );
  }

  render() {
    return (
      <View style={styles.navbar}>
        {this.props.hasBackButton ? this.backButton() : <Text></Text>}

        <Text style={styles.pageTitle}>{this.props.title}</Text>
        {this.props.children}
      </View>
    );
  }
}

const styles = StyleSheet.create({
  navbar: {
    flex: 1,
    marginTop: 20,
    backgroundColor: 'skyblue',
    marginBottom: 6,
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  backButton: {
    borderWidth: 1,
    padding: 10,
    alignSelf: 'flex-start'
  },
  editButton: {
    borderWidth: 1,
    padding: 10,
    alignSelf: 'flex-end',
  },
  pageTitle: {
    fontSize: 18,
    fontWeight: 'bold',
    alignSelf: 'center',
  },
});

Navbar.propTypes = {
  navigator: React.PropTypes.object.isRequired,
};

Navbar.defaultProps = {
  hasBackButton: true,
};

module.exports = Navbar;
{'fraction_non_alphanumeric': 0.13675213675213677, 'fraction_numerical': 0.006216006216006216, 'mean_word_length': 2.8581418581418583, 'pattern_counts': {'":': 2, '<': 25, '<?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': '6307964', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1250, 'n_words': 351}