diff --git a/components/ToastManager.js b/components/ToastManager.js index 1f76cd1..e32b018 100644 --- a/components/ToastManager.js +++ b/components/ToastManager.js @@ -6,7 +6,7 @@ import { View, Text, Animated, Dimensions, TouchableOpacity } from 'react-native import defaultProps from '../utils/defaultProps' import { Colors } from '../config/theme' -import styles from './styles' +import { styles, customContentStyles } from './styles' const { height } = Dimensions.get('window') @@ -40,23 +40,27 @@ class ToastManager extends Component { }, } - static info = (text, position) => { - ToastManager.__singletonRef.show(text, Colors.info, 'ios-information-circle', position) + static info = ({ text: text, position: position, icon: icon = 'ios-information-circle', iconColor = Colors.info, textColor: textColor = '#000000', background: background = '#FFFFFF' }) => { + ToastManager.__singletonRef.show(text, iconColor, icon, position, background, textColor) } - static success = (text, position) => { - ToastManager.__singletonRef.show(text, Colors.success, 'checkmark-circle', position) + static success = ({ text: text, position: position, icon: icon = 'checkmark-circle', iconColor = Colors.success, textColor: textColor = '#000000', background: background = '#FFFFFF' }) => { + ToastManager.__singletonRef.show(text, iconColor, icon, position, background, textColor) } - static warn = (text, position) => { - ToastManager.__singletonRef.show(text, Colors.warn, 'warning', position) + static warn = ({ text: text, position: position, icon: icon = 'warning', iconColor = Colors.warn, textColor: textColor = '#000000', background: background = '#FFFFFF' }) => { + ToastManager.__singletonRef.show(text, iconColor, icon, position, background, textColor) } - static error = (text, position) => { - ToastManager.__singletonRef.show(text, Colors.error, 'alert-circle', position) + static error = ({ text: text, position: position, icon: icon = 'alert-circle', iconColor = Colors.error, textColor: textColor = '#000000', background: background = '#FFFFFF' }) => { + ToastManager.__singletonRef.show(text, iconColor, icon, position, background, textColor) } - show = (text = '', barColor = Colors.default, icon, position) => { + static custom = ({ text: text, position: position, icon: icon = 'alert-circle', iconColor: iconColor = Colors.error, textColor: textColor = '#000000', background: background = '#FFFFFF' }) => { + ToastManager.__singletonRef.show(text, iconColor, icon, position, background, textColor) + } + + show = (text = '', barColor = Colors.default, icon, position, background, textColor) => { const { duration } = this.props this.state.barWidth.setValue(this.props.width) this.setState({ @@ -65,6 +69,8 @@ class ToastManager extends Component { text, barColor, icon, + background, + textColor }) if (position) this.setState({ position }) this.isShow = true @@ -135,9 +141,13 @@ class ToastManager extends Component { width, height, style, + contentStyle, + testID, theme, } = this.props + const allContentStyles = { ...customContentStyles, ...contentStyle } + const { isShow, animationStyle: stateAnimationStyle, @@ -145,6 +155,8 @@ class ToastManager extends Component { icon, text, barWidth, + background, + textColor } = this.state return ( @@ -165,30 +177,31 @@ class ToastManager extends Component { backdropColor={backdropColor} backdropOpacity={backdropOpacity} hasBackdrop={hasBackdrop} - style={styles.modalContainer} + style={[styles.modalContainer, allContentStyles?.modalContainer]} > - - + + - - - {text} + + + {text} - + @@ -199,4 +212,4 @@ class ToastManager extends Component { ToastManager.defaultProps = defaultProps -export default ToastManager +export default ToastManager \ No newline at end of file diff --git a/components/styles.js b/components/styles.js index 4254e3c..728a534 100644 --- a/components/styles.js +++ b/components/styles.js @@ -57,4 +57,17 @@ const styles = StyleSheet.create({ } }) -export default styles +const customContentStyles = { + modalContainer: {}, + mainContainer: {}, + hideButton: {}, + textStyle: {}, + progressBarContainer: {}, + content: {}, + iconWrapper: {}, +} + +export { + styles, + customContentStyles +} \ No newline at end of file