From 9e4e50e468239924c9df3f9ccaada156ff4249eb Mon Sep 17 00:00:00 2001 From: amerllica Date: Thu, 27 Mar 2025 17:43:43 +0330 Subject: [PATCH 1/2] Add type of onPress --- dist/components/FontAwesomeIcon.js | 1 + index.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/components/FontAwesomeIcon.js b/dist/components/FontAwesomeIcon.js index b87b492..9463600 100644 --- a/dist/components/FontAwesomeIcon.js +++ b/dist/components/FontAwesomeIcon.js @@ -140,6 +140,7 @@ function FontAwesomeIcon(props) { FontAwesomeIcon.displayName = 'FontAwesomeIcon'; FontAwesomeIcon.propTypes = { + onPress: _propTypes["default"].func, height: _propTypes["default"].number, width: _propTypes["default"].number, size: _propTypes["default"].number, diff --git a/index.d.ts b/index.d.ts index 5ac0d4a..11264de 100644 --- a/index.d.ts +++ b/index.d.ts @@ -24,6 +24,7 @@ export interface Props { transform?: string | Transform; style?: FontAwesomeIconStyle; testID?: string; + onPress?: () => void; } export function FontAwesomeIcon(props: Props): JSX.Element; From cc120ce3053e25c38737beb8c60e672b8cb78ee5 Mon Sep 17 00:00:00 2001 From: amerllica Date: Thu, 27 Mar 2025 17:44:03 +0330 Subject: [PATCH 2/2] Add onPress and pass it to the root element --- dist/components/FontAwesomeIcon.js | 11 ++++++++--- src/components/FontAwesomeIcon.js | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dist/components/FontAwesomeIcon.js b/dist/components/FontAwesomeIcon.js index 9463600..3b7dc33 100644 --- a/dist/components/FontAwesomeIcon.js +++ b/dist/components/FontAwesomeIcon.js @@ -73,6 +73,8 @@ function normalizeIconArgs(icon) { } } +const noop = () => {}; + function FontAwesomeIcon(props) { var _props = _objectSpread({ icon: null, @@ -83,7 +85,8 @@ function FontAwesomeIcon(props) { color: null, secondaryColor: null, secondaryOpacity: null, - size: DEFAULT_SIZE + size: DEFAULT_SIZE, + onPress: noop }, props); var iconArgs = _props.icon, @@ -91,7 +94,8 @@ function FontAwesomeIcon(props) { maskId = _props.maskId, height = _props.height, width = _props.width, - size = _props.size; + size = _props.size, + onPress = _props.onPress; var style = _reactNative.StyleSheet.flatten(_props.style); @@ -134,6 +138,7 @@ function FontAwesomeIcon(props) { rootAttributes.height = resolvedHeight; rootAttributes.width = resolvedWidth; rootAttributes.style = modifiedStyle; + rootAttributes.onPress = onPress; replaceCurrentColor(_abstract[0], color, secondaryColor, secondaryOpacity); return convertCurry(_abstract[0]); } @@ -187,4 +192,4 @@ function replaceFill(obj, primaryColor, secondaryColor, secondaryOpacity) { function hasPropertySetToValue(obj, property, value) { return Object.prototype.hasOwnProperty.call(obj, property) && obj[property] === value; -} \ No newline at end of file +} diff --git a/src/components/FontAwesomeIcon.js b/src/components/FontAwesomeIcon.js index 876839e..808f529 100644 --- a/src/components/FontAwesomeIcon.js +++ b/src/components/FontAwesomeIcon.js @@ -38,6 +38,8 @@ function normalizeIconArgs (icon) { } } +const noop = () => {}; + export default function FontAwesomeIcon (props) { const _props = { icon: null, @@ -49,10 +51,11 @@ export default function FontAwesomeIcon (props) { secondaryColor: null, secondaryOpacity: null, size: DEFAULT_SIZE, + onPress: noop, ...props } - const { icon: iconArgs, mask: maskArgs, maskId, height, width, size } = _props + const { icon: iconArgs, mask: maskArgs, maskId, height, width, size, onPress } = _props const style = StyleSheet.flatten(_props.style) const iconLookup = normalizeIconArgs(iconArgs) @@ -106,6 +109,7 @@ export default function FontAwesomeIcon (props) { rootAttributes.height = resolvedHeight rootAttributes.width = resolvedWidth rootAttributes.style = modifiedStyle + rootAttributes.onPress = onPress replaceCurrentColor(abstract[0], color, secondaryColor, secondaryOpacity)