From de1175c5e2eae08e4117bd7f1785e5706adc0c14 Mon Sep 17 00:00:00 2001 From: Enzo Manuel Mangano Date: Tue, 8 Oct 2024 15:07:25 +0200 Subject: [PATCH] docs: readme --- README.md | 63 +++++++++++++++++++++++++++++++++++---------- example/src/App.tsx | 17 +++++++++--- 2 files changed, 62 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e7596c8..d1c973d 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,13 @@ function BasicPressablesExample() { return ( console.log('scale')} /> - console.log('opacity')} /> + console.log('opacity')} + /> ); } - ``` ### Create a custom Pressable with createAnimatedPressable @@ -49,15 +51,16 @@ function BasicPressablesExample() { import { createAnimatedPressable } from 'pressto'; const PressableRotate = createAnimatedPressable((progress) => ({ - transform: [ - { rotate: `${progress.value * Math.PI / 4}rad` }, - ], + transform: [{ rotate: `${(progress.value * Math.PI) / 4}rad` }], })); function CustomPressableExample() { return ( - console.log('rotate')} /> + console.log('rotate')} + /> ); } @@ -73,22 +76,32 @@ import { PressablesConfig } from 'pressto'; function App() { return ( - console.log('rotate')} /> + console.log('rotate')} + /> console.log('scale')} /> - console.log('opacity')} /> + console.log('opacity')} + /> ); } export default () => ( - { - console.log('you can call haptics here'); - } - }}> + { + console.log('you can call haptics here'); + }, + }} + > -) +); ``` ## API @@ -120,3 +133,25 @@ MIT --- Made with ❤️ using [create-react-native-library](https://github.com/callstack/react-native-builder-bob) + +### Use with ScrollView and FlatList + +`pressto` provides a custom scroll component that enhances the scrolling experience when used with pressable components. + +```jsx +import { renderScrollComponent } from 'pressto'; +import { FlatList } from 'react-native'; + +function App() { + return ( + // This works with all the lists that support the renderScrollComponent prop + } + /> + ); +} +``` + +The `renderScrollComponent` function wraps the scroll view with additional functionality in order to allow smoother interactions between scrolling and pressable components, preventing unwanted activations during scroll gestures. diff --git a/example/src/App.tsx b/example/src/App.tsx index f448d47..32b7fde 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -17,7 +17,7 @@ const PressableRotate = createAnimatedPressable((progress) => { backgroundColor: interpolateColor( progress.value, [0, 1], - ['#474747', '#000000'] + ['#d1d1d1', '#000000'] ), shadowColor: '#ffffff', shadowOffset: { @@ -46,13 +46,22 @@ function App() { const styles = StyleSheet.create({ container: { - // flex: 1, + paddingTop: 25, backgroundColor: '#fff', + gap: 10, }, box: { - width: 120, + width: '95%', height: 120, - backgroundColor: 'gray', + elevation: 5, + shadowColor: '#000000', + shadowOffset: { + width: 0, + height: 0, + }, + shadowOpacity: 0.5, + backgroundColor: 'red', + shadowRadius: 10, borderRadius: 35, borderCurve: 'continuous', alignSelf: 'center',