廓形仪rn版本-技术调研
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

  1. 'use client';
  2. import React from 'react';
  3. import { createPressable } from '@gluestack-ui/pressable';
  4. import { Pressable as RNPressable } from 'react-native';
  5. import { tva } from '@gluestack-ui/nativewind-utils/tva';
  6. import { withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext';
  7. import type { VariantProps } from '@gluestack-ui/nativewind-utils';
  8. const UIPressable = createPressable({
  9. Root: withStyleContext(RNPressable),
  10. });
  11. const pressableStyle = tva({
  12. base: 'data-[focus-visible=true]:outline-none data-[focus-visible=true]:ring-indicator-info data-[focus-visible=true]:ring-2 data-[disabled=true]:opacity-40',
  13. });
  14. type IPressableProps = Omit<
  15. React.ComponentProps<typeof UIPressable>,
  16. 'context'
  17. > &
  18. VariantProps<typeof pressableStyle>;
  19. const Pressable = React.forwardRef<
  20. React.ComponentRef<typeof UIPressable>,
  21. IPressableProps
  22. >(function Pressable({ className, ...props }, ref) {
  23. return (
  24. <UIPressable
  25. {...props}
  26. ref={ref}
  27. className={pressableStyle({
  28. class: className,
  29. })}
  30. />
  31. );
  32. });
  33. Pressable.displayName = 'Pressable';
  34. export { Pressable };