ShadowView.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. export const ShadowViewV2 = ({
  28. offset=42,
  29. style=styles.shadowViewV2,
  30. shadowColor="#222222"
  31. }) => (
  32. <View style={style}>
  33. <Svg width={$vw(100)-offset} height={$vw(4.36)} viewBox="0 0 342 15" fill="none">
  34. <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)"/>
  35. <Defs>
  36. <LinearGradient id="paint0_linear_4117_1875" x1="171" y1="15" x2="171" y2="0" gradientUnits="userSpaceOnUse">
  37. <Stop stopColor="#ddd"/>
  38. <Stop offset="1" stopColor={shadowColor}/>
  39. </LinearGradient>
  40. </Defs>
  41. </Svg>
  42. </View>
  43. );
  44. const styles = StyleSheet.create({
  45. shadowView: {
  46. opacity: 0.8,
  47. marginTop: -6,
  48. marginLeft: 16,
  49. marginRight: 16
  50. },
  51. shadowViewV2: {
  52. zIndex: 1,
  53. opacity: .8,
  54. marginTop: -8,
  55. marginLeft: 20,
  56. marginRight: 20,
  57. display: "none"
  58. }
  59. })