ShadowView.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react';
  2. import { StyleSheet, Text, View } from 'react-native';
  3. import Svg, { Defs, Ellipse, G, LinearGradient, Path, Rect, Stop } from 'react-native-svg';
  4. /**
  5. * 阴影组件
  6. * @param {offset} 阴影左右偏移量(配合style实现margin)
  7. * @returns React Element
  8. */
  9. const ShadowView = ({
  10. offset=32,
  11. style=styles.shadowView,
  12. shadowColor="#888888"
  13. }) => (
  14. <View style={style}>
  15. <Svg width={$vw(100)-offset} height={$vw(4.36)} viewBox="0 0 342 15" fill="none">
  16. <Path d="M0 0H342V7C342 11.4183 338.418 15 334 15H8.00001C3.58173 15 0 11.4183 0 7V0Z" fill="url(#paint0_linear_4117_1875)"/>
  17. <Defs>
  18. <LinearGradient id="paint0_linear_4117_1875" x1="171" y1="15" x2="171" y2="0" gradientUnits="userSpaceOnUse">
  19. <Stop stopColor="#F9F9F9"/>
  20. <Stop offset="1" stopColor={shadowColor}/>
  21. </LinearGradient>
  22. </Defs>
  23. </Svg>
  24. </View>
  25. );
  26. export default ShadowView;
  27. const styles = StyleSheet.create({
  28. shadowView: {
  29. opacity: 0.8,
  30. marginTop: -6,
  31. marginLeft: 16,
  32. marginRight: 16
  33. }
  34. })