ScheduleFlatItem.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 ScheduleFlatItem extends Component<Props> {
  25. render() {
  26. return (
  27. <TouchableOpacity activeOpacity={1} onPress={this.props.onPress}>
  28. <View
  29. style={{
  30. backgroundColor: "white",
  31. width: this.props.width,
  32. height: this.props.height,
  33. alignItems: "center",
  34. justifyContent: "center",
  35. borderRadius: 30
  36. }}
  37. >
  38. <View
  39. style={{
  40. width: "95%",
  41. height: "80%",
  42. flexDirection: "row",
  43. alignItems: "center",
  44. justifyContent: "center"
  45. }}
  46. >
  47. <View
  48. style={{
  49. flex: 2.5,
  50. backgroundColor: this.props.data.typecolor,
  51. width: "95%",
  52. height: "70%",
  53. alignItems: "center",
  54. justifyContent: "center",
  55. borderRadius: 20
  56. }}
  57. >
  58. <Text style={{ color: "white" }}>{this.props.data.typename}</Text>
  59. </View>
  60. <View style={{ flex: 0.5 }} />
  61. <View
  62. style={{
  63. flex: 10,
  64. width: "100%",
  65. justifyContent: "center",
  66. height: "100%"
  67. }}
  68. >
  69. <Text style={{ textAlign: "left" }}>
  70. {this.props.data.videoname}
  71. </Text>
  72. </View>
  73. <View
  74. style={{
  75. flex: 1,
  76. width: "100%",
  77. height: "80%",
  78. alignItems: "center",
  79. justifyContent: "center",
  80. backgroundColor: "blue"
  81. }}
  82. >
  83. <Image
  84. style={{ width: 20, height: 20, backgroundColor: "blue" }}
  85. />
  86. </View>
  87. <View style={{ flex: 0.1 }} />
  88. </View>
  89. </View>
  90. </TouchableOpacity>
  91. );
  92. }
  93. }
  94. /**
  95. 使用方法
  96. <ScheduleFlatItem
  97. width={this.getWindowWidth() * 0.95}
  98. height={60}
  99. data={data}
  100. />
  101. */