YRModel.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. backgroundColor: 'rgba(0, 0, 0, 0.5)'
  93. },
  94. innerContainer: {
  95. borderRadius: 3,
  96. alignItems: 'center',
  97. backgroundColor: '#fff',
  98. borderColor:"#fff",
  99. borderWidth:1,
  100. },
  101. header:{
  102. width:dialogWidth,
  103. flexDirection:'row',
  104. justifyContent:'flex-start',
  105. padding:8
  106. },
  107. content:{
  108. borderColor:"#82D2F8",
  109. },
  110. btnContainer:{
  111. flexDirection:"row",
  112. justifyContent:"flex-end",
  113. width:dialogWidth,
  114. borderTopWidth:1,
  115. paddingTop:10,
  116. borderTopColor:'#E7E7E7',
  117. alignItems:'center',
  118. padding:3
  119. },
  120. inputtext:{
  121. width:dialogWidth-20,
  122. margin:10,
  123. },
  124. textSure: {
  125. color:"#fff"
  126. },
  127. textClose:{
  128. color:"#82D2F8"
  129. },
  130. textContainer:{
  131. borderColor:"#fff",
  132. borderWidth:1,
  133. flexDirection:'row',
  134. justifyContent:"center",
  135. alignItems:"center",
  136. },
  137. btnClose:{
  138. borderColor:"#82D2F8",
  139. borderWidth:1,
  140. borderRadius:5,
  141. paddingTop:6,
  142. paddingBottom:6,
  143. paddingLeft:20,
  144. paddingRight:20,
  145. backgroundColor:"#fff"
  146. },
  147. btnSure:{
  148. borderColor:"#82D2F8",
  149. borderWidth:1,
  150. borderRadius:5,
  151. paddingTop:6,
  152. paddingBottom:6,
  153. paddingLeft:20,
  154. paddingRight:20,
  155. margin:10,
  156. backgroundColor:"#82D2F8"
  157. }
  158. });
  159. export default YRModel;