react-native-navigation的迁移库

CustomTransitionOrigin.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const React = require('react');
  2. const { Component } = require('react');
  3. const { View, Text, Image, TouchableOpacity } = require('react-native');
  4. const { Navigation } = require('react-native-navigation');
  5. class CustomTransitionOrigin extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.onClickNavigationIcon = this.onClickNavigationIcon.bind(this);
  9. }
  10. static get options() {
  11. return {
  12. topBar: {
  13. title: {
  14. fontFamily: 'HelveticaNeue-Italic',
  15. fontSize: 16
  16. },
  17. largeTitle: {
  18. visible: false
  19. },
  20. translucent: true
  21. }
  22. };
  23. }
  24. render() {
  25. return (
  26. <View style={styles.root}>
  27. <Navigation.Element elementId='title1'>
  28. <Text style={styles.h1}>Custom Transition Screen</Text>
  29. </Navigation.Element>
  30. <View style={{ flex: 1, justifyContent: 'flex-start' }}>
  31. <TouchableOpacity testID='shared_image1' activeOpacity={0.5} onPress={this.onClickNavigationIcon}>
  32. <Navigation.Element resizeMode='cover' elementId='image1'>
  33. <Image resizeMode='cover' style={styles.gyroImage} source={require('../../img/400.jpeg')} />
  34. </Navigation.Element>
  35. </TouchableOpacity>
  36. <TouchableOpacity activeOpacity={0.5} onPress={this.onClickNavigationIcon}>
  37. <Navigation.Element elementId='image2'>
  38. <Image style={styles.gyroImage} source={require('../../img/2048.jpeg')} />
  39. </Navigation.Element>
  40. </TouchableOpacity>
  41. <TouchableOpacity activeOpacity={0.5} onPress={this.onClickNavigationIcon}>
  42. <Navigation.Element elementId='image3'>
  43. <Image style={styles.gyroImage} source={require('../../img/Icon-87.png')} />
  44. </Navigation.Element>
  45. </TouchableOpacity>
  46. <TouchableOpacity activeOpacity={0.5} onPress={this.onClickNavigationIcon}>
  47. <Navigation.Element elementId='image4'>
  48. <Image style={styles.gyroImage} source={require('../../img/Icon-87.png')} />
  49. </Navigation.Element>
  50. </TouchableOpacity>
  51. </View>
  52. </View>
  53. );
  54. }
  55. onClickNavigationIcon() {
  56. Navigation.push(this.props.componentId, {
  57. component: {
  58. name: 'navigation.playground.CustomTransitionDestination',
  59. options: {
  60. customTransition: {
  61. animations: [
  62. { type: 'sharedElement', fromId: 'title1', toId: 'title2', startDelay: 0, springVelocity: 0.2, duration: 0.5 },
  63. { type: 'sharedElement', fromId: 'image1', toId: 'customDestinationImage', startDelay: 0, springVelocity: 0.9,
  64. springDamping: 0.9, duration: 0.8, interactivePop: true },
  65. { type: 'sharedElement', fromId: 'image2', toId: 'customDestinationImage2', startDelay: 0, duration: 0.8 },
  66. { fromId: 'image4', x: { to: 50 }, y: { to: 50 }, endAlpha: 0, startDelay: 0, duration: 0.8, springVelocity: 0.5 },
  67. { fromId: 'customDestinationParagraph', startY: 50, startAlpha: 0, endAlpha: 1, startDelay: 0, duration: 0.8 }
  68. ],
  69. duration: 0.8
  70. }
  71. }
  72. }
  73. });
  74. }
  75. }
  76. module.exports = CustomTransitionOrigin;
  77. const styles = {
  78. root: {
  79. alignItems: 'center',
  80. flexGrow: 1,
  81. backgroundColor: '#f5fcff'
  82. },
  83. h1: {
  84. fontSize: 24,
  85. textAlign: 'center',
  86. marginTop: 100
  87. },
  88. footer: {
  89. fontSize: 10,
  90. color: '#888',
  91. marginTop: 10
  92. },
  93. gyroImage: {
  94. marginTop: 10,
  95. width: 100,
  96. height: 100
  97. }
  98. };