ScheduleFlatItem.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. var width = Dimensions.get("window").width;
  15. var height = Dimensions.get("window").height;
  16. export default class ScheduleFlatItem extends Component {
  17. render() {
  18. return (
  19. <TouchableOpacity activeOpacity={1} onPress={this.props.onPress}>
  20. <View
  21. style={{
  22. backgroundColor: "white",
  23. width: this.props.width,
  24. height: this.props.height,
  25. alignItems: "center",
  26. justifyContent: "center",
  27. borderRadius: 30
  28. }}
  29. >
  30. <View
  31. style={{
  32. width: "95%",
  33. height: "80%",
  34. flexDirection: "row",
  35. alignItems: "center",
  36. justifyContent: "center"
  37. }}
  38. >
  39. <View
  40. style={{
  41. flex: 2.5,
  42. backgroundColor: this.props.data.subColor,
  43. width: "100%",
  44. height: "70%",
  45. alignItems: "center",
  46. justifyContent: "center",
  47. borderRadius: 20
  48. }}
  49. >
  50. <Text style={{ color: "white",fontSize: 12, }}>{this.props.data.subTitle}</Text>
  51. </View>
  52. <View style={{ flex: 0.2 }} />
  53. <View
  54. style={{
  55. flex: 10,
  56. width: "100%",
  57. justifyContent: "center",
  58. height: "100%"
  59. }}
  60. >
  61. <Text style={{ textAlign: "left" }}>
  62. {this.props.data.title}
  63. </Text>
  64. </View>
  65. <View
  66. style={{
  67. flex: 1,
  68. width: "100%",
  69. height: "80%",
  70. alignItems: "center",
  71. justifyContent: "center"
  72. }}
  73. >
  74. <Image
  75. style={{ width: 20, height: 20 }}
  76. source={require("../images/schedulePage/schedule_item_right.png")}
  77. />
  78. </View>
  79. <View style={{ flex: 0.1 }} />
  80. </View>
  81. </View>
  82. </TouchableOpacity>
  83. );
  84. }
  85. }
  86. /**
  87. 使用方法
  88. <ScheduleFlatItem
  89. width={this.getWindowWidth() * 0.95}
  90. height={60}
  91. data={data}
  92. />
  93. */