react-native-navigation的迁移库

OverlayAlert.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const React = require('react');
  2. const { Text, Button, View, Alert, Platform } = require('react-native');
  3. const { Navigation } = require('react-native-navigation');
  4. const { component } = require('../commons/Layouts');
  5. const Screens = require('./Screens');
  6. const {
  7. OVERLAY_ALERT_HEADER,
  8. DISMISS_BTN,
  9. SET_ROOT_BUTTON,
  10. SET_INTERCEPT_TOUCH
  11. } = require('../testIDs');
  12. class OverlayAlert extends React.PureComponent {
  13. render() {
  14. return (
  15. <View style={styles.root}>
  16. <Text style={styles.title} testID={OVERLAY_ALERT_HEADER}>Test view</Text>
  17. <Button title='Dismiss' testID={DISMISS_BTN} onPress={this.dismiss} />
  18. <Button title='Set Root' testID={SET_ROOT_BUTTON} onPress={this.setRoot} />
  19. <Button title='Set Intercept touch' testID={SET_INTERCEPT_TOUCH} onPress={this.setInterceptTouch} />
  20. </View>
  21. );
  22. }
  23. dismiss = () => Navigation.dismissOverlay(this.props.componentId);
  24. setRoot = () => Navigation.setRoot({ root: component(Screens.Pushed) });
  25. setInterceptTouch = () => Navigation.mergeOptions(this.props.componentId, {
  26. overlay: {
  27. interceptTouchOutside: false
  28. }
  29. });
  30. }
  31. const styles = {
  32. root: {
  33. position: 'absolute',
  34. backgroundColor: 'green',
  35. alignItems: 'center',
  36. height: 160,
  37. bottom: 0,
  38. left: 0,
  39. right: 0
  40. },
  41. title: {
  42. marginTop: 8
  43. }
  44. };
  45. module.exports = OverlayAlert;