SettingMessage.js 5.14 KB
/**
 * Created by jone on 2017/4/10.
 */
import React,
{
    Component
} from "react";
import ReactNative,{
    View,
    Text,
    TouchableWithoutFeedback,
    StyleSheet,
    TouchableOpacity,
    ScrollView,
    Dimensions,
    Platform,
} from "react-native";

import SettingCell from '../components/common/SettingCell';
import MoreAppCell from '../components/common/MoreAppCell';

export default class SettingMessage extends Component {
    constructor(props) {
        super(props);
    }



    _renderLoginView(isLogin){
        if (isLogin){
            return (
                <TouchableOpacity
                    activeOpacity={0.5}
                    onPress={
                            () =>  this.props.onPressItem && this.props.onPressItem(11)
                        }
                >
                <View style={styles.loginOutStyle}>

                   <Text style={styles.loginOutTvStyle}>
                       退出登录
                   </Text>
                </View>
                </TouchableOpacity>
            );
        }
    }

    _renderTouchView(){
        if (Platform.OS === 'ios'){
            return (
                <SettingCell
                    leftText="使用Touch ID登录"
                    orderId = "6"
                    isSwitch = {true}
                    onPressItem = {this.props.onPressItem}
                />
            );
        }
    }
    render() {
        let {data} = this.props;
        let isSwitchOpen = data.settingInfo.isOpenGprs;
        let isLogin = data.settingInfo.isLogin;
        let hasNew = data.versionInfo.hasNew;
        return (
            <ScrollView>
                <TouchableOpacity
                    activeOpacity={0.5}
                    onPress={
                            () =>  this.props.onPressItem && this.props.onPressItem(1)
                        }
                >
                <SettingCell
                    leftText="消息推送"
                    orderId = "1"
                    onPressItem = {this.props.onPressItem}
                    cellData = {data}
                    isGide = {true}
                    isPush = {true}
                />
                </TouchableOpacity>
                <SettingCell
                    leftText="2G/3G网络显示原图"
                    orderId = "2"
                    isSwitch = {isSwitchOpen}
                    onPressItem = {this.props.onPressItem}
                />
                <TouchableOpacity
                    activeOpacity={0.5}
                    onPress={
                            () =>  this.props.onPressItem && this.props.onPressItem(3)
                        }
                >
                <SettingCell
                    leftText="清除缓存"
                    orderId = "3"
                    rightTv = {data.settingInfo.cache}
                />
                </TouchableOpacity>
                {this._renderTouchView()}
                <View style={{marginTop:20}}>
                    <TouchableOpacity
                        activeOpacity={0.5}
                        onPress={
                            () =>  this.props.onPressItem && this.props.onPressItem(4)
                        }
                    >
                        <SettingCell
                            leftText="关于我们"
                            orderId = "4"
                            isGide = {true}
                            isNew = {hasNew}
                        />
                     </TouchableOpacity>

                    <TouchableOpacity
                        activeOpacity={0.5}
                        onPress={
                            () =>  this.props.onPressItem && this.props.onPressItem(5)
                        }
                    >
                        <SettingCell
                            leftText="推荐有货给好友"
                            orderId = "5"
                            isGide = {true}
                        />
                    </TouchableOpacity>

                </View>
                <View style={{marginTop:20}}>
                    <MoreAppCell
                        onPressItem =  {this.props.onPressItem}
                    />
                </View>
            {this._renderLoginView(isLogin)}
            </ScrollView>
        );
    }


};
let {width, height} = Dimensions.get('window');

let styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
    },
    leftViewStyle: {
        flexDirection: 'row',
        alignItems: 'center',
        marginLeft: 8
    },
    leftImgStyle: {
        width: 24,
        height: 24,
        marginRight: 6,
    },
    titleHelighted: {
        color: 'black',
        fontSize: 15,
    },
    titleNormal: {
        color: '#b0b0b0',
        fontSize: 15,
    },
    titleSelected: {
        color: 'black',
        fontSize: 15,
    },
    loginOutStyle:{
        height:45,
        backgroundColor: '#d0021b',
        borderRadius: 4,
        alignItems: 'center',
        justifyContent:'center',
        margin:25
    },
    loginOutTvStyle: {
        color: 'white',
        textAlign: 'center',
        fontSize: 15,
    },
});