CatchRuleModal.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { Images } from '@/constants/images';
  2. import { ImageBackground } from 'expo-image';
  3. import React, { forwardRef, useImperativeHandle, useState } from 'react';
  4. import { Image, Modal, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
  5. export interface CatchRuleModalRef {
  6. show: () => void;
  7. close: () => void;
  8. }
  9. export const CatchRuleModal = forwardRef<CatchRuleModalRef>((_, ref) => {
  10. const [visible, setVisible] = useState(false);
  11. useImperativeHandle(ref, () => ({
  12. show: () => setVisible(true),
  13. close: () => setVisible(false),
  14. }));
  15. if (!visible) return null;
  16. return (
  17. <Modal visible={visible} transparent animationType="fade" onRequestClose={() => setVisible(false)}>
  18. <View style={styles.overlay}>
  19. <View style={styles.contentContainer}>
  20. <ImageBackground
  21. source={{ uri: Images.welfare.qijiWelfareDollRule }}
  22. style={styles.bgContainer}
  23. resizeMode="stretch"
  24. >
  25. <View style={styles.titleContainer}>
  26. <Text style={styles.title}>扭蛋机 玩法规则</Text>
  27. </View>
  28. <View style={styles.textContent}>
  29. <Text style={styles.textTitle}>扭蛋机规则</Text>
  30. <Text style={styles.text}>一个源力币可以扭动一次旋钮,按照需求可选择“扭一次”或“扭五次”,扭动后随机掉落捣蛋机内物品。</Text>
  31. <Text style={styles.textTitle}>源力币获取途径</Text>
  32. <Text style={styles.text}>在宝箱中购买超神或欧皇款后,系统自动发放源力市。</Text>
  33. <Text style={styles.text}>(超神款2个,欧皇款1个)</Text>
  34. </View>
  35. </ImageBackground>
  36. <TouchableOpacity onPress={() => setVisible(false)} style={styles.closeBtn}>
  37. <Image source={{ uri: Images.mine.dialogClose }} style={styles.closeIcon} />
  38. </TouchableOpacity>
  39. </View>
  40. </View>
  41. </Modal>
  42. );
  43. });
  44. const styles = StyleSheet.create({
  45. overlay: {
  46. flex: 1,
  47. backgroundColor: 'rgba(0,0,0,0.6)',
  48. justifyContent: 'center',
  49. alignItems: 'center',
  50. },
  51. contentContainer: {
  52. width: '100%',
  53. alignItems: 'center',
  54. },
  55. bgContainer: {
  56. width: 357, // 714rpx
  57. height: 252, // 504rpx
  58. paddingTop: 32, // 64rpx
  59. alignItems: 'center',
  60. },
  61. titleContainer: {
  62. alignItems: 'center',
  63. marginBottom: 10,
  64. },
  65. title: {
  66. fontSize: 18,
  67. fontWeight: 'bold',
  68. color: 'rgba(255,255,255,0.68)',
  69. textShadowColor: '#07004A',
  70. textShadowOffset: { width: 1, height: 1 },
  71. textShadowRadius: 1,
  72. },
  73. textContent: {
  74. paddingHorizontal: 15,
  75. marginTop: 10,
  76. width: '100%',
  77. },
  78. textTitle: {
  79. textAlign: 'center',
  80. fontSize: 16,
  81. fontWeight: 'bold',
  82. color: '#000',
  83. marginVertical: 5,
  84. },
  85. text: {
  86. fontSize: 12,
  87. color: '#000',
  88. lineHeight: 18,
  89. marginBottom: 4,
  90. },
  91. closeBtn: {
  92. marginTop: 20,
  93. },
  94. closeIcon: {
  95. width: 30,
  96. height: 30,
  97. }
  98. });