1.0.4 • Published 4 years ago

react-native-draganddrop-board v1.0.4

Weekly downloads
13
License
ISC
Repository
github
Last release
4 years ago

Introduction

react-native-draganddrop-board is a simple React Native library, enabling to create a scrollable board component with carousel, sortable columns and draggable cards for your iOS and Android apps.

Move Gif MoveInColumn Gif Scroll Gif

Installation

Install library via npm or yarn

npm install react-native-draganddrop-board or yarn add react-native-draganddrop-board

In Use

First you need to build and fill with data BoardRepository:

import { BoardRepository } from 'react-native-draganddrop-board'

const data = [
  {
    id: 1,
    name: 'TO DO',
    rows: [
      {
        id: '1',
        name: 'Analyze your audience',
        description: 'Learn more about the audience to whom you will be speaking'
      },
      {
        id: '2',
        name: 'Select a topic',
        description: 'Select a topic that is of interest to the audience and to you'
      },
      {
        id: '3',
        name: 'Define the objective',
        description: 'Write the objective of the presentation in a single concise statement'
      }
    ]
  },
  {
    id: 2,
    name: 'IN PROGRESS',
    rows: [
      {
        id: '4',
        name: 'Look at drawings',
        description: 'How did they use line and shape? How did they shade?'
      },
      {
        id: '5',
        name: 'Draw from drawings',
        description: 'Learn from the masters by copying them'
      },
      {
        id: '6',
        name: 'Draw from photographs',
        description: 'For most people, it’s easier to reproduce an image that’s already two-dimensional'
      }
    ]
  },
  {
    id: 3,
    name: 'DONE',
    rows: [
      {
        id: '7',
        name: 'Draw from life',
        description: 'Do you enjoy coffee? Draw your coffee cup'
      },
      {
        id: '8',
        name: 'Take a class',
        description: 'Check your local university extension'
      }
    ]
  }
]

const boardRepository = new BoardRepository(data);

Then you can render the Board:

import { Board } from 'react-native-draganddrop-board'

  <Board
    boardRepository={boardRepository}
    open={() => {}}
    onDragEnd={() => {}}
  />

Board component

PropertyTypeRequiredDescription
boardRepositoryBoardRepositoryyesobject that holds data
boardBackgroundstringnoboard background color
openfunctionyesfunction invoked when item is pressed, returns item
onDragEndfunctionyesfunction invoked when drag is finished, returns srcColumnId, destColumnId, draggedItem

All props from Board, Card, Column and Empty components should be added to <Board />

Data update

Data can be changed within our predefined class 'boardRepository'. 'boardRepository.updateData(data)' That way we won't have to rerender the Board and class objects.

Card component

If you want to use default Card you should build your boardRepository with rows that have elements id, nameand description:

  {
     id: '1',
     name: 'Analyze your audience',
     description: 'Learn more about the audience to whom you will be speaking'
  }
PropertyTypeRequiredDescription
cardNameTextColorstringnocolor of the first line (name)
cardNameFontSizenumbernofont size of of the first line (name)
cardNameFontFamilystringnofont family of the first line (name)
cardDescriptionTextColorstringnocolor of the second line (description)
cardDescriptionFontSizenumbernofont size of the second line (description)
cardDescriptionFontFamilystringnofont family of the second line (description)
cardIconColorstringnocolor of the icon (arrow)

If you need to have another elements in rows, then you can use cardContent prop - it's a function that returns item element and can take another Components to fill Card.

import { Text, View } from 'react-native'
import { Board } from 'react-native-draganddrop-board'

  <Board
    boardRepository={boardRepository}
    open={() => {}}
    onDragEnd={() => {}}
    cardContent={(item) => (<View><Text>{item.name}</Text></View>)}
  />
PropertyTypeRequiredDescription
cardBackgroundstringnocard background color
cardBorderRadiusnumbernocard border radius value
isCardWithShadowboolnoadd shadow to card component

Column component

PropertyTypeRequiredDescription
badgeBackgroundColorstringnocolor of the count badge
badgeBorderRadiusnumbernocount badge border radius
badgeHeightnumbernoheight of the count badge
badgeWidthstringnowidth of the count badge
badgeTextColorstringnocolor of the count badge
badgeTextFontSizenumbernofont size of the count badge
badgeTextFontFamilystringnofont family of the count badge
columnBackgroundColorstringnocolumn background color
columnBorderRadiusnumbernocolumn border radius
columnHeightnumbernoheight of the column
columnNameTextColorstringnocolor of the column
columnNameFontSizenumbernofont size of the column
columnNameFontFamilystringnofont family of the column
isWithCountBadgeboolnoif false then the count badge is not visible

Empty column component

Empty Gif

You can use default empty column component:

PropertyTypeRequiredDescription
emptyIconColorstringnocolor of the icon
emptyTextColorstringnocolor of the text
emptyFontSizenumbernofont size of the text
emptyFontFamilystringnofont family of the text

You can also create your own empty column component:

PropertyTypeRequiredDescription
emptyComponentfunctionnofunction that should return custom empty column component

Tech stack

React Native 0.61.4

License

Copyright (c) 2019, Natalia Muryn

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.