{"size": 1702, "ext": "js", "max_stars_repo_path": "Example/App.js", "max_stars_repo_name": "KZen-networks/react-native-dropdownalert", "max_stars_repo_stars_event_min_datetime": "2021-05-28T01:07:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-28T01:07:22.000Z", "max_issues_repo_path": "Example/App.js", "max_issues_repo_name": "ZenGo-X/react-native-dropdownalert", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Example/App.js", "max_forks_repo_name": "ZenGo-X/react-native-dropdownalert", "max_forks_repo_forks_event_min_datetime": "2019-11-28T13:18:21.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-28T13:18:21.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 25.7878787879, "max_line_length": 111, "alphanum_fraction": 0.5793184489}
import React, { Component } from 'react';
import { StyleSheet, SafeAreaView } from 'react-native';
import DropdownAlert from 'react-native-dropdownalert';
import { MAIN_CUSTOM_COLOR, MAIN_BACKGROUND_COLOR } from './constants';
import List from './List';

export default class App extends Component {
  constructor(props) {
    super(props);
  }
  onSelect({ item, index }) {
    switch (item.type) {
      case 'close':
        this._close();
        break;
      default:
        const random = Math.floor(Math.random() * 4000 + 1);
        const title = `${item.type} in ${random} milliseconds`;
        this.dropDownAlertRef.alertWithType(
          item.type,
          title,
          item.message,
          { message: 'HelloWorld', source: 'https://facebook.github.io/react-native/docs/assets/favicon.png' },
          random
        );
    }
  }
  _close = () => {
    this.dropdown.closeAction();
  };
  _onClose = data => {
    console.log(data);
  };
  _onCancel = data => {
    console.log(data);
  };
  _onTap = data => {
    console.log(data);
  };
  render() {
    return (
      <SafeAreaView style={styles.container}>
        <List onSelect={({ item, index }) => this.onSelect({ item, index })} />
        <DropdownAlert
          ref={ref => this.dropDownAlertRef = ref}
          containerStyle={{
            backgroundColor: MAIN_CUSTOM_COLOR,
          }}
          showCancel={true}
          onCancel={this._onCancel}
          onTap={this._onTap}
          messageNumOfLines={0}
          onClose={this._onClose}
        />
      </SafeAreaView>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: MAIN_BACKGROUND_COLOR,
  },
});
