react-native#TouchableOpacityProps TypeScript Examples

The following examples show how to use react-native#TouchableOpacityProps. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IconButton.tsx    From vsinder with Apache License 2.0 7 votes vote down vote up
IconButton: React.FC<
  TouchableOpacityProps & { secondary?: boolean; size?: number }
> = ({ children, secondary, style, size = 40, ...props }) => {
  const [{ buttonBackground, buttonSecondaryBackground }] = useContext(
    ThemeContext
  );
  return (
    <TouchableOpacity
      style={[
        {
          width: size,
          height: size,
          borderRadius: size / 2,
          backgroundColor: secondary
            ? buttonSecondaryBackground
            : buttonBackground,
          alignItems: "center",
          justifyContent: "center",
        },
        style,
      ]}
      {...props}
    >
      {children}
    </TouchableOpacity>
  );
}
Example #2
Source File: LoadingButton.tsx    From vsinder with Apache License 2.0 6 votes vote down vote up
LoadingButton: React.FC<
  TouchableOpacityProps & { isLoading: boolean }
> = ({ isLoading, children, disabled, ...props }) => {
  const { buttonForeground } = useTheme();
  return (
    <MyButton {...props} disabled={disabled || isLoading}>
      {isLoading ? <ActivityIndicator color={buttonForeground} /> : children}
    </MyButton>
  );
}
Example #3
Source File: ListButton.tsx    From jellyfin-audio-player with MIT License 6 votes vote down vote up
ListButton: React.FC<TouchableOpacityProps> = ({ children, ...props }) => {
    const defaultStyles = useDefaultStyles();
    const [isPressed, setPressed] = useState(false);
    const handlePressIn = useCallback(() => setPressed(true), []);
    const handlePressOut = useCallback(() => setPressed(false), []);

    return (
        <Container
            {...props}
            onPressIn={handlePressIn}
            onPressOut={handlePressOut}
            style={[
                defaultStyles.border,
                isPressed ? defaultStyles.activeBackground : undefined
            ]}
        >
            <Label>{children}</Label>
            <ChevronRight width={BUTTON_SIZE} height={BUTTON_SIZE} fill={THEME_COLOR} />
        </Container>
    );
}
Example #4
Source File: Touchable.tsx    From krmanga with MIT License 6 votes vote down vote up
Touchable: React.FC<TouchableOpacityProps> = React.memo(({style, onPress, ...rest}) => {
        const touchableStyle = rest.disabled ? [style, styles.disabled] : style;
        let throttleOnPress = undefined;
        if (typeof onPress === 'function') {
            throttleOnPress = useCallback(
                _.throttle(onPress, 300, {leading: true, trailing: false}), [onPress]
            )
        }
        return (
            <TouchableOpacity onPress={throttleOnPress} style={touchableStyle} activeOpacity={0.8} {...rest} />
        )
    }
)
Example #5
Source File: MyButton.tsx    From vsinder with Apache License 2.0 5 votes vote down vote up
MyButton: React.FC<
  TouchableOpacityProps & { secondary?: boolean }
> = ({ children, secondary, style, ...props }) => {
  const [
    {
      buttonBackground,
      buttonForeground,
      buttonSecondaryBackground,
      buttonSecondaryForeground,
    },
  ] = useContext(ThemeContext);
  return (
    <TouchableOpacity
      style={[
        {
          width: "100%",
          paddingVertical: 10,
          paddingHorizontal: 4,
          backgroundColor: secondary
            ? buttonSecondaryBackground
            : buttonBackground,
          alignItems: "center",
          justifyContent: "center",
        },
        style,
      ]}
      {...props}
    >
      {typeof children === "string" ||
      (Array.isArray(children) && typeof children[0] === "string") ? (
        <Text
          style={{
            color: secondary ? buttonSecondaryForeground : buttonForeground,
            fontSize: 17,
            fontWeight: "600",
          }}
        >
          {children}
        </Text>
      ) : (
        children
      )}
    </TouchableOpacity>
  );
}
Example #6
Source File: CustomView.tsx    From react-native-paper-onboarding with MIT License 5 votes vote down vote up
AnimatedTouchableOpacity: React.FC<
  Animated.AnimateProps<ViewStyle, TouchableOpacityProps>
> = Animated.createAnimatedComponent(TouchableOpacity) as any