Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
react-native-inkwell
Advanced tools
A material touchable area that provides the ripple effect. Inspired by the InkWell Flutter component.
You need to have already installed the following packages:
Open a Terminal in your project's folder and install the library using yarn
:
yarn add react-native-inkwell
or with npm
:
npm install react-native-inkwell
import InkWell from 'react-native-inkwell';
const YourRippleButton = () => (
<InkWell
style={{
width: 200,
height: 200,
backgroundColor: 'white',
}}
contentContainerStyle={{
alignItems: 'center',
justifyContent: 'center',
}}
onTap={() => {
console.log('tapped');
}}
>
<Text>Tap Here</Text>
</InkWell>
);
enabled?: boolean
Indicates whether InkWell should be active or not.
Default: true
.
radius?: number
Decides the maximum radius of the Ripple Effect. By default the Ripple effect will determine the radius from the height and width of the component so that it can expand as much as possible.
onTap?: () => void
Called when the InkWell is clicked. If the onDoubleTap callback is not specified, onTap will be called immediately, otherwise it will be called after maxDelayMs.
onTapDown?: () => void
Called when the user taps down the InkWell.
onTapCancel?: () => void
Called when the user cancels a tap.
onDoubleTap?: () => void
Called when the InkWell is clicked two consecutive times in less than maxDelayMs.
onLongPress?: () => void
Called when the component is pressed for more than minDurationMs.
maxDelayMs?: number
This property is inherited from maxDelayMs of the react-native-gesture-handler's TapGestureHandler.
Default: 500
minDurationMs?: number
This property is inherited from minDurationMs of the react-native-gesture-handler's LongPressGestureHandler.
Default: 500
scaleDuration?: number
The duration of ink scale animation.
Default: depends on the component's width and height.
easing?: Animated.WithTimingConfig["easing"]
The Reanimated EasingFunction.
Default: Easing.bezier(0.25, 0.5, 0.4, 1.0)
splashColor?: string
The splash color of the ripple effect.
Default: rgba(0,0,0,0.1)
;
highlightColor?: string
The backgroundColor of the View when the InkWell is activated.
Default: rgba(0,0,0,0.03)
;
style?: StyleProp<ViewStyle>
contentContainerStyle?: StyleProp<ViewStyle>
The React Native style of the content.
children?: React.ReactNode
The component that could be contained in the InkWell.
simultaneousHandlers and waitFor
Since the InkWell is built on top of the react-native-gesture-handler component TapGestureHandler, by default, upon clicking an InkWell inside another, the tap will be propagated to the parent as well.
Fortunately, this case study is easily handled.
First, a Ref
must be created and assigned to the InkWell
that is being nested. Once this is done, the Ref
must be added to the childrenRefs property of the InkWell
.
That's it.
const NestedInkWellUseCase = () => {
const onTapParent = React.useCallback(() => {
console.log('Parent');
}, []);
const onTapChild = React.useCallback(() => {
console.log('Child');
}, []);
// 1. create the refs
const firstChildRef = React.useRef<InkWellRefType>(null);
const secondChildRef = React.useRef<InkWellRefType>(null);
return (
<View style={styles.buttonContainer}>
{/* Parent */}
<InkWell
style={styles.button}
contentContainerStyle={styles.contentButton}
onTap={onTapParent}
childrenRefs={[firstChildRef, secondChildRef]} // <-- 4. add the childRef to the childrenRefs
>
{/* First nested InkWell */}
<InkWell
ref={firstChildRef} // <-- 2. assign the firstChildRef
style={[styles.button, styles.innerButton]}
contentContainerStyle={styles.contentButton}
onTap={onTapChild}
>
<Text>Child</Text>
</InkWell>
{/* Second nested InkWell */}
<InkWell
ref={secondChildRef} // <-- 3. assign the secondChildRef
style={[styles.button, styles.innerButton]}
contentContainerStyle={styles.contentButton}
onTap={onTapChild}
>
<Text>Child</Text>
</InkWell>
</InkWell>
</View>
);
};
Here's the result:
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
FAQs
A material touchable area that provides the ripple effect
The npm package react-native-inkwell receives a total of 0 weekly downloads. As such, react-native-inkwell popularity was classified as not popular.
We found that react-native-inkwell demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.