/**
 * CrawlTop view
 *
 * Generated by coz on 2017-01-03,
 * from a template provided by apeman-asset-templates.
 *
 * @function CrawlTopView
 */
'use strict'

import React, { Component, PropTypes as types } from 'react'
import defineDebug from 'debug'
import {
  ApView, ApViewHeader, ApViewBody, ApViewFooter,
  ApList, ApListHeader, ApListBody, ApListItem
} from 'apeman-react-basic'
import {
  asConnected,
  asLocaled,
  asView,
  asServed,
  forAuth,
  forSpin,
  combine
} from '../../wrappers'

import { IconClasses } from 'ore-fol-enums'

const debug = defineDebug('project:view:crawl-top')
const { CRAWL_ICON } = IconClasses

/** @lends CrawlTopView */
class CrawlTopView extends Component {
  // --------------------
  // Specs
  // --------------------
  static get propTypes () {
    return {}
  }

  static get defaultProps () {
    return {}
  }

  render () {
    const s = this
    const {
      props,
      l
    } = s
    return (
      <ApView id='crawl-top-view'
              className='view'
              spinning={ props.spinning }
              way={ props.way }
      >
        <ApViewHeader onLeftTap={ s.handlePop }
                      leftText={ null }
                      leftIcon={ props.popIcon }
                      titleText={ l('titles.CRAWL') }
                      titleIcon={ CRAWL_ICON }
                      onRightTap={ null }
                      rightIcon={ null }
                      rightText={ null }
        />

        <ApViewBody>
          <ApList>
            <ApListHeader>{ l('headings.CRAWL_BOARD') }</ApListHeader>
            <ApListBody>
              <ApListItem disclosure
                          onTap={ s.handleNichan }
                          title={ l('buttons.SHOW_NICHAN_CRAWL') }
              />
            </ApListBody>
          </ApList>
        </ApViewBody>
      </ApView>
    )
  }

  // --------------------
  // Lifecycle
  // --------------------

  componentWillMount () {
    debug('willMount')
    const s = this
  }

  componentDidMount () {
    debug('didMount')
    const s = this
  }

  componentWillUnmount () {
    debug('willUnmount')
    const s = this
  }

  // --------------------
  // Handlers
  // --------------------

  handleNichan () {
    const s = this
    s.ifAuthorized(() =>
      s.handlePush('CrawlNichanView', {})
    )
  }

}

export default combine(
  asServed(),
  forSpin(),
  forAuth(),
  asLocaled(),
  asView(),
  asConnected()
)(CrawlTopView)

