UpgradeDialog.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, {Component} from 'react';
  2. import {Button, Dimensions, Modal, StyleSheet, Text, View} from 'react-native';
  3. const {width} = Dimensions.get('window');
  4. export default class UpgradeDialog extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. show: false
  9. }
  10. }
  11. render() {
  12. return (
  13. <Modal transparent={true}
  14. visible={this.state.show}
  15. onRequestClose={() => this.closeModal()}>
  16. <View style={styles.container}>
  17. <View style={styles.dialogContainer}>
  18. <View style={styles.textContainer}>
  19. <Text style={styles.titleText}>发现新版本!</Text>
  20. </View>
  21. <View style={{width: width / 1.5, height: 1, backgroundColor: '#ECECEC'}}/>
  22. <View style={[styles.textContainer, {marginTop: 10, marginBottom: 10, paddingLeft: 10, paddingRight: 10}]}>
  23. <Text style={styles.contentText}>{this.props.content}</Text>
  24. </View>
  25. <View style={styles.textContainer}>
  26. <View style={styles.btnContainer}>
  27. <Button color="#19AD17" title="  更新  " onPress={() => {
  28. this.closeModal()
  29. }}/>
  30. </View>
  31. <View style={styles.btnContainer}>
  32. <Button color="#888888" title="  取消  " onPress={() => {
  33. this.closeModal()
  34. }}/>
  35. </View>
  36. </View>
  37. </View>
  38. </View>
  39. </Modal>
  40. );
  41. }
  42. closeModal() {
  43. this.setState({show: false});
  44. }
  45. showModal() {
  46. this.setState({show: true});
  47. }
  48. }
  49. const styles = StyleSheet.create({
  50. container: {
  51. flex: 1,
  52. flexDirection: 'column',
  53. justifyContent: 'center',
  54. alignItems: 'center',
  55. backgroundColor: 'rgba(0, 0, 0, 0.5)'
  56. },
  57. dialogContainer: {
  58. backgroundColor: '#FFFFFF',
  59. width: width / 1.5,
  60. borderRadius: 5,
  61. },
  62. textContainer: {
  63. flexDirection: 'row',
  64. justifyContent: 'center',
  65. alignItems: 'center',
  66. paddingTop: 10,
  67. paddingBottom: 10,
  68. },
  69. titleText: {
  70. fontSize: 16,
  71. color: '#000000',
  72. },
  73. contentText: {
  74. fontSize: 16,
  75. color: '#000000',
  76. },
  77. btnContainer: {
  78. flex: 1,
  79. justifyContent: 'center',
  80. alignItems: 'center',
  81. }
  82. })