React Native Buttonパッケージ

1846 ワード

react nativeの開発では、独自のbuttonコンポーネントは私たちの開発ニーズを満たすことができません.背景図などの設定はサポートされていません.簡単なbuttonをパッケージしましたコードは次のとおりです.
import React from "react";
import {
    Text,
    View,
    StyleSheet,
    TouchableOpacity,
    Image
} from "react-native";

const styles = StyleSheet.create({
    ButtonStyle: {
        justifyContent: "center",
        alignItems: "center"
    },
    contentStyle: {
        backgroundColor: "transparent"
    },
    Text: {
        textAlign: "center"
    },
    backgroundImage: {
        width: "100%",
        height: "100%",
        position: "absolute",
        zIndex: -2,
        alignSelf: "center"
    }
});

class Button extends React.Component {
    constructor(props) {
        super(props);
    }
    static defaultProps = {
        style: {},
        enable: true,
        textStyle: {},
        backgroundImage: null,
        backgroundImageStyle: {},
        type: "default"
    };

    render() {
        return (
            // 
            
                {this.props.hasOwnProperty("title") ? (
                    
                        {this.props.title}
                    
                ) : null}
                {this.props.hasOwnProperty("backgroundImage") ? (
                    
                ) : null}
                
            
        );
    }
}

export default Button;