react-native-navigation的迁移库

CustomDialog.js 1.2KB

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