0.0.12 • Published 2 years ago

alert-toast-react-native v0.0.12

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

react-native-alert-notification

Example Dialog Box

Theme LightTheme Dark

Example Toast Notification

Theme LightTheme Dark

Installation

- Installing:

yarn add react-native-alert-notification

- Installing dependencies:

  • For Native project:
yarn add react-native-safe-area-context

pod install
  • For Expo project:
expo install react-native-safe-area-context

Usage

import { ALERT_TYPE, Dialog, Root, Toast } from 'react-native-alert-notification';

<Root>
  <View>
    // dialog box
    <Button
      title={'dialog box'}
      onPress={() =>
        Dialog.show({
          type: ALERT_TYPE.SUCCESS,
          title: 'Success',
          textBody: 'Congrats! this is dialog box success',
          button: 'close',
        })
      }
    />
    // toast notification
    <Button
      title={'toast notification'}
      onPress={() =>
        Toast.show({
          type: ALERT_TYPE.SUCCESS,
          title: 'Success',
          textBody: 'Congrats! this is toast notification success',
        })
      }
    />
  </View>
</Root>;

Documentation:

Root Component

A React node that will be most likely wrapping your whole app.

NameDescriptionRequireDefaultType
themeselect theme light dark (by default is auto)auto'light','dark'
colorscustom colorsIColors, IColors
dialogConfigconfig dialog box global{closeOnOverlayTap:bool, autoClose:bool / number}
toastConfigconfig toast global{autoClose:bool / number}
type IProps = {
  dialogConfig?: Pick<IConfigDialog, 'closeOnOverlayTap' | 'autoClose'>;
  toastConfig?: Pick<IConfigToast, 'autoClose'>;
  theme?: 'light' | 'dark';
  colors?: [IColors, IColors] /** ['light_colors' , 'dark_colors'] */;
};
type IColors = {
  label: string;
  card: string;
  overlay: string;
  success: string;
  danger: string;
  warning: string;
};

Dialog Box Component

NameDescriptionRequireDefaultType
titleThe title textString
typeDefines the type ("Success", "Warning" or "Error")true"SUCCESS", "DANGER", "WARNING"
textBodyThe text bodyString
buttonname button (for hide button: undefined)String
autoCloseDefines time auto close dialog box in msfacebool / number
closeOnOverlayTapallow close if click in overlaytruebool
onPressButton(if not declared and isset button action is close)String() => void
onShowaction after end animation open() => void
onHideaction after end animation close() => void
type IConfig = {
  type: ALERT_TYPE;
  title?: string;
  textBody?: string;
  button?: string;
  autoClose?: number | boolean;
  closeOnOverlayTap?: boolean;
  onPressButton?: () => void;
  onShow?: () => void;
  onHide?: () => void;
};

Toast Notification Component

NameDescriptionRequireDefaultType
titleThe title textString
typeDefines the type ("Success", "Warning" or "Error")"SUCCESS", "DANGER", "WARNING"
textBodyThe text bodyString
autoCloseDefines time auto close dialog box in ms5000bool / number
onPressaction click in cardbool
onLongPressaction long click in card() => void
onShowevent after end animation open() => void
onHideevent after end animation close() => void
type IConfig = {
  type?: ALERT_TYPE;
  title?: string;
  textBody?: string;
  autoClose?: number | boolean;
  onPress?: () => void;
  onLongPress?: () => void;
  onShow?: () => void;
  onHide?: () => void;
};

For Close popup

// For Dialog Box
Dialog.hide();

// For Toast Notification
Toast.hide();

Author

Rodolphe Jerez | https://codingbyjerez.com

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.0

2 years ago