Skip to content

Commit

Permalink
feat: pressable opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
enzomanuelmangano committed Sep 17, 2024
1 parent c5f6802 commit 3f07f86
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
12 changes: 11 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { PressableScale, PressablesConfig } from '@reactiive/pressables';
import {
PressableOpacity,
PressableScale,
PressablesConfig,
} from '@reactiive/pressables';
import { StyleSheet, View } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

Expand All @@ -9,6 +13,9 @@ export default function App() {
<PressableScale onPress={() => console.log('pressed')}>
<View style={styles.box} />
</PressableScale>
<PressableOpacity onPress={() => console.log('pressed')}>
<View style={[styles.box, styles.customBox]} />
</PressableOpacity>
</GestureHandlerRootView>
</PressablesConfig>
);
Expand All @@ -25,4 +32,7 @@ const styles = StyleSheet.create({
height: 200,
backgroundColor: 'red',
},
customBox: {
backgroundColor: 'blue',
},
});
2 changes: 2 additions & 0 deletions src/pressables/custom/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './opacity';
export * from './scale';
9 changes: 9 additions & 0 deletions src/pressables/custom/opacity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { interpolate } from 'react-native-reanimated';
import { createAnimatedPressable } from '../hoc';

export const PressableOpacity = createAnimatedPressable((progress) => {
'worklet';
return {
opacity: interpolate(progress.value, [0, 1], [1, 0.5]),
};
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { interpolate } from 'react-native-reanimated';
import { createAnimatedPressable } from './hoc';
import { createAnimatedPressable } from '../hoc';

export const PressableScale = createAnimatedPressable((progress) => {
'worklet';
Expand Down
2 changes: 1 addition & 1 deletion src/pressables/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './custom';
export * from './hoc';
export * from './scale';

0 comments on commit 3f07f86

Please sign in to comment.