Header.js 2.31 KB
'use strict';

import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
import DeviceInfo from 'react-native-device-info';

const {
    View,
    Text,
    TouchableOpacity,
    Dimensions,
    StyleSheet,
	Platform,
} = ReactNative;

export default class Header extends React.Component {

    constructor(props) {
        super (props);
    }

    render() {
		return (
			<View style={styles.container}>
                <Text style={styles.name}>筛选商品</Text>
                <TouchableOpacity onPress={() => {this.props.cancelAction && this.props.cancelAction()}} >
                    <View style={styles.cancelButton}>
                        <Text style={styles.cancelText}>清空</Text>
                    </View>
                </TouchableOpacity>
                <TouchableOpacity onPress={() => {this.props.okAction && this.props.okAction()}} >
                    <View style={styles.okButton}>
                        <Text style={styles.okText}>确定</Text>
                    </View>
                </TouchableOpacity>
			</View>
		);
    }
}

let {width, height} = Dimensions.get('window');
let backgroundWidth = width;
let backgroundHeight = 64;
let buttonHeight = 30;
let buttonWidth = 50;
let rightOffset = 50;

let styles = StyleSheet.create({
	container: {
		width: backgroundWidth,
		height: backgroundHeight,
		backgroundColor: 'rgba(46,46,46,1)',
        flexDirection: 'row',
	},
    name: {
        fontSize: 14,
        color: 'white',
        marginTop: backgroundHeight - 20 - 10,
        marginLeft: 10,
        width: 100,
        height: buttonHeight,
        backgroundColor: 'transparent',
    },
    cancelButton: {
        height: buttonHeight,
        width: buttonWidth,
        backgroundColor: 'white',
        marginTop: backgroundHeight - buttonHeight - 10,
        alignItems: 'center',
        justifyContent: 'center',
        marginLeft: width - rightOffset - 110 - 10 - 2*buttonWidth - 10,
    },
    cancelText: {
        color: 'black',
    },
    okButton: {
        height: buttonHeight,
        width: buttonWidth,
        backgroundColor: 'black',
        marginTop: backgroundHeight - buttonHeight - 10,
        alignItems: 'center',
        justifyContent: 'center',
        marginLeft: 10,
    },
    okText: {
        color: 'white',
    },
});