YRModel.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. import React from 'react';
  2. import {
  3. Modal,
  4. Text,
  5. TouchableHighlight,
  6. TouchableOpacity,
  7. View,
  8. StyleSheet,
  9. Image,
  10. TextInput
  11. } from 'react-native';
  12. let Dimensions = require('Dimensions');
  13. let screenWidth = Dimensions.get('window').width;
  14. let dialogWidth = screenWidth - 40;
  15. class YRModel extends React.Component {
  16. constructor(props) {
  17. super(props);
  18. this.state = {
  19. name: 'YRModel',
  20. modalVisible: false
  21. };
  22. }
  23. setModalVisible(visible) {
  24. this.setState({modalVisible: visible});
  25. }
  26. componentDidMount() {
  27. }
  28. render() {
  29. /*自定义对话框*/
  30. return (<View style={styles.page}>
  31. <Modal animationType={"slide"}
  32. transparent={true}
  33. visible={this.state.modalVisible}
  34. onRequestClose={() => {
  35. this.setModalVisible(false)
  36. }}>
  37. {/* <TouchableOpacity style={{flex:1}} >*/}
  38. <View style={styles.container}>
  39. <View style={styles.innerContainer}>
  40. <View style={styles.header}>
  41. <Image
  42. style={{width:22,height:22}}
  43. source={require('../../assets/images/icon_delete.png')}></Image>
  44. </View>
  45. <View style={styles.content}>
  46. <TextInput
  47. style={styles.inputtext}
  48. placeholder="Type here!"
  49. />
  50. </View>
  51. <View style={styles.btnContainer}>
  52. <TouchableHighlight
  53. style={styles.btnClose}
  54. underlayColor="#fff"
  55. onPress={() => {
  56. this.setModalVisible(!this.state.modalVisible)
  57. }}>
  58. <Text style={styles.textClose}>重置</Text>
  59. </TouchableHighlight>
  60. <TouchableHighlight
  61. style={styles.btnSure}
  62. underlayColor="#82D2F8"
  63. onPress={() => {
  64. this.setModalVisible(!this.state.modalVisible)
  65. }}>
  66. <Text style={styles.textSure}>确认</Text>
  67. </TouchableHighlight>
  68. </View>
  69. </View>
  70. </View>
  71. {/* </TouchableOpacity>*/}
  72. </Modal>
  73. <TouchableHighlight
  74. underlayColor="#1FB579"
  75. style={styles.textContainer} onPress={() => {
  76. this.setModalVisible(true)
  77. }}>
  78. <Text style={{ fontSize:22}}>弹出对话框</Text>
  79. </TouchableHighlight>
  80. </View>)
  81. }
  82. }
  83. const styles = StyleSheet.create({
  84. page:{
  85. flex: 1,
  86. justifyContent: 'center',
  87. },
  88. container: {
  89. flex: 1,
  90. justifyContent: 'center',
  91. padding: 20,
  92. borderColor:"#E7E7E7",
  93. borderWidth:1,
  94. backgroundColor: 'rgba(0, 0, 0, 0.5)'
  95. },
  96. innerContainer: {
  97. borderRadius: 3,
  98. alignItems: 'center',
  99. backgroundColor: '#fff',
  100. borderColor:"#fff",
  101. borderWidth:1,
  102. },
  103. header:{
  104. width:dialogWidth,
  105. flexDirection:'row',
  106. justifyContent:'flex-start',
  107. padding:8
  108. },
  109. content:{
  110. borderColor:"#82D2F8",
  111. },
  112. btnContainer:{
  113. flexDirection:"row",
  114. justifyContent:"flex-end",
  115. width:dialogWidth,
  116. borderTopWidth:1,
  117. paddingTop:10,
  118. borderTopColor:'#E7E7E7',
  119. alignItems:'center',
  120. padding:3
  121. },
  122. inputtext:{
  123. width:dialogWidth-20,
  124. margin:10,
  125. },
  126. textSure: {
  127. color:"#fff"
  128. },
  129. textClose:{
  130. color:"#82D2F8"
  131. },
  132. textContainer:{
  133. borderColor:"#fff",
  134. borderWidth:1,
  135. flexDirection:'row',
  136. justifyContent:"center",
  137. alignItems:"center",
  138. },
  139. btnClose:{
  140. borderColor:"#82D2F8",
  141. borderWidth:1,
  142. borderRadius:5,
  143. paddingTop:6,
  144. paddingBottom:6,
  145. paddingLeft:20,
  146. paddingRight:20,
  147. backgroundColor:"#fff"
  148. },
  149. btnSure:{
  150. borderColor:"#82D2F8",
  151. borderWidth:1,
  152. borderRadius:5,
  153. paddingTop:6,
  154. paddingBottom:6,
  155. paddingLeft:20,
  156. paddingRight:20,
  157. margin:10,
  158. backgroundColor:"#82D2F8"
  159. }
  160. });
  161. export default YRModel;