From f74a13824d550005234736a6e2c215c34a24f9d5 Mon Sep 17 00:00:00 2001 From: Kaique292 Date: Mon, 17 Apr 2023 14:32:50 -0300 Subject: [PATCH 1/6] featured: add new prop contentStyle for custom style in every div contentStyle = { modalContainer: {}, mainContainer: {}, hideButton: {}, textStyle: {}, progressBarContainer: {}, content: {}, iconWrapper: {}, } --- components/ToastManager.js | 15 ++++++++------- components/styles.js | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/ToastManager.js b/components/ToastManager.js index 1f76cd1..d36b359 100644 --- a/components/ToastManager.js +++ b/components/ToastManager.js @@ -135,6 +135,7 @@ class ToastManager extends Component { width, height, style, + contentStyle, theme, } = this.props @@ -165,11 +166,11 @@ class ToastManager extends Component { backdropColor={backdropColor} backdropOpacity={backdropOpacity} hasBackdrop={hasBackdrop} - style={styles.modalContainer} + style={contentStyle?.modalContainer ?? styles.modalContainer} > - + - + - {text} + {text} - + diff --git a/components/styles.js b/components/styles.js index 4254e3c..b304734 100644 --- a/components/styles.js +++ b/components/styles.js @@ -57,4 +57,4 @@ const styles = StyleSheet.create({ } }) -export default styles +export default styles \ No newline at end of file From 85cd120750d23cf8baf93e2d6e4188324b668533 Mon Sep 17 00:00:00 2001 From: Kaique292 Date: Mon, 17 Apr 2023 14:44:25 -0300 Subject: [PATCH 2/6] fix: Improving the way the prop is read Improved contentStyle prop, to override property only if it's equal, if not added more --- components/ToastManager.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/ToastManager.js b/components/ToastManager.js index d36b359..fce79cc 100644 --- a/components/ToastManager.js +++ b/components/ToastManager.js @@ -166,11 +166,12 @@ class ToastManager extends Component { backdropColor={backdropColor} backdropOpacity={backdropOpacity} hasBackdrop={hasBackdrop} - style={contentStyle?.modalContainer ?? styles.modalContainer} + style={[styles.modalContainer, ...contentStyle?.modalContainer ]} > - + - - - {text} + + + {text} - + From 2abd3508088da130c44ae9d121aa92ebd14cbd00 Mon Sep 17 00:00:00 2001 From: Kaique292 Date: Mon, 17 Apr 2023 14:52:08 -0300 Subject: [PATCH 3/6] fix: undefined value in object --- components/ToastManager.js | 6 +++--- components/styles.js | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/components/ToastManager.js b/components/ToastManager.js index fce79cc..46c781f 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') @@ -135,7 +135,7 @@ class ToastManager extends Component { width, height, style, - contentStyle, + contentStyle = customContentStyles, theme, } = this.props @@ -166,7 +166,7 @@ class ToastManager extends Component { backdropColor={backdropColor} backdropOpacity={backdropOpacity} hasBackdrop={hasBackdrop} - style={[styles.modalContainer, ...contentStyle?.modalContainer ]} + style={[styles.modalContainer, ...contentStyle?.modalContainer]} > Date: Mon, 17 Apr 2023 15:09:31 -0300 Subject: [PATCH 4/6] fix: interator bug --- components/ToastManager.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/components/ToastManager.js b/components/ToastManager.js index 46c781f..bfab364 100644 --- a/components/ToastManager.js +++ b/components/ToastManager.js @@ -135,10 +135,12 @@ class ToastManager extends Component { width, height, style, - contentStyle = customContentStyles, + contentStyle, theme, } = this.props + const allContentStyles = { ...customContentStyles, ...contentStyle } + const { isShow, animationStyle: stateAnimationStyle, @@ -166,12 +168,12 @@ class ToastManager extends Component { backdropColor={backdropColor} backdropOpacity={backdropOpacity} hasBackdrop={hasBackdrop} - style={[styles.modalContainer, ...contentStyle?.modalContainer]} + style={[styles.modalContainer, allContentStyles?.modalContainer]} > - + - - - {text} + + + {text} - + From 5828804bdc63dcb5b25787035bdff5634c996319 Mon Sep 17 00:00:00 2001 From: Kaique292 Date: Mon, 17 Apr 2023 16:01:08 -0300 Subject: [PATCH 5/6] featured: more props --- components/ToastManager.js | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/components/ToastManager.js b/components/ToastManager.js index bfab364..f259e7f 100644 --- a/components/ToastManager.js +++ b/components/ToastManager.js @@ -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 @@ -148,6 +154,8 @@ class ToastManager extends Component { icon, text, barWidth, + background, + textColor } = this.state return ( @@ -177,18 +185,18 @@ class ToastManager extends Component { { width, height, - backgroundColor: Colors[theme].back, + backgroundColor: background, top: this.position(), ...style, }, ]} > - + - {text} + {text} Date: Mon, 8 May 2023 16:55:13 -0300 Subject: [PATCH 6/6] fix: Added testID directly in message text for automated testing --- components/ToastManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/ToastManager.js b/components/ToastManager.js index f259e7f..e32b018 100644 --- a/components/ToastManager.js +++ b/components/ToastManager.js @@ -142,6 +142,7 @@ class ToastManager extends Component { height, style, contentStyle, + testID, theme, } = this.props @@ -196,7 +197,7 @@ class ToastManager extends Component { - {text} + {text}