Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OptionsDialog.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // @flow
  2. import * as React from 'react';
  3. import {Button, Dialog, Paragraph, Portal} from 'react-native-paper';
  4. import {FlatList} from 'react-native';
  5. export type OptionsDialogButtonType = {
  6. title: string,
  7. onPress: () => void,
  8. };
  9. type PropsType = {
  10. visible: boolean,
  11. title: string,
  12. message: string,
  13. buttons: Array<OptionsDialogButtonType>,
  14. onDismiss: () => void,
  15. };
  16. class OptionsDialog extends React.PureComponent<PropsType> {
  17. getButtonRender = ({item}: {item: OptionsDialogButtonType}): React.Node => {
  18. return <Button onPress={item.onPress}>{item.title}</Button>;
  19. };
  20. keyExtractor = (item: OptionsDialogButtonType): string => item.title;
  21. render(): React.Node {
  22. const {props} = this;
  23. return (
  24. <Portal>
  25. <Dialog visible={props.visible} onDismiss={props.onDismiss}>
  26. <Dialog.Title>{props.title}</Dialog.Title>
  27. <Dialog.Content>
  28. <Paragraph>{props.message}</Paragraph>
  29. </Dialog.Content>
  30. <Dialog.Actions>
  31. <FlatList
  32. data={props.buttons}
  33. renderItem={this.getButtonRender}
  34. keyExtractor={this.keyExtractor}
  35. horizontal
  36. inverted
  37. />
  38. </Dialog.Actions>
  39. </Dialog>
  40. </Portal>
  41. );
  42. }
  43. }
  44. export default OptionsDialog;