react-native-navigation的迁移库

Alert.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const React = require('react');
  2. const { PureComponent } = require('react');
  3. const { Text, Button, View, Platform } = require('react-native');
  4. const { Navigation } = require('react-native-navigation');
  5. const testIDs = require('../testIDs');
  6. class Alert extends PureComponent {
  7. render() {
  8. return (
  9. <View style={styles.root} key={'overlay'}>
  10. <View style={styles.alert}>
  11. <Text style={styles.h1} testID={testIDs.DIALOG_HEADER}>{this.props.title}</Text>
  12. <View style={styles.buttonContainer}>
  13. <Button title='OK' testID={testIDs.OK_BUTTON} onPress={() => this.onCLickOk()} />
  14. </View>
  15. </View>
  16. </View>
  17. );
  18. }
  19. onCLickOk() {
  20. Navigation.dismissOverlay(this.props.componentId);
  21. }
  22. }
  23. const styles = {
  24. root: {
  25. justifyContent: 'center',
  26. alignItems: 'center',
  27. flex: 1
  28. },
  29. alert: {
  30. alignItems: 'center',
  31. backgroundColor: '#efefef',
  32. width: 250,
  33. height: 100,
  34. elevation: 4
  35. },
  36. buttonContainer: {
  37. width: '50%',
  38. alignItems: 'center'
  39. },
  40. h1: {
  41. fontSize: 18,
  42. margin: 10
  43. }
  44. };
  45. module.exports = Alert;