CourseTitle.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React, { Component } from "react";
  2. import {
  3. Platform,
  4. StyleSheet,
  5. Text,
  6. View,
  7. Image,
  8. TouchableOpacity,
  9. ImageBackground,
  10. Button,
  11. Dimensions,
  12. DeviceEventEmitter
  13. } from "react-native";
  14. /** 因没有图,所以Image先用颜色代替,有图可替换 */
  15. const instructions = Platform.select({
  16. ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
  17. android:
  18. "Double tap R on your keyboard to reload,\n" +
  19. "Shake or press menu button for dev menu"
  20. });
  21. type Props = {};
  22. var width = Dimensions.get("window").width;
  23. var height = Dimensions.get("window").height;
  24. export default class CourseTitle extends Component<Props> {
  25. render() {
  26. return (
  27. <View
  28. style={{
  29. width: this.props.width,
  30. height: this.props.height,
  31. flexDirection: "row"
  32. }}
  33. >
  34. <View style={{ flex: 1 }}>
  35. <TouchableOpacity
  36. //返回
  37. activeOpacity={1}
  38. onPress={() => this.props.navigation.goBack()}
  39. >
  40. <Image style={{ width: 20, height: 20, backgroundColor: "blue" }} />
  41. </TouchableOpacity>
  42. </View>
  43. <View style={{ flex: 5 }}>
  44. <Text>{this.props.title}</Text>
  45. </View>
  46. <View style={{ flex: 1 }}>
  47. <TouchableOpacity
  48. //分享
  49. activeOpacity={1}
  50. onPress={() => this.props.navigation.goBack()}
  51. >
  52. <Image style={{ width: 20, height: 20, backgroundColor: "blue" }} />
  53. </TouchableOpacity>
  54. </View>
  55. </View>
  56. );
  57. }
  58. }
  59. /**
  60. 使用方法
  61. <CourseTitle
  62. uri="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&amp;fm=26&amp;gp=0.jpg"
  63. width={400}
  64. height={150}
  65. username="卡通笨笨熊"
  66. flowerNumber="123234"
  67. onPress={() => this.toNextPage("MainActivity")}
  68. />
  69. */