UNPKG

@uiw/react-native

Version:
54 lines (49 loc) 1.21 kB
import React, { Component } from 'react'; import { View, Text, StyleSheet } from 'react-native'; function MaybeTextOrView({ children, ...otherProps }) { if (typeof children === 'string' || children && children.type.displayName === 'Text') { return <Text {...otherProps}>{children}</Text>; } return <View {...otherProps}>{children}</View>; } const styles = StyleSheet.create({ defalut: { justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff', paddingTop: 30, paddingBottom: 21 }, title: { fontSize: 21, marginTop: 15, paddingHorizontal: 15 }, message: { fontSize: 16, marginTop: 9, paddingHorizontal: 15, lineHeight: 18, color: '#888' } }); export default class Result extends Component { static defaultProps = {}; render() { const { style, title, message, img, ...otherProps } = this.props; return <View style={[styles.defalut, style]} {...otherProps}> {img} {title && <MaybeTextOrView style={styles.title}>{title}</MaybeTextOrView>} {message && <MaybeTextOrView style={styles.message}>{message}</MaybeTextOrView>} </View>; } }