Socket
Socket
Sign inDemoInstall

react-native-drag-and-drop-list

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-drag-and-drop-list

The Drag and Drop List with Drop Box is an intuitive and user-friendly interface that allows users to easily organize and manage items by dragging them from a list and dropping them into a designated drop box.


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

React Native Drag and Drop List

The Drag and Drop List with Drop Box is an intuitive and user-friendly interface that allows users to easily organize and manage items by dragging them from a list and dropping them into a designated drop box.

Imgur

Imgur

Install

with npm

      npm install react-native-drag-and-drop-list
    

How to Use

Take in consideration the following data passed to component DragAndDropList i.e. the array must be in form of key and value

       const data = [
        { key: 1, value:"Mango" },
        { key: 2, value: "Orange" },
        { key: 3, value: "Apple" },
        { key: 4, value: "Banana" },
        { key: 5, value: "Cherry" },
        { key: 6, value: "Watermelon" },
        { key: 7, value: "Grapes" },
        { key: 8, value: "Pineapple" },
        ]

Props

All the props accepted are as follows:
NameTypeDescription
data[]Required. an array that populates the list
onDrop(item)=>void. a callback function that is called when user drops an item
listItemStylestylestyle properties that need to be applied on every item of list
containerWidthnumberwidth of the container that contains draggable list and drop area
dropBoxStylestylestyle properties that need to be applied on the dropbox
listItemContainerStylestylestyle properties that need to be applied on the container containing all the list items
listItemContainerStylestylestyle properties that need to be applied on the container containing all the list items
parentContainerStylestylestyle properties that need to be applied on the parent container containing both the list items and droppable area

Usage/Examples

import { StatusBar } from "expo-status-bar";
import { SafeAreaView, StyleSheet, Text, View } from "react-native";


import DragAndDropList from "react-native-drag-and-drop-list";
const data = [
  { key: 1, value: "Mango" },
  { key: 2, value: "Orange" },
  { key: 3, value: "Apple" },
  { key: 4, value: "Banana" },
  { key: 5, value: "Cherry" },
  { key: 6, value: "Watermelon" },
  { key: 7, value: "Grapes" },
  { key: 8, value: "Pineapple" },
];
export default function App() {
  return (
    <SafeAreaView style={{ width: "100%", height: "100%" }}>
      <View style={styles.container}>
        <DragAndDropList
          data={data}
          onDrop={(item) => {
            console.log(item);
          }}
          listItemStyle={{
            backgroundColor: "black",
            width: "80%",
          }}
          containerWidth={300}
          listItemContainerStyle={{
            backgroundColor:"skyblue",
            width:"50%"
          }}
           parentContainerStyle={
            {
              marginStart:100,
              marginTop:100
            }
          }

          dropBoxTitle="Drop Here"
          dropBoxStyle={{
    
            width: "50%",
            marginStart:100,
            height: "30%",
            backgroundColor: "orange",
          }}
        />

        <StatusBar style="auto" />
      </View>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
  },
});


const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
  },
});


Authors

  • Sanskar Atrey

Keywords

FAQs

Last updated on 25 Jul 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc