<commit_before>'use strict';
/**
 * layout布局模块，仅仅提供，该页面上的布局元素
 */
import React from 'react';
import {View, Text, StyleSheet, Button, Alert, ScrollView} from 'react-native';
import {connect} from 'react-redux';
//自己相关的reducer
import {reqArticle} from './action';
import './reducer';

import Header from '../../ui/head';
import Article from '../../ui/article';
import {loadDone} from '../../ui/article/action';

import Foot from '../../ui/foot';
import CmntEditor from '../../ui/cmntEditor';
import CmntList from '../../ui/cmntList';


import { NativeModules } from 'react-native';

import Loading from '../../ui/loading';

import {hideLoading} from '../../ui/loading/action';


const {ArticleHelper} = NativeModules;
//注册了一个helper的方法，用于提供接口访问相关
ArticleHelper.ajax(JSON.stringify({url:'helloworld','method':'post'})).then(function(data){
    console.log(data);
});


const styles = StyleSheet.create({
    'container': {
        flex: 1,
        display: 'flex',
        flexDirection: 'column',
        backgroundColor:'#fff'
    }
})

class ArticleLayout extends React.Component {
    static navigationOptions = {
        header: ({navigation})=>{
            //这里就navigation能用
            // console.log('helloworld');
            // console.log(navigation);
            // console.log(props);
            // const {resetState} = this.props;
            //这里的navigation中的dispatch就是redux中的dispatch 太棒了可以这里直接dispatch action了！！！
            const {dispatch} = navigation;
            return (
                <View style={{
                    height:30,
                    flexDirection:'row'
                }}>
                    <Button title={'点我回退到activity'} onPress={() => {
                        const {goBack} = ArticleHelper;

                        goBack().then(function(){
                            console.log('go back success');
                            //TODO 重置状态
                            //重置文章的isDone状态
                            dispatch(loadDone(false));
                            //重置loading的view的状态
                            dispatch(hideLoading(false));
                        });
                    }}/>
                    <Text style={{
                        marginLeft:20
                    }}>HELLO WORLD!!!!</Text>
                </View>
            )
        }
    }

    componentWillMount(){
        const {getArticle} = this.props;
        getArticle();
    }

    render() {
        const {state} = this.props.navigation;
        const {hideLoading} = this.props;
        return (
            <View style={styles.container}>
                {/* 添加loading动画效果 */}
                {!hideLoading && <Loading/>}
                <ScrollView style={{
                    marginBottom:56
                }}>
                    {/* 头部导航 */}
                    <Header/>
                    {/* 文章内容 */}
                    <Article/>
                    {/* 入选主题 */}
                    {/* 禁止评论 与 禁止转载 */}<commit_msg>添加一个延迟，防止页面直接刷新了<commit_after>'use strict';
/**
 * layout布局模块，仅仅提供，该页面上的布局元素
 */
import React from 'react';
import {View, Text, StyleSheet, Button, Alert, ScrollView} from 'react-native';
import {connect} from 'react-redux';
//自己相关的reducer
import {reqArticle} from './action';
import './reducer';

import Header from '../../ui/head';
import Article from '../../ui/article';
import {loadDone} from '../../ui/article/action';

import Foot from '../../ui/foot';
import CmntEditor from '../../ui/cmntEditor';
import CmntList from '../../ui/cmntList';


import { NativeModules } from 'react-native';

import Loading from '../../ui/loading';

import {hideLoading} from '../../ui/loading/action';


const {ArticleHelper} = NativeModules;
//注册了一个helper的方法，用于提供接口访问相关
ArticleHelper.ajax(JSON.stringify({url:'helloworld','method':'post'})).then(function(data){
    console.log(data);
});


const styles = StyleSheet.create({
    'container': {
        flex: 1,
        display: 'flex',
        flexDirection: 'column',
        backgroundColor:'#fff'
    }
})

class ArticleLayout extends React.Component {
    static navigationOptions = {
        header: ({navigation})=>{
            //这里就navigation能用
            // console.log('helloworld');
            // console.log(navigation);
            // console.log(props);
            // const {resetState} = this.props;
            //这里的navigation中的dispatch就是redux中的dispatch 太棒了可以这里直接dispatch action了！！！
            const {dispatch} = navigation;
            return (
                <View style={{
                    height:30,
                    flexDirection:'row'
                }}>
                    <Button title={'点我回退到activity'} onPress={() => {
                        const {goBack} = ArticleHelper;

                        goBack().then(function(){
                            console.log('go back success');
                            setTimeout(() => {
                                //重置状态
                                //重置文章的isDone状态
                                dispatch(loadDone(false));
                                //重置loading的view的状态
                                dispatch(hideLoading(false));
                            },300);

                        });
                    }}/>
                    <Text style={{
                        marginLeft:20
                    }}>HELLO WORLD!!!!</Text>
                </View>
            )
        }
    }

    componentWillMount(){
        const {getArticle} = this.props;
        getArticle();
    }

    render() {
        const {state} = this.props.navigation;
        const {hideLoading} = this.props;
        return (
            <View style={styles.container}>
                {/* 添加loading动画效果 */}
                {!hideLoading && <Loading/>}
                <ScrollView style={{
                    marginBottom:56
                }}>
                    {/* 头部导航 */}
                    <Header/>
                    {/* 文章内容 */}
                    <Article/>
                    {/* 入选主题 */}
                    {/* 禁止评论 与 禁止转载 */}
{'fraction_non_alphanumeric': 0.14188741721854303, 'fraction_numerical': 0.002814569536423841, 'mean_word_length': 1.4000794596742154, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 28, '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': '3385102', 'n_tokens_mistral': 1733, 'n_tokens_neox': 1731, 'n_words': 315}