Skip to content

Commit

Permalink
feat: add custom scale decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmydel committed Aug 24, 2023
1 parent e3345c0 commit 583d274
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
26 changes: 14 additions & 12 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TouchableOpacity,
Text,
} from 'react-native';
import { MyDraggableList } from 'react-native-awesome-module';
import { MyDraggableList, MyScaleDecorator } from 'react-native-awesome-module';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

const getItems = (count: number) =>
Expand All @@ -23,17 +23,19 @@ export default function App() {

const renderItem = ({ item, drag, isActive }: any) => {
return (
<TouchableOpacity
onLongPress={drag}
disabled={isActive}
style={[
styles.rowItem,
{ backgroundColor: isActive ? '#111111' : item.backgroundColor },
]}
>
<Text style={styles.text}>{item.content.label}</Text>
<Text>{item.content.subtitle}</Text>
</TouchableOpacity>
<MyScaleDecorator>
<TouchableOpacity
onLongPress={drag}
disabled={isActive}
style={[
styles.rowItem,
{ backgroundColor: isActive ? '#111111' : item.backgroundColor },
]}
>
<Text style={styles.text}>{item.content.label}</Text>
<Text>{item.content.subtitle}</Text>
</TouchableOpacity>
</MyScaleDecorator>
);
};

Expand Down
6 changes: 6 additions & 0 deletions src/decorators/MyScaleDecorator/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import { ScaleDecorator } from 'react-native-draggable-flatlist';

export function MyScaleDecorator({ children }) {
return <ScaleDecorator>{children}</ScaleDecorator>;
}
3 changes: 3 additions & 0 deletions src/decorators/MyScaleDecorator/index.web.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function MyScaleDecorator({ children }) {
return children;
}
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'react-native-gesture-handler';

export { MyDraggableList } from './MyDraggableList';
export { MyScaleDecorator } from './decorators/MyScaleDecorator';

0 comments on commit 583d274

Please sign in to comment.