npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rameshupadhaya/react-native-dnd-board

v1.0.0

Published

Drag and drop Kanban board like Trello

Downloads

78

Readme

React Native DnD Board

A drag and drop Kanban board for React Native using Reanimated (V1) and React Native Gesture Handler.

Installation

Step 1:

Install Reanimated V1.

Step 2:

Install React Native Gesture Handler.

Make sure your MainActivity.java was updated by follow all Android instructions.

React Native Gesture Handler IMPORTANT NOTE: If you're using wix/react-native-navigation, please wrap your board screen using gestureHandlerRootHOC (View RNGH docs for more details). If not do it, your board won't work.

Step 3:

Install this package using npm or yarn

with npm:

npm install react-native-dnd-board

with yarn:

yarn add react-native-dnd-board

API reference

The package exports a Board component which is the one you'd use to render the dnd board and a Repository class to handle column, row layout.

Board

| Property | Type | Required | Description | | :------------------ | :------------------------------------------------------ | :------: | :---------------------------------------------------------------------- | | repository | Repository | yes | Object that holds data | | renderRow | ({ item, index }) => {} | yes | Function responsible for rendering row item | | renderColumnWrapper | ({ item, index, columnComponent, layoutProps }) => {} | yes | Function responsible for rendering wrapper of the column | | onRowPress | (row) => {} | no | Function invoked when row pressed | | onDragStart | () => {} | no | Function invoked when drag is started | | onDragEnd | (fromColumnId, toColumnId, row) => {} | no | Function invoked when drag is finished | | style | StyleProp | no | Style of the board | | columnWidth | number | no | Initial min column width | | accessoryRight | function\|View | no | Render end of the board. Useful when rendering virtual add more column. | | activeRowStyle | StyleProp | no | A custom style for the row when being dragged. | | activeRowRotation | number | no | Degrees to rotate the row when being dragged. Default is 8. | | xScrollThreshold | number | no | Offset from X to calculate scroll from. Default is 50. | | yScrollThreshold | number | no | Offset from Y for the rows. Default is 50. | | dragSpeedFactor | number | no | When dragging you can accelerate the scrollTo position. Default is 1. |

Repository

Update repository data:

repository.updateData(data);

Handle column data:

repository.addColumn(data);
repository.updateColumn(columnId, data);
repository.deleteColumn(columnId);

Handle row data:

repository.addRow(columnId, data);
repository.updateRow(rowId, data);
repository.deleteRow(rowId);

Get rows with index updated:

const { rows } = repository.getItemsChanged();

Example

Usage

You need to build Repository

import Board, { Repository } from "react-native-dnd-board";

const mockData = [
  {
    id: "1",
    name: "Column 1",
    rows: [
      {
        id: "11",
        name: "Row 1 (Column 1)",
      },
      {
        id: "12",
        name: "Row 2 (Column 1)",
      },
    ],
  },
  {
    id: "2",
    name: "Column 2",
    rows: [
      {
        id: "21",
        name: "Row 1 (Column 2)",
      },
    ],
  },
];

const [repository, setRepository] = useState(new Repository(mockData));

Render the Board

<Board
  repository={repository}
  renderRow={renderCard}
  renderColumnWrapper={renderColumnWrapper}
  onRowPress={onCardPress}
  onDragEnd={onDragEnd}
/>

renderColumnWrapper function

const renderColumnWrapper = ({ item, columnComponent, layoutProps }) => {
  return (
    <View style={styles.column} {...layoutProps}>
      <Text style={styles.columnName}>{item.name}</Text>
      {columnComponent}
    </View>
  );
};

IMPORTANT: You need pass layoutProps to wrapper view props and columnComponent must be rendered inside renderColumnWrapper fuction.

See example for more details.

Performance

We're trying to improve board performance. If you have a better solution, please open a issue or pull request. Best regards!