home.js 5.01 KB
/**
 * Created by Cassie on 2018/03/21
 */
import React, { Component } from 'react';
import {
    StyleSheet,
    View,
    Text,
    TouchableOpacity,
    Image,
    TextInput
} from 'react-native';

import {zoomW,zoomH} from '../utils/getSize';

const address = require('../img/address.png');
const circle = require('../img/circle.png');

export default class Home extends Component {
    static navigationOptions = ({navigation}) => ({
        title:'安全护航员',
    });

    constructor(props){
        super(props);
        this.state = {
            value:true
        };
    };

    render() {
        return (
            <View style={styles.background}>
                <View style={styles.top}>
                    <View style={styles.topLeft}>
                        <Text style={{fontSize:13,color:'#616161'}}>当前状态:</Text>
                        <View style={{flex:1,flexDirection:'row',justifyContent:'center'}}>
                            <Text style={{fontSize:18,color:'#3e6db7'}}>已上岗</Text>
                        </View>
                    </View>
                    <View style={styles.topRight}>
                        <View style={{width:(96/zoomW),height:(25/zoomH),display:'flex',justifyContent:'center',alignItems:'center'}}>
                            <Text style={{fontSize:13,color:'#616161'}}>自动上、下岗</Text>
                        </View>
                        <TouchableOpacity activeOpacity={0.8} style={styles.topBtn}>
                            <View style={styles.circle} />
                        </TouchableOpacity>
                    </View>
                </View>
                <View style={styles.content}>
                    <View style={styles.contentTop}>
                        <View style={{height:(20/zoomH),display:'flex',flexDirection:'row',alignItems:'center'}}>
                            <View style={styles.contentTip}>
                                <Text style={{fontSize:14,color:'#636363'}}>上岗</Text>
                            </View>
                            <Text style={{fontSize:14,color:'#707070'}}>03-20 08:38:42</Text>
                        </View>
                        <View style={{height:(20/zoomH),display:'flex',flexDirection:'row',alignItems:'center'}}>
                            <View style={styles.contentTip}>
                                <Image style={{width:(17/zoomW),height:(17/zoomW)}} source={address} resizeMode="center" />
                            </View>
                            <Text style={{fontSize:14,color:'#707070'}}>03-20 08:38:42</Text>
                            <TouchableOpacity style={{marginLeft:(20/zoomW)}}>
                                <Text style={{fontSize:12,color:'#4b85e0'}}>修正</Text>
                            </TouchableOpacity>
                        </View>
                        <Image style={styles.contentCircle} source={circle} resizeMode="cover" />
                    </View>
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    background:{
        flex:1,
        backgroundColor:'#f6f6f6',
        display:'flex',
        alignItems:'center'
    },
    top:{
        width:(345/zoomW),
        height:(44/zoomH),
        backgroundColor:'#fff',
        borderRadius:8,
        marginTop:(15/zoomH),
        marginBottom:(15/zoomH),
        paddingLeft:(15/zoomW),
        paddingRight:(15/zoomW),
        elevation:2,
        shadowColor:'#a9a9a9',
        shadowOffset:{width:0,height:2},
        shadowOpacity:0.5,
        shadowRadius:4,
        display:'flex',
        flexDirection:'row',
        alignItems:'center'
    },
    topLeft:{
        width:(190/zoomW),
        height:(25/zoomH),
        display:'flex',
        flexDirection:'row',
        alignItems:'center',
        borderRightWidth:1,
        borderColor:'#f6f6f6',
        borderStyle:'solid'
    },
    topRight:{
        flex:1,
        height:(25/zoomW),
        display:'flex',
        flexDirection:'row',
        alignItems:'center'
    },
    topBtn:{
        width:(30/zoomW),
        height:(16/zoomH),
        backgroundColor:'#1fbe6e',
        borderRadius:(8/zoomH),
        display:'flex',
        justifyContent:'center'
    },
    circle:{
        width:(14/zoomH),
        height:(14/zoomH),
        borderRadius:(7/zoomH),
        backgroundColor:'#fff',
        position:'absolute',
        left:(14/zoomW)
    },
    content:{
        width:(345/zoomW),
        height:(342/zoomH),
        backgroundColor:'#fff',
        paddingLeft:(15/zoomW),
        paddingRight:(15/zoomW)
    },
    contentTop:{
        width:'100%',
        height:(94/zoomH),
        borderBottomWidth:1,
        borderColor:'#f6f6f6',
        borderStyle:'solid',
        paddingTop:(20/zoomH),
        paddingLeft:(35/zoomW)
    },
    contentTip:{
        width:(28/zoomW),
        display:'flex',
        alignItems:'center',
        marginRight:(15/zoomW)
    },
    contentCircle:{
        width:(18/zoomW),
        height:(18/zoomW),
        position:'absolute',
        top:(35/zoomH)
    }
});