react-native-dropdownalert
Advanced tools
Comparing version 4.5.0 to 4.5.1
@@ -66,3 +66,3 @@ # Props | ||
| `defaultContainer` | Object | Style for inner view container (**override paddingTop with this**) | `{ flexDirection: 'row', padding: 8 }` | | ||
| `defaultTextContainer` | Object | Style for inner text container (holds title and message) | `{ flex: 1, paddingHorizontal: 8 }` | | ||
| `defaultTextContainer` | Object | Style for inner text container (holds title and message) | `{ flex: 1, padding: 8 }` | | ||
| `wrapperStyle` | Object | styles for the view that wraps the container. For [React Native Web](https://github.com/necolas/react-native-web) support you might want to set this to `{ position: 'fixed' }` | `null` | | ||
@@ -69,0 +69,0 @@ | `containerStyle` | Object | styles for container for custom type only | `{ flexDirection: 'row', backgroundColor: '#202020' }` | |
@@ -170,3 +170,3 @@ import React, {Component} from 'react'; | ||
flex: 1, | ||
paddingHorizontal: 8, | ||
padding: 8, | ||
}, | ||
@@ -198,3 +198,2 @@ translucent: false, | ||
this.state = { | ||
animationValue: new Animated.Value(0), | ||
isOpen: false, | ||
@@ -214,2 +213,3 @@ topValue: 0, | ||
this.queue = new Queue(); | ||
this.animationValue = new Animated.Value(0); | ||
} | ||
@@ -392,3 +392,3 @@ componentWillUnmount() { | ||
const {useNativeDriver, isInteraction} = this.props; | ||
Animated.spring(this.state.animationValue, { | ||
Animated.spring(this.animationValue, { | ||
toValue: toValue, | ||
@@ -519,6 +519,9 @@ duration: duration, | ||
}; | ||
_renderTitle = () => { | ||
_renderTitle = (title) => { | ||
if (this.props.renderTitle) { | ||
return this.props.renderTitle(this.props, this.alertData); | ||
} | ||
if (!title || title.length === 0) { | ||
return null; | ||
} | ||
const {titleTextProps, titleStyle, titleNumOfLines} = this.props; | ||
@@ -530,10 +533,13 @@ return ( | ||
numberOfLines={titleNumOfLines}> | ||
{this.alertData.title} | ||
{title} | ||
</Text> | ||
); | ||
}; | ||
_renderMessage = () => { | ||
_renderMessage = (message) => { | ||
if (this.props.renderMessage) { | ||
return this.props.renderMessage(this.props, this.alertData); | ||
} | ||
if (!message || message.length === 0) { | ||
return null; | ||
} | ||
const {messageTextProps, messageStyle, messageNumOfLines} = this.props; | ||
@@ -545,3 +551,3 @@ return ( | ||
numberOfLines={messageNumOfLines}> | ||
{this.alertData.message} | ||
{message} | ||
</Text> | ||
@@ -593,4 +599,4 @@ ); | ||
} = this.props; | ||
const {animationValue, topValue, height} = this.state; | ||
const {type, payload} = this.alertData; | ||
const {topValue, height} = this.state; | ||
const {type, payload, title, message} = this.alertData; | ||
let style = this.getStyleForType(type); | ||
@@ -616,3 +622,3 @@ let imageSrc = this.getSourceForType(type); | ||
{ | ||
translateY: animationValue.interpolate({ | ||
translateY: this.animationValue.interpolate({ | ||
inputRange: [0, 1], | ||
@@ -657,4 +663,4 @@ outputRange, | ||
<View style={StyleSheet.flatten(defaultTextContainer)}> | ||
{this._renderTitle()} | ||
{this._renderMessage()} | ||
{this._renderTitle(title)} | ||
{this._renderMessage(message)} | ||
</View> | ||
@@ -661,0 +667,0 @@ {this._renderCancel(showCancel)} |
@@ -44,6 +44,6 @@ import React, {ReactNode} from 'react'; | ||
defaultTextContainer?: object | number; | ||
renderImage?(props: DropdownAlertProps, state: {type: string}): ReactNode; | ||
renderCancel?(props: DropdownAlertProps, state: {type: string}): ReactNode; | ||
renderTitle?(props: DropdownAlertProps, state: {type: string}): ReactNode; | ||
renderMessage?(props: DropdownAlertProps, state: {type: string}): ReactNode; | ||
renderImage?(props: DropdownAlertProps, state: AlertDataType): ReactNode; | ||
renderCancel?(props: DropdownAlertProps, state: AlertDataType): ReactNode; | ||
renderTitle?(props: DropdownAlertProps, state: AlertDataType): ReactNode; | ||
renderMessage?(props: DropdownAlertProps, state: AlertDataType): ReactNode; | ||
testID?: string; | ||
@@ -50,0 +50,0 @@ accessibilityLabel?: string; |
{ | ||
"name": "react-native-dropdownalert", | ||
"version": "4.5.0", | ||
"version": "4.5.1", | ||
"description": "A simple alert to notify users about new chat messages, something went wrong or everything is ok.", | ||
@@ -5,0 +5,0 @@ "main": "DropdownAlert.js", |
57359
835