GithubHelp home page GithubHelp logo

m-julius / react-native-modal-bottom-alert Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 3.36 MB

This package for react native, bottom alert with animation

JavaScript 40.42% Starlark 8.56% Java 27.77% Objective-C 19.78% Ruby 3.47%
react react-native alert bottom-alert react-native-alert react-native-modal lottie-react-native

react-native-modal-bottom-alert's Introduction

react-native-modal-bottom-alert

alt text

Getting Started

Installation

$ yarn add react-native-modal-bottom-alert lottie-react-native

Or

$ npm install react-native-modal-bottom-alert lottie-react-native --save

Basic Usage

import { BottomAlert } from 'react-native-modal-bottom-alert';

onOpenAlert() {
    this.modalBottom.onOpenAlert('info', 'This Title', 'This Message Example Info')
}

onOpenAlertButtonPressed() {
    // onOpenAlert parameters: type, title, message, function
    // parameter type: 'success', 'info', 'error'
    // parameter title: 'string'
    // parameter message: 'string'
    // parameter action: function, default null'
    this.modalBottom.onOpenAlert('error', 'This Title', 'This Message Example Error', () => console.log('This Button Try Again Pressed'))
}

return (
    <>
        <Button
          title={'Open Alert'}
          onPress={() => this.onOpenAlert()}
        />
        <Button
          title={'Open Alert Button Preesed With Action'}
          onPress={() => this.onOpenAlertButtonPressed()}
        />
        <BottomAlert
            ref={(ref) => this.modalBottom = ref}
        />
    </>
)

Set Global Alert

1. Add Modal Bottom Alert on Root App

// Root.js
import store from './reduxStore';
import React from 'react';
import { Provider } from 'react-redux';
import { useRefBottomAlert, BottomAlert } from 'react-native-modal-bottom-alert'; // Add This For Set Alert

let App = () => (
  <Navigator>
    <MainScreen />
    <OtherScreen />
  </Navigator>
);

const Root = () => (
  <Provider store={store}>
    <App />
    {/* Add This on root app */}
    <BottomAlert ref={(ref) => useRefBottomAlert(ref) }/> 
  </Provider>
);

2. Add on your screen or other function

// Screen.js
import React, { Component } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import { showBottomAlert } from 'react-native-modal-bottom-alert'; // Add This On Your Screen For Call Alert

export default class App extends Component {

  onOpenAlert() {
    showBottomAlert('info', 'This Title', 'This Message Example Info', () => this.onDonePress())
  }

  onDonePress = () => {
    console.log('Pressed')
  }


  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Modal Bottom Alert example</Text>
        <Button
          title={'Info'}
          onPress={() => this.onOpenAlert()}
        />
        <Button
          title={'Error'}
          onPress={() => showBottomAlert('error', 'This Title', 'This Message Example Error')}
        />
        <Button
          title={'Success'}
          onPress={() => showBottomAlert('success', 'This Title', 'This Message Example Success')}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'space-around',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  }
});

Props

Basic

Prop Type Description Default
statusBarTranslucent boolean Status Bar Translucent false
loopAnimation boolean Animation Loop For Lottie Icon false

Styling

Prop Type Description Default
styleTextTitle object Text Title Style -
styleTextMessage object Text Message Style -
styleTextButton object Text Button Style -
styleButton object Button Style -
styleContainerAlert object Container Style Alert -

react-native-modal-bottom-alert's People

Contributors

m-julius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.