@kietpt2003/react-native-core-ui
Version:
React Native Core UI components by KietPT
31 lines (30 loc) • 1.22 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from 'react';
import { Pressable, View, StyleSheet, } from 'react-native';
const CardActionArea = React.forwardRef(({ children, onPress, disabled = false, style, contentStyle, accessibilityRole = 'button', }, ref) => {
return (_jsxs(Pressable, { ref: ref, disabled: disabled, onPress: onPress, accessibilityRole: accessibilityRole, style: ({ pressed }) => [
styles.root,
style,
pressed && styles.pressed,
disabled && styles.disabled,
], children: [_jsx(View, { style: [styles.content, contentStyle], children: children }), _jsx(View, { pointerEvents: "none", style: styles.focusHighlight })] }));
});
CardActionArea.displayName = 'CardActionArea';
const styles = StyleSheet.create({
root: {
width: '100%',
borderRadius: 12,
overflow: 'hidden',
},
content: {
width: '100%',
},
pressed: {
opacity: 0.92,
},
disabled: {
opacity: 0.5,
},
focusHighlight: Object.assign(Object.assign({}, StyleSheet.absoluteFillObject), { backgroundColor: 'rgba(0,0,0,0.08)', opacity: 0 }),
});
export default CardActionArea;