Giter Club home page Giter Club logo

react-native-dropdownalert's Introduction

react-native-dropdownalert

Platform npm version npm version Build Status License

A way to display bits of information to users. You can try 1 of 3 pre-defined types or roll your own. The user can tap the alert to close it or pan gesture up or close automatically after 4 seconds, see closeInterval prop.

Installation

npm i react-native-dropdownalert --save

Demo

screenshot

Usage

import DropdownAlert from 'react-native-dropdownalert'
// ...
render() {
  return (
    <View>
      // !!! Make sure it's the last component in your document tree.
      <DropdownAlert ref={(ref) => this.dropdown = ref} onClose={(data) => this.onClose(data)} />
    </View>
  )
}
// ...
handleServerResponse(err, response) {
  if (err != null) {
    this.dropdown.alertWithType('error', 'Error', err)
  }
}
// ...
onClose(data) {
  // data = {type, title, message}
}
// ...

Types

| info | warn | error | custom | ------------ | ------------- | ------------ |------------ |------------ | |screenshot |screenshot |screenshot|screenshot

Props

Name Type Description Default
closeInterval Number dismiss alert at a certain time in milliseconds 4000
imageSrc String or Number local or network source null
startDelta Number where the container starts (changes based on container height onLayout) -100
endDelta Number where the container ends 0
onClose Function Fires when alert closes either by user or closeInterval Returns: data = {type, title, message} null
containerStyle View.propTypes.style styles for container for custom type only { padding: 16, flexDirection: 'row' }
titleStyle Text.propTypes.style styles for title for all types { fontSize: 16, textAlign: 'left', fontWeight: 'bold', color: 'white', backgroundColor: 'transparent' }
messageStyle Text.propTypes.style styles for message for all types { fontSize: 14, textAlign: 'left', fontWeight: 'bold', color: 'white', backgroundColor: 'transparent' }
imageStyle Image.propTypes.style styles for image for all types { padding: 8, width: 36, height: 36, alignSelf: 'center' }
cancelBtnImageStyle Image.propTypes.style styles for image for all types { padding: 8, width: 36, height: 36, alignSelf: 'center' }
cancelBtnImageSrc String or Number local or network source require('./assets/cancel.png')
titleNumOfLines Number number of lines 1
messageNumOfLines Number number of lines 3
onCancel Function Cancel button action. Returns: data = {type, title, message} null
showCancel Bool whether or not to show cancel button false

Inspired by: RKDropdownAlert

react-native-dropdownalert's People

Contributors

testshallpass avatar

Watchers

James Cloos avatar  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.