react-native-navigation的迁移库

Info.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import React, { Component } from 'react';
  2. import {
  3. ScrollView,
  4. TouchableOpacity,
  5. StyleSheet,
  6. Image,
  7. Text,
  8. View,
  9. Platform,
  10. ScrolView
  11. } from 'react-native';
  12. import { SharedElementTransition } from 'react-native-navigation';
  13. import * as Animatable from 'react-native-animatable';
  14. const SHOW_DURATION = 400;
  15. const HIDE_DURATION = 300;
  16. class InfoScreen extends Component {
  17. constructor(props) {
  18. super(props);
  19. this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
  20. this.state = {
  21. animationType: 'fadeInRight',
  22. animationDuration: SHOW_DURATION
  23. }
  24. }
  25. onNavigatorEvent(event) {
  26. if (event.id === 'backPress') {
  27. this.setState({
  28. animationType: 'fadeOutRight',
  29. animationDuration: HIDE_DURATION
  30. });
  31. this.props.navigator.pop();
  32. }
  33. }
  34. render() {
  35. return (
  36. <View style={styles.container}>
  37. {this._renderImage()}
  38. {this._renderContent()}
  39. </View>
  40. );
  41. }
  42. _renderImage() {
  43. return (
  44. <SharedElementTransition
  45. style={styles.imageContainer}
  46. sharedElementId={this.props.sharedImageId}
  47. showDuration={SHOW_DURATION}
  48. hideDuration={HIDE_DURATION}
  49. animateClipBounds={true}
  50. showInterpolation={
  51. {
  52. type: 'linear',
  53. easing: 'FastOutSlowIn'
  54. }
  55. }
  56. hideInterpolation={
  57. {
  58. type: 'linear',
  59. easing: 'FastOutSlowIn'
  60. }
  61. }
  62. >
  63. <Image
  64. style={styles.image}
  65. source={require('../../../../../img/beach.jpg')}
  66. />
  67. </SharedElementTransition>
  68. );
  69. }
  70. _renderContent() {
  71. return (
  72. <Animatable.View
  73. style={styles.content}
  74. duration={this.state.animationDuration}
  75. animation={this.state.animationType}
  76. useNativeDriver={true}
  77. >
  78. <Text style={styles.text}>Line 1</Text>
  79. <Text style={styles.text}>Line 2</Text>
  80. <Text style={styles.text}>Line 3</Text>
  81. <Text style={styles.text}>Line 4</Text>
  82. <Text style={styles.text}>Line 5</Text>
  83. <Text style={styles.text}>Line 6</Text>
  84. <Text style={styles.text}>Line 7</Text>
  85. <Text style={styles.text}>Line 8</Text>
  86. </Animatable.View>
  87. );
  88. }
  89. }
  90. const styles = StyleSheet.create({
  91. container: {
  92. flex: 1
  93. },
  94. content: {
  95. flex: 1,
  96. marginTop: 190,
  97. backgroundColor: 'white'
  98. },
  99. imageContainer: {
  100. position: 'absolute',
  101. top: 0,
  102. left: 0,
  103. right: 0,
  104. },
  105. image: {
  106. height: 190
  107. },
  108. text: {
  109. fontSize: 17,
  110. paddingVertical: 4,
  111. paddingLeft: 8
  112. }
  113. });
  114. export default InfoScreen;