RuleModal.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { Ionicons } from '@expo/vector-icons';
  2. import { ImageBackground } from 'expo-image';
  3. import React, { forwardRef, useImperativeHandle, useState } from 'react';
  4. import {
  5. Modal,
  6. StyleSheet,
  7. Text,
  8. TouchableOpacity,
  9. View
  10. } from 'react-native';
  11. import { Images } from '@/constants/images';
  12. export interface RuleModalRef {
  13. show: () => void;
  14. close: () => void;
  15. }
  16. export const RuleModal = forwardRef<RuleModalRef>((_, ref) => {
  17. const [visible, setVisible] = useState(false);
  18. useImperativeHandle(ref, () => ({
  19. show: () => setVisible(true),
  20. close: () => setVisible(false),
  21. }));
  22. return (
  23. <Modal visible={visible} transparent animationType="fade" onRequestClose={() => setVisible(false)}>
  24. <View style={styles.overlay}>
  25. <View style={styles.contentContainer}>
  26. <ImageBackground
  27. source={{ uri: Images.mine.dialogContentBg }}
  28. style={styles.bgContainer}
  29. resizeMode="stretch"
  30. >
  31. <View style={styles.textContent}>
  32. <Text style={styles.text}>1.房间仅可用于免费赠送手办或其它礼品</Text>
  33. <Text style={styles.text}>2.您可以查看完整版《用户协议》和《隐私政策》 以便了解我们收集、使用、存储信息的情况,以及对信息的保护措施</Text>
  34. <Text style={styles.text}>3.不支持设置私密房间</Text>
  35. <Text style={styles.text}>4.参与热度仅代表房间热度,不代表具体人数</Text>
  36. </View>
  37. </ImageBackground>
  38. <View style={styles.closeContainer}>
  39. <TouchableOpacity onPress={() => setVisible(false)} style={styles.closeBtn}>
  40. <Ionicons name="close" size={20} color="#444" />
  41. </TouchableOpacity>
  42. </View>
  43. </View>
  44. </View>
  45. </Modal>
  46. );
  47. });
  48. const styles = StyleSheet.create({
  49. overlay: {
  50. flex: 1,
  51. backgroundColor: 'rgba(0,0,0,0.6)',
  52. justifyContent: 'center',
  53. alignItems: 'center',
  54. },
  55. contentContainer: {
  56. width: '100%',
  57. alignItems: 'center',
  58. },
  59. bgContainer: {
  60. width: 300, // 600rpx approx
  61. height: 300, // 600rpx approx
  62. justifyContent: 'flex-start',
  63. paddingHorizontal: 25, // 50rpx
  64. paddingTop: 75, // 150rpx
  65. },
  66. textContent: {
  67. width: '100%',
  68. },
  69. text: {
  70. fontSize: 12,
  71. color: '#333',
  72. marginBottom: 8,
  73. lineHeight: 18,
  74. },
  75. closeContainer: {
  76. marginTop: 20,
  77. alignItems: 'center',
  78. },
  79. closeBtn: {
  80. width: 32,
  81. height: 32,
  82. borderRadius: 16,
  83. backgroundColor: '#D8D8D8',
  84. justifyContent: 'center',
  85. alignItems: 'center',
  86. },
  87. });