GradientText.tsx 838 B

12345678910111213141516171819202122232425262728
  1. import React from "react";
  2. import { Text } from "react-native";
  3. import MaskedView from "@react-native-masked-view/masked-view";
  4. import LinearGradient from "react-native-linear-gradient";
  5. import { ColorType } from "@/context/themes/color";
  6. import { View } from "@tarojs/components";
  7. const GradientText = (props) => {
  8. return (
  9. <View onClick={()=>{
  10. if (props.onClick){
  11. props.onClick()
  12. }
  13. }}>
  14. <MaskedView maskElement={<Text {...props} />}>
  15. <LinearGradient
  16. colors={[props.start ? props.start : ColorType.fast, props.end ? props.end : ColorType.sleep]}
  17. start={{ x: 0, y: 0 }}
  18. end={{ x: 1, y: 0 }}
  19. >
  20. <Text {...props} style={[props.style, { opacity: 0 }]} />
  21. </LinearGradient>
  22. </MaskedView>
  23. </View>
  24. );
  25. };
  26. export default GradientText;