React UI设计黑色蒙层#000000 80%,首次打开弹出,点击图片可以关闭

javascript 复制代码
import { MainProps } from "@src/component/MaskPannel";
import React, { useState } from "react";
import { StyleSheet, View, TouchableOpacity, Image, Text } from 'react-native';

import { UI } from 'xxxxxx'; // 可以自定义Icon图库
const { Icon } = UI;

const MaskPannel: React.FC<MainProps> = (props: MainProps) => {
    const [visible, setVisible] = useState(true);

    const handleClose = () => {
        setVisible(false);
    };

    const handleMinimize = () => {
        // 处理最小化逻辑
    };

    const handleHelp = () => {
        // 处理帮助逻辑
    };

    return (
        <View style={styles.container}>
            <View style={styles.header}>
                <Text style={styles.headerText}>黑色蒙层和覆盖透明图片</Text>
                <View style={styles.iconContainer}>
                    <TouchableOpacity onPress={handleHelp} style={styles.iconButton}>
                        <Icon type='question-circle-o' size={18} tintColor='rgba(255, 255, 255, 0.7)' />
                    </TouchableOpacity>
                    <TouchableOpacity onPress={handleMinimize} style={styles.iconButton}>
                        <Icon type='minus' size={18} tintColor='rgba(255, 255, 255, 0.7)' />
                    </TouchableOpacity>
                    <TouchableOpacity onPress={handleClose} style={styles.iconButton}>
                        <Icon type='times' size={18} tintColor='rgba(255, 255, 255, 0.7)' />
                    </TouchableOpacity>
                </View>
            </View>
            <View style={styles.wrap}>
                {visible && (
                    <View style={styles.overlayContainer}>
                        <TouchableOpacity style={styles.overlay} onPress={handleClose}>
                            <Image source={require('@src/assets/test/bk.png')} style={styles.overlayImage} />
                        </TouchableOpacity>
                    </View>
                )}

                <View style={styles.effectsRow}>
                    <TouchableOpacity style={styles.effectContainer}>
                        <Image source={require('@src/assets/test/pika1.gif')} style={styles.effectImage} />
                        <Text style={styles.effectText}>城堡</Text>
                    </TouchableOpacity>
                    <TouchableOpacity style={styles.effectContainer}>
                        <Image source={require('@src/assets/test/pika2.gif')} style={styles.effectImage} />
                        <Text style={styles.effectText}>发射爱心</Text>
                    </TouchableOpacity>
                    <TouchableOpacity style={styles.effectContainer}>
                        <Image source={require('@src/assets/test/pika3.gif')} style={styles.effectImage} />
                        <Text style={styles.effectText}>创世纪摩托车</Text>
                    </TouchableOpacity>
                </View>
            </View>
        </View>
    );
}

const styles = StyleSheet.create({
    container: {
        // flex: 1,
        borderTopLeftRadius: 12,
        borderTopRightRadius: 12,
        overflow: 'hidden',
        height: 576
    },
    wrap: {
        // flex: 1,
        backgroundColor: '#2E3137',
        paddingTop: 10,
        paddingHorizontal: 20,
    },
    header: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        paddingHorizontal: 10,
        paddingVertical: 5,
        backgroundColor: '#25272C',
        height: 40,
    },
    headerText: {
        color: '#FFFFFF',
        fontSize: 14,
        fontWeight: '400',
        fontFamily: 'Microsoft YaHei',
        lineHeight: 16,
    },
    iconContainer: {
        width: 98,
        height: 18,
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
    },
    iconButton: {
        width: 18,
        height: 18,
        justifyContent: 'center',
        alignItems: 'center',
    },
    overlayContainer: {
        ...StyleSheet.absoluteFillObject,
        zIndex: 2,
    },
    overlay: {
        ...StyleSheet.absoluteFillObject,
        backgroundColor: 'rgba(0, 0, 0, 0.8)',
    },
    overlayImage: {
        width: 375,
        height: 536,
    },
    effectsRow: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        marginTop: 20,
    },
    effectContainer: {
        alignItems: 'center',
        width: 100,
        backgroundColor: '#2E3137',
        padding: 10,
        borderRadius: 10,
    },
    effectImage: {
        width: 50,
        height: 50,
        marginBottom: 8,
    },
    effectText: {
        fontFamily: 'Microsoft YaHei',
        color: '#FFFFFF',
        fontSize: 12,
    },
});

export default MaskPannel;

1.黑色蒙层#000000 80%,首次打开弹出

2.点击图片可以关闭

相关推荐
进取星辰14 分钟前
25、Tailwind:魔法速记术——React 19 样式新思路
前端·react.js·前端框架
struggle202533 分钟前
continue通过我们的开源 IDE 扩展和模型、规则、提示、文档和其他构建块中心,创建、共享和使用自定义 AI 代码助手
javascript·ide·python·typescript·开源
x-cmd1 小时前
[250512] Node.js 24 发布:ClangCL 构建,升级 V8 引擎、集成 npm 11
前端·javascript·windows·npm·node.js
夏之小星星1 小时前
el-tree结合checkbox实现数据回显
前端·javascript·vue.js
Bl_a_ck2 小时前
【React】Craco 简介
开发语言·前端·react.js·typescript·前端框架
为美好的生活献上中指3 小时前
java每日精进 5.11【WebSocket】
java·javascript·css·网络·sql·websocket·网络协议
寧笙(Lycode)4 小时前
React系列——HOC高阶组件的封装与使用
前端·react.js·前端框架
拖孩4 小时前
【Nova UI】十五、打造组件库之滚动条组件(上):滚动条组件的起步与进阶
前端·javascript·css·vue.js·ui组件库
苹果电脑的鑫鑫4 小时前
element中表格文字剧中可以使用的属性
javascript·vue.js·elementui
一丝晨光5 小时前
数值溢出保护?数值溢出应该是多少?Swift如何让整数计算溢出不抛出异常?类型最大值和最小值?
java·javascript·c++·rust·go·c·swift