xref: /MusicFree/src/components/base/colorBlock.tsx (revision 5589cdf32b2bb0f641e5ac7bf1f6152cd6b9b70e)
157277364S猫头猫import React from 'react';
2*5589cdf3S猫头猫import {Image, StyleSheet, View} from 'react-native';
357277364S猫头猫import rpx from '@/utils/rpx';
457277364S猫头猫import {ImgAsset} from '@/constants/assetsConst';
557277364S猫头猫
657277364S猫头猫interface IColorBlockProps {
757277364S猫头猫    color: string;
857277364S猫头猫}
957277364S猫头猫export default function ColorBlock(props: IColorBlockProps) {
1057277364S猫头猫    const {color} = props;
1157277364S猫头猫
1257277364S猫头猫    return (
1357277364S猫头猫        <View style={[styles.showBar]}>
1457277364S猫头猫            <Image
1557277364S猫头猫                resizeMode="repeat"
1657277364S猫头猫                source={ImgAsset.transparentBg}
1757277364S猫头猫                style={styles.transparentBg}
1857277364S猫头猫            />
1957277364S猫头猫            <View
2057277364S猫头猫                style={[
2157277364S猫头猫                    styles.showBarContent,
2257277364S猫头猫                    {
2357277364S猫头猫                        backgroundColor: color,
2457277364S猫头猫                    },
2557277364S猫头猫                ]}
2657277364S猫头猫            />
2757277364S猫头猫        </View>
2857277364S猫头猫    );
2957277364S猫头猫}
3057277364S猫头猫
3157277364S猫头猫const styles = StyleSheet.create({
3257277364S猫头猫    showBar: {
3357277364S猫头猫        width: rpx(76),
3457277364S猫头猫        height: rpx(50),
3557277364S猫头猫        borderWidth: 1,
3657277364S猫头猫        borderStyle: 'solid',
3757277364S猫头猫        borderColor: '#ccc',
3857277364S猫头猫    },
3957277364S猫头猫    showBarContent: {
4057277364S猫头猫        width: '100%',
4157277364S猫头猫        height: '100%',
4257277364S猫头猫        position: 'absolute',
4357277364S猫头猫        left: 0,
4457277364S猫头猫        top: 0,
4557277364S猫头猫    },
4657277364S猫头猫    transparentBg: {
4757277364S猫头猫        position: 'absolute',
4857277364S猫头猫        zIndex: -1,
4957277364S猫头猫        width: '100%',
5057277364S猫头猫        height: '100%',
5157277364S猫头猫        left: 0,
5257277364S猫头猫        top: 0,
5357277364S猫头猫    },
5457277364S猫头猫});
55