react-native-navigation的迁移库

CustomTransitionOrigin.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. textFontFamily: 'HelveticaNeue-Italic',
  14. textFontSize: 16,
  15. largeTitle: false,
  16. translucent: true
  17. }
  18. };
  19. }
  20. render() {
  21. return (
  22. <View style={styles.root}>
  23. <Navigation.Element elementId="title1">
  24. <Text style={styles.h1}>Custom Transition Screen</Text>
  25. </Navigation.Element>
  26. <View style={{ flex: 1, justifyContent: 'flex-start' }}>
  27. <TouchableOpacity testID="shared_image1" activeOpacity={0.5} onPress={this.onClickNavigationIcon}>
  28. <Navigation.Element resizeMode="cover" elementId="image1">
  29. <Image resizeMode="cover" style={styles.gyroImage} source={require('../../img/400.jpeg')} />
  30. </Navigation.Element>
  31. </TouchableOpacity>
  32. <TouchableOpacity activeOpacity={0.5} onPress={this.onClickNavigationIcon}>
  33. <Navigation.Element elementId="image2">
  34. <Image style={styles.gyroImage} source={require('../../img/2048.jpeg')} />
  35. </Navigation.Element>
  36. </TouchableOpacity>
  37. <TouchableOpacity activeOpacity={0.5} onPress={this.onClickNavigationIcon}>
  38. <Navigation.Element elementId="image3">
  39. <Image style={styles.gyroImage} source={require('../../img/Icon-87.png')} />
  40. </Navigation.Element>
  41. </TouchableOpacity>
  42. <TouchableOpacity activeOpacity={0.5} onPress={this.onClickNavigationIcon}>
  43. <Navigation.Element elementId="image4">
  44. <Image style={styles.gyroImage} source={require('../../img/Icon-87.png')} />
  45. </Navigation.Element>
  46. </TouchableOpacity>
  47. </View>
  48. </View>
  49. );
  50. }
  51. onClickNavigationIcon() {
  52. Navigation.push(this.props.containerId, {
  53. name: 'navigation.playground.CustomTransitionDestination',
  54. customTransition: {
  55. animations: [
  56. { type: 'sharedElement', fromId: 'title1', toId: 'title2', startDelay: 0, springVelocity: 0.2, duration: 0.5 },
  57. { type: 'sharedElement', fromId: 'image1', toId: 'customDestinationImage', startDelay: 0, springVelocity: 0.9, springDamping: 0.9, duration: 0.8, interactivePop: true },
  58. { type: 'sharedElement', fromId: 'image2', toId: 'customDestinationImage2', startDelay: 0, duration: 0.8 },
  59. { fromId: 'image4', endY: 50, endX: 50, endAlpha: 0, startDelay: 0, duration: 0.8, springVelocity: 0.5 },
  60. { fromId: 'customDestinationParagraph', startY: 50, startAlpha: 0, endAlpha: 1, startDelay: 0, duration: 0.8 }
  61. ],
  62. duration: 0.8
  63. }
  64. });
  65. }
  66. }
  67. module.exports = CustomTransitionOrigin;
  68. const styles = {
  69. root: {
  70. alignItems: 'center',
  71. flexGrow: 1,
  72. backgroundColor: '#f5fcff'
  73. },
  74. h1: {
  75. fontSize: 24,
  76. textAlign: 'center',
  77. marginTop: 100
  78. },
  79. footer: {
  80. fontSize: 10,
  81. color: '#888',
  82. marginTop: 10
  83. },
  84. gyroImage: {
  85. marginTop: 10,
  86. width: 100,
  87. height: 100
  88. }
  89. };