Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "rntoast", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A light tip that can be used on both android and iOS.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,2 +45,3 @@ # RNToast | ||
| hideOnPress | bool | true | 点击Toast是否关闭Toast | | ||
| type | string | default | 支持success(#5cb85c)/info(#62B1F6)/error(#d9534f)/warning(#f0ad4e)/default(#999999) | | ||
@@ -47,0 +48,0 @@ |
@@ -15,3 +15,3 @@ import React, { | ||
TouchableOpacity, | ||
Platform | ||
Platform, | ||
} from 'react-native' | ||
@@ -31,8 +31,7 @@ | ||
padding: 10, | ||
backgroundColor: 'grey', | ||
width: width - 40, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
marginHorizontal: 40, | ||
borderRadius: 5, | ||
flexDirection: 'row', | ||
alignItems: 'center' | ||
}, | ||
@@ -42,14 +41,30 @@ textStyle: { | ||
color: '#fff', | ||
textAlign: 'center', | ||
}, | ||
touchableOpacity: { | ||
backgroundColor: '#61B843', | ||
marginTop: 20, | ||
height: 40, | ||
width: 80, | ||
textStyleWithButton: { | ||
fontSize: 16, | ||
color: '#fff', | ||
width: width - 120, | ||
}, | ||
confirmStyle: { | ||
backgroundColor: 'transparent', | ||
marginLeft: 10, | ||
width: 50, | ||
padding: 6, | ||
justifyContent: 'center', | ||
alignItems: 'center' | ||
alignItems: 'center', | ||
borderWidth: 0.5, | ||
borderColor: '#fff', | ||
}, | ||
confirmTextStyle: { | ||
color: '#fff', | ||
} | ||
} | ||
const colors = { | ||
default: '#999999', | ||
success: '#5cb85c', | ||
info: '#62B1F6', | ||
error: '#d9534f', | ||
warning: '#f0ad4e', | ||
} | ||
class ToastContainer extends Component { | ||
@@ -73,3 +88,6 @@ | ||
confirm: PropTypes.bool, | ||
confirmText: PropTypes.string | ||
confirmStyle: ViewPropTypes.style, | ||
confirmText: PropTypes.string, | ||
confirmTextStyle: Text.propTypes.style, | ||
type: PropTypes.string, | ||
}; | ||
@@ -85,3 +103,3 @@ | ||
confirm: false, | ||
confirmText: 'ok' | ||
confirmText: 'ok', | ||
}; | ||
@@ -190,3 +208,3 @@ | ||
{opacity: this.state.opacity}, | ||
{backgroundColor: colors[props.type] || colors['default']} | ||
)} | ||
@@ -198,8 +216,8 @@ pointerEvents='none' | ||
typeof(props.content) === 'string' | ||
? <Text style={Object.assign({}, styles.textStyle, props.textStyle)}>{props.children}</Text> | ||
? <Text allowFontScaling={false} style={Object.assign({}, props.textStyle, (props.confirm === true || props.duration <= 0) ? styles.textStyleWithButton : styles.textStyle)}>{props.children}</Text> | ||
: props.children | ||
} | ||
{props.confirm === true | ||
? <TouchableOpacity onPress={this.hide} style={styles.touchableOpacity}> | ||
<Text>{this.props.confirmText}</Text> | ||
{(props.confirm === true) || (props.duration <= 0) | ||
? <TouchableOpacity onPress={this.hide} style={Object.assign({}, styles.confirmStyle, props.confirmStyle)}> | ||
<Text allowFontScaling={false} style={Object.assign({}, styles.confirmTextStyle, props.confirmTextStyle)}>{this.props.confirmText}</Text> | ||
</TouchableOpacity> : null} | ||
@@ -206,0 +224,0 @@ </Animated.View> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10427
261
60