react-native-navigation的迁移库

CustomDialog.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const React = require('react');
  2. const { PureComponent } = require('react');
  3. const { Text, Button, View, Alert, Platform } = require('react-native');
  4. const { Navigation } = require('react-native-navigation');
  5. const testIDs = require('../testIDs');
  6. class CustomDialog extends PureComponent {
  7. render() {
  8. return (
  9. <View style={styles.root}>
  10. <Text style={styles.h1} testID={testIDs.DIALOG_HEADER}>Test view</Text>
  11. <Button title='OK' testID={testIDs.OK_BUTTON} onPress={() => this.onCLickOk()} />
  12. </View>
  13. );
  14. }
  15. didDisappear() {
  16. if (Platform.OS === 'android') {
  17. Alert.alert('Overlay disappeared');
  18. }
  19. }
  20. onCLickOk() {
  21. Navigation.dismissOverlay(this.props.componentId);
  22. }
  23. }
  24. const styles = {
  25. root: {
  26. backgroundColor: 'green',
  27. justifyContent: 'center',
  28. alignItems: 'center',
  29. height: 100,
  30. bottom: 0,
  31. position: 'absolute',
  32. left: 0,
  33. right: 0
  34. },
  35. h1: {
  36. fontSize: 24,
  37. textAlign: 'center',
  38. margin: 10
  39. },
  40. h2: {
  41. fontSize: 12,
  42. textAlign: 'center',
  43. margin: 10
  44. },
  45. footer: {
  46. fontSize: 10,
  47. color: '#888',
  48. marginTop: 10
  49. }
  50. };
  51. module.exports = CustomDialog;