RevisionAge.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. const instructions = Platform.select({
  15. ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
  16. android:
  17. "Double tap R on your keyboard to reload,\n" +
  18. "Shake or press menu button for dev menu"
  19. });
  20. /** 因没有图,所以Image先用颜色代替,有图可替换 */
  21. type Props = {};
  22. var width = Dimensions.get("window").width;
  23. var height = Dimensions.get("window").height;
  24. export default class RevisionAge extends Component<Props> {
  25. render() {
  26. return (
  27. <TouchableOpacity activeOpacity={1} onPress={this.props.onPress}>
  28. <View
  29. style={{
  30. width: this.props.width,
  31. height: this.props.height,
  32. flexDirection: "row",
  33. backgroundColor: "white",
  34. alignItems: "center",
  35. justifyContent: "center",
  36. borderRadius: 30
  37. }}
  38. >
  39. <View style={{ flex: 1 }} />
  40. <View
  41. style={{
  42. flex: 4,
  43. flexDirection: "row",
  44. alignItems: "center",
  45. justifyContent: "center"
  46. }}
  47. >
  48. <Image
  49. // source={{
  50. // uri:
  51. // "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
  52. // }}
  53. style={{
  54. width: 20,
  55. height: 20,
  56. backgroundColor: "blue"
  57. }}
  58. />
  59. <Text
  60. style={{
  61. fontSize: 18,
  62. marginLeft: 10,
  63. fontWeight: "bold",
  64. color: "#151515"
  65. }}
  66. >
  67. {this.props.textss}
  68. </Text>
  69. </View>
  70. </View>
  71. </TouchableOpacity>
  72. );
  73. }
  74. }
  75. /**
  76. 使用方法
  77. <RevisionAge
  78. width={150}
  79. height={50}
  80. textss="学前"
  81. onPress={() => this.toWebPage("这里写json......")}
  82. />
  83. */