{"size": 1890, "ext": "js", "max_stars_repo_path": "src/containers/HomeScreen.js", "max_stars_repo_name": "varmais/profitti-client", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/containers/HomeScreen.js", "max_issues_repo_name": "varmais/profitti-client", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/containers/HomeScreen.js", "max_forks_repo_name": "varmais/profitti-client", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.5, "max_line_length": 96, "alphanum_fraction": 0.6634920635}
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { ScrollView, Text, View } from 'react-native';
import { connect } from 'react-redux';
import SearchTextInput from '../components/songs/SearchTextInput';
import CategoryButton from '../components/songs/CategoryButton';
import HeaderLogo from '../components/common/HeaderLogo';
import AppStyles from '../helpers/Styles';
import { fetchSongs } from '../redux/songs';
import NavigationButtonListView from '../components/navigation/NavigationButtonListView';
import { navigatorPropTypes, categoryPropTypes } from '../helpers/PropTypes';
import config from "../config";

export class HomeScreen extends Component {
  static navigationOptions = {
    headerTitle: <HeaderLogo />,
    headerStyle: {
      backgroundColor: config.colors.black
    }
  };

  static propTypes = {
    navigation: navigatorPropTypes(),
    fetchSongs: PropTypes.func.isRequired,
    categories: PropTypes.arrayOf(categoryPropTypes()).isRequired
  };

  componentWillMount () {
    this.props.fetchSongs();
  }

  render () {
    const { navigation, categories } = this.props;
    return (
      <ScrollView style={AppStyles.background}>
        <View>
          <View style={AppStyles.container}>
            <View style={AppStyles.titleContainer}>
              <Text style={AppStyles.title}>Haku</Text>
            </View>
            <SearchTextInput navigation={navigation}/>
          </View>
          <NavigationButtonListView
            title="Kategoriat"
            enableEmptySections
            navigation={navigation}
            items={categories}
            renderRow={rowData => <CategoryButton category={rowData} navigation={navigation} />}
          />
        </View>
      </ScrollView>
    );
  }
}

export default connect((state) => ({
  categories: state.songs.categories
}), {
  fetchSongs
})(HomeScreen);