1import React from 'react'; 2import {StyleSheet, Image, View} from 'react-native'; 3import rpx from '@/utils/rpx'; 4import {ImgAsset} from '@/constants/assetsConst'; 5 6interface IColorBlockProps { 7 color: string; 8} 9export default function ColorBlock(props: IColorBlockProps) { 10 const {color} = props; 11 12 return ( 13 <View style={[styles.showBar]}> 14 <Image 15 resizeMode="repeat" 16 source={ImgAsset.transparentBg} 17 style={styles.transparentBg} 18 /> 19 <View 20 style={[ 21 styles.showBarContent, 22 { 23 backgroundColor: color, 24 }, 25 ]} 26 /> 27 </View> 28 ); 29} 30 31const styles = StyleSheet.create({ 32 showBar: { 33 width: rpx(76), 34 height: rpx(50), 35 borderWidth: 1, 36 borderStyle: 'solid', 37 borderColor: '#ccc', 38 }, 39 showBarContent: { 40 width: '100%', 41 height: '100%', 42 position: 'absolute', 43 left: 0, 44 top: 0, 45 }, 46 transparentBg: { 47 position: 'absolute', 48 zIndex: -1, 49 width: '100%', 50 height: '100%', 51 left: 0, 52 top: 0, 53 }, 54}); 55