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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 OptionsDialogButton = {
  6. title: string,
  7. onPress: () => void,
  8. }
  9. type Props = {
  10. visible: boolean,
  11. title: string,
  12. message: string,
  13. buttons: Array<OptionsDialogButton>,
  14. onDismiss: () => void,
  15. }
  16. class OptionsDialog extends React.PureComponent<Props> {
  17. getButtonRender = ({item}: { item: OptionsDialogButton }) => {
  18. return <Button
  19. onPress={item.onPress}>
  20. {item.title}
  21. </Button>;
  22. }
  23. keyExtractor = (item: OptionsDialogButton) => item.title;
  24. render() {
  25. return (
  26. <Portal>
  27. <Dialog
  28. visible={this.props.visible}
  29. onDismiss={this.props.onDismiss}>
  30. <Dialog.Title>{this.props.title}</Dialog.Title>
  31. <Dialog.Content>
  32. <Paragraph>{this.props.message}</Paragraph>
  33. </Dialog.Content>
  34. <Dialog.Actions>
  35. <FlatList
  36. data={this.props.buttons}
  37. renderItem={this.getButtonRender}
  38. keyExtractor={this.keyExtractor}
  39. horizontal={true}
  40. inverted={true}
  41. />
  42. </Dialog.Actions>
  43. </Dialog>
  44. </Portal>
  45. );
  46. }
  47. }
  48. export default OptionsDialog;