Skip to content

v5.0.0

Compare
Choose a tag to compare
@testshallpass testshallpass released this 31 Jul 22:15
· 12 commits to main since this release

Changelog

Overview

<DropdownAlert /> has been refactored to a functional Typescript component. In doing so, there was opportunity to add props, change props and refocus to a single animation flow.

That single animation flow is to start off screen from the top then animate downward onto the screen. This resulted in a decision to remove the complexity behind and usage of the startDelta and endDelta props and where there was logic to keep it on screen.

Moreover, props were added that give more access and control over built-in components. In addition, the children prop was added and this provides the ability to build your own alert (BYOA), for example, <DropdownAlert><Text>{'Alert'}</Text></DropdownAlert>.

Lastly, prop name changes for the most part are to realign them with the associated type and component name. For example, wrapperStyle renamed to animatedViewStyle.

New

  • onDismissAutomatic callback function added and invoked when alert is dismissed by timeout the time can customized with dismissInterval prop or interval data property and defaults to 4000ms.
  • onDismissPanResponder callback function added and invoked when alert is dismissed by pan gesture.
  • onDismissProgrammatic callback function added and invoked when alert is dismissed by dismiss function prop.
  • onDismissCancel callback function added and invoked when alert is cancelled typically when using showCancel prop.
  • onDismissPress callback function added and invoked when alert is dismissed by tapping on alert view.
  • panResponderDismissDistance number added and is the distance on the y-axis the alert needs to travel to be dismissed.
  • animatedViewProps ViewProps added and allows control over props for Animated.View parent component.
  • alertTouchableOpacityProps TouchableOpacityProps added and allows control over props for TouchableOpacity child component.
  • safeViewProps ViewProps added and allows control over props for SafeView child component to TouchableOpacity.
  • textViewProps ViewProps added and allows control over props for View component that holds title and message text components.
  • imageProps ImageProps added and allows control over props for the Image left side child component to TouchableOpacity.
  • cancelTouchableOpacityProps TouchableOpacityProps added and allows control over props for the cancel TouchableOpacity component.
  • cancelImageProps ImageProps added and allows control over props for the cancel Image component.
  • children ReactNode added and if provided are rendered inside the Animated.View instead of the built-in components.
  • springAnimationConfig added and used in Animated.spring().
  • DropdownAlertType enum added.
  • DropdownAlertDismissAction enum added.
  • DropdownAlertColor enum added.
  • DropdownAlertData object type added.
  • DropdownAlertToValue enum added.
  • DropdownAlertImage enum added.
  • DropdownAlertTestID object added.

Changes

  • isOpen state variable removed. This results in the alert always rendered. It's visibility is based on top position of the Animated.View parent component.
  • Removed dependency prop-types.
  • imageSrc, infoImageSrc, warnImageSrc, errorImageSrc, successImageSrc propType changed to ImageSourcePropType.
  • infoColor, warnColor, errorColor, successColor, activeStatusBarBackgroundColor, inactiveStatusBarBackgroundColor propType changed to ColorValue.
  • imageStyle propType changed to ImageStyle.

Breaking changes

  • dropDownAlertRef.alertWithType(...) replaced by alert(data?: DropdownAlertData) promise function prop. payload removed and source is part of data.
  • dropDownAlertRef.closeAction() replaced by dismiss() function prop.
  • closeInterval renamed to dismissInterval.
  • startDelta and endDelta removed.
  • wrapperStyle renamed to animatedViewStyle and propType changed to ViewStyle.
  • containerStyle renamed to alertViewStyle and propType changed to ViewStyle.
  • contentContainerStyle renamed to safeViewStyle and propType changed to ViewStyle.
  • titleStyle renamed to titleTextStyle and propType changed to TextStyle.
  • messageStyle renamed to messageTextStyle and propType changed to TextStyle.
  • cancelBtnImageStyle renamed to cancelImageStyle and propType changed to ImageStyle.
  • titleNumOfLines renamed to titleNumberOfLines.
  • messageNumOfLines renamed to messageNumberOfLines.
  • onClose replaced by callback functions based on action taken. See: onDismissAutomatic, onDismissCancel, onDismissPress, onDismissPanResponder or onDismissProgrammatic.
  • onCancel renamed to onDismissCancel.
  • tapToCloseEnabled renamed to onDismissPressDisabled to match TouchableOpacity disabled prop and default changed to false.
  • useNativeDriver and isInteraction moved into springAnimationConfig object and defaults changed to false.
  • activeStatusBarStyle and inactiveStatusBarStyle propTypes changed to StatusBarStyle.
  • sensitivity renamed to panResponderMoveDistance. It serves as the distance gesture needs to travel before alert should move.
  • testID, accessibleLabel and accessible removed. Use new prop objects to set these attributes on the specific components.
  • onTap renamed to onDismissPress.
  • defaultContainer removed.
  • defaultTextContainer renamed to textViewStyle and propType changed to ViewStyle.
  • cancelBtnImageSrc renamed to cancelImageSrc and propType changed to ImageSourcePropType.